Package com.dotmarketing.beans

Examples of com.dotmarketing.beans.Host


        //Getting the theme path
        String themePath;
        if ( themeFolder.getHostId().equals( hostId ) ) {
            themePath = Template.THEMES_PATH + themeFolder.getName() + "/";
        } else {
            Host themeHost = APILocator.getHostAPI().find( themeFolder.getHostId(), APILocator.getUserAPI().getSystemUser(), false );
            themePath = "//" + themeHost.getHostname() + Template.THEMES_PATH + themeFolder.getName() + "/";
        }

        //Getting the template.vtl file path
        String themeTemplatePath;
        if ( UtilMethods.isSet( themeTemplate ) && InodeUtils.isSet( themeTemplate.getInode() ) ) {
View Full Code Here


      //Case when the subscriptions link is prepended with the host
      finalMessageStr = finalMessageStr.replaceAll("(?i)(http[s]?://[^/]+)/?(<|(&lt;))subscriptionsLink(\")?( )*/*( )*(>|(&gt;))", "$1/dotCMS/subscribe?dispatch=manageMailingList&ui="+PublicEncryptionFactory.encryptString(subscriber.getUserId()));

      //Case when the subscriptions link is alone then we prepend the default host to it 
      Host host;
      try {
        host = APILocator.getHostAPI().findDefaultHost(APILocator.getUserAPI().getSystemUser(), false);
      } catch (DotDataException e) {
        Logger.error(DeliverCampaignThread.class, e.getMessage(), e);
        throw new DotRuntimeException(e.getMessage(), e);
      } catch (DotSecurityException e) {
        Logger.error(DeliverCampaignThread.class, e.getMessage(), e);
        throw new DotRuntimeException(e.getMessage(), e);
      }
      String hostName = host.getHostname();
      finalMessageStr = finalMessageStr.replaceAll("(?i)(<|(&lt;))subscriptionsLink(\")?( )*/*( )*(>|(&gt;))", hostName+"/dotCMS/subscribe?dispatch=manageMailingList&ui="+PublicEncryptionFactory.encryptString(subscriber.getUserId()));
     
      finalMessageStr = finalMessageStr.replaceAll("(?i)(<|(&lt;))/fromName(>|(&gt;))", "");
      finalMessageStr = finalMessageStr.replaceAll("(?i)(<|(&lt;))fromName(\")?( )*/*( )*(>|(&gt;))", (comm.getFromName()!=null) ? comm.getFromName() : "");
     
View Full Code Here

      return;
    }
    /*
     * Getting host object form the session
     */
    Host host;
    try {
      host = whostAPI.getCurrentHost(request);
    } catch (Exception e) {
      Logger.warn(this, "Unable to retrieve current request host for URI " + uri);
      throw new ServletException(e.getMessage(), e);
    }

    // http://jira.dotmarketing.net/browse/DOTCMS-6079
    if (uri.endsWith("/"))
      uri = uri.substring(0, uri.length() - 1);
   
    String pointer = null;
   
    if(host!=null){
      pointer = VirtualLinksCache.getPathFromCache(host.getHostname() + ":" + uri);
    }
    if (!UtilMethods.isSet(pointer)) {
      pointer = VirtualLinksCache.getPathFromCache(uri);
    }
    if(UtilMethods.isSet(pointer)){
      uri = pointer;
    }

   
   
    String mastRegEx = null;
    StringBuilder query = null;
    try {
      mastRegEx = StructureCache.getURLMasterPattern();
    } catch (DotCacheException e2) {
      Logger.error(URLMapFilter.class, e2.getMessage(), e2);
    }
    if (mastRegEx == null) {
      synchronized (StructureCache.MASTER_STRUCTURE) {
        try {
          mastRegEx = buildCacheObjects();
        } catch (DotDataException e) {
          Logger.error(URLMapFilter.class, e.getMessage(), e);
          throw new ServletException("Unable to build URLMap patterns", e);
        }
      }
    }
    boolean trailSlash = uri.endsWith("/");
    boolean isDotPage = uri.substring(uri.lastIndexOf(".")+1).equals(Config.getStringProperty("VELOCITY_PAGE_EXTENSION"));
    String url = (!trailSlash && !isDotPage)?uri+'/':uri;
    if (!UtilMethods.isSet(mastRegEx) || uri.startsWith("/webdav")) {
      chain.doFilter(req, res);
      return;
    }
    if (RegEX.contains(url, mastRegEx)) {
      boolean ADMIN_MODE = (session.getAttribute(com.dotmarketing.util.WebKeys.ADMIN_MODE_SESSION) != null);
      boolean EDIT_MODE = ((session.getAttribute(com.dotmarketing.util.WebKeys.EDIT_MODE_SESSION) != null) && ADMIN_MODE);

      Structure structure = null;
      User user = null;
      try {
        user = wuserAPI.getLoggedInUser(request);
      } catch (Exception e1) {
        Logger.error(URLMapFilter.class, e1.getMessage(), e1);
      }
 
      List<ContentletSearch> cons = null;
      Collections.sort(patternsCache, new Comparator<PatternCache>(){
        public int compare(PatternCache o1, PatternCache o2) {
          String regex1 = o1.getRegEx();
          String regex2 = o2.getRegEx();
          if(!regex1.endsWith("/")){
            regex1+="/";
          }
          if(!regex2.endsWith("/")){
            regex2+="/";
          }
       
          int regExLength1 = getSlashCount(regex1);
            int regExLength2 = getSlashCount(regex2);
          if(regExLength1 < regExLength2){
                return 1;
            }else if(regExLength1 > regExLength2){
                return -1;
              }else{
                return 0
              }
        }
      });
      for (PatternCache pc : patternsCache) {
        List<RegExMatch> matches = RegEX.findForUrlMap(url, pc.getRegEx());
        if (matches != null && matches.size() > 0) {
          query = new StringBuilder();
          List<RegExMatch> groups = matches.get(0).getGroups();
          List<String> fieldMatches = pc.getFieldMatches();
          structure = StructureCache.getStructureByInode(pc.getStructureInode());
          List<Field> fields = FieldsCache.getFieldsByStructureInode(structure.getInode());
          query.append("+structureName:").append(structure.getVelocityVarName()).append(" +deleted:false ");
          if (EDIT_MODE || ADMIN_MODE) {
            query.append("+working:true ");
          } else {
            query.append("+live:true ");
          }

          // Set Host Stuff
          boolean hasHostField = false;
          Boolean hostIsRequired = false;
          for (Field field : fields) {
            if (field.getFieldType().equals(Field.FieldType.HOST_OR_FOLDER.toString())) {
              hasHostField = true;
              if (field.isRequired()) {
                hostIsRequired = true;
              }
              break;
            }
          }
          if (hasHostField) {
            if (host != null) {
              //if (hostIsRequired) {
              //query.append("+conhost:" + host.getIdentifier() + " ");
              //} else {
              try {
                query.append("+(conhost:").append(host.getIdentifier()).append(" ")
                     .append("conhost:").append(whostAPI.findSystemHost(wuserAPI.getSystemUser(), true).getIdentifier()).append(") ");
              } catch (Exception e) {
                Logger.error(URLMapFilter.class, e.getMessage()
                    + " : Unable to build host in query : ", e);
              }
View Full Code Here

        parent.addChild(liveWebAsset);
      }

      // gets identifier for this webasset and changes the uri and
      // persists it
      Host newHost = hostAPI.findParentHost(parent, user, false);
      identifier.setHostId(newHost.getIdentifier());
      identifier.setURI(workingWebAsset.getURI(parent));
      APILocator.getIdentifierAPI().save(identifier);

      SessionMessages.add(httpReq, "message", "message." + webAsset.getType() + ".move");
    }
View Full Code Here

      hostId = (String) session.getAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID);
    }

    if (hostId != null){

      Host host = null;
      try{
        host = hostAPI.find(hostId, user, false);
      }
      catch(Exception e){
        Logger.error(this.getClass(), "Can't find host for assets.  Looking for host " + hostId + ", error:  " + e);
View Full Code Here

      HttpServletRequest request, HttpServletResponse response)
  throws Exception {
    ActionErrors errors = new ActionErrors();
    //Email parameters
    HttpSession session = request.getSession();
    Host currentHost = hostWebAPI.getCurrentHost(request);
    User currentUser = (User) session.getAttribute(WebKeys.CMS_USER);
   
    String method = request.getMethod();
    String errorURL = request.getParameter("errorURL");   
    errorURL = (!UtilMethods.isSet(errorURL) ? request.getHeader("referer") : errorURL);
View Full Code Here

  //pagePath == $VTLSERVLET_URI where the user is at that moment
    //links Folders as default
  public String createMenu(String path, String pagePath, String divName, int numberOfLevels) throws JspException
  {
    try {
      Host host = hostWebAPI.getCurrentHost(request);
      return createMenu(path, pagePath, host.getIdentifier(),divName,"",true,"","",numberOfLevels);
    } catch (PortalException e) {
      Logger.error(StaticMenuBuilder.class, e.getMessage(), e);
      throw new DotRuntimeException(e.getMessage(), e);
    } catch (SystemException e) {
      Logger.error(StaticMenuBuilder.class, e.getMessage(), e);
View Full Code Here

  //pass linkFolders folders
  public String createMenu(String path, String pagePath, String divName, boolean linkFolders, int numberOfLevels) throws JspException
  {
    try {
      Host host = hostWebAPI.getCurrentHost(request);
      return createMenu(path, pagePath, host.getIdentifier(),divName,"",linkFolders,"","",numberOfLevels);
    } catch (DotDataException e) {
      Logger.error(StaticMenuBuilder.class, e.getMessage(), e);
      throw new DotRuntimeException(e.getMessage(), e);
    } catch (DotSecurityException e) {
      Logger.error(StaticMenuBuilder.class, e.getMessage(), e);
View Full Code Here

       if (path.equals("/")) {
      fileName = hostId + "_static.vtl";
      menuId = String.valueOf(hostId);
      file  = new java.io.File(StaticMenuBuilder.MENU_VTL_PATH + java.io.File.separator + fileName);
      if (!file.exists()) {
        Host host = APILocator.getHostAPI().find(hostId, APILocator.getUserAPI().getSystemUser(),false);
        itemsList = fapi.findSubFolders(host, true);
        folderPath = path;
        fileExists = false;
      }
       }
View Full Code Here

        this.hostWebAPI = WebAPILocator.getHostWebAPI();
    }

    private StringBuffer getMenuItems(StringBuffer stringbuf, Folder folderChildChild, boolean linkFolders, int numberOfLevels, int currentLevel, String imagePrefix, String imageSuffix) throws DotStateException, DotDataException, DotSecurityException {
     
        Host host;
    try {
      host = hostWebAPI.getCurrentHost(request);
    } catch (PortalException e) {
      Logger.error(StaticMenuBuilder.class, e.getMessage(), e);
      throw new DotRuntimeException(e.getMessage(), e);
View Full Code Here

TOP

Related Classes of com.dotmarketing.beans.Host

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.