Examples of HostWebAPI


Examples of com.dotmarketing.business.web.HostWebAPI

   

   
      try{
        HostWebAPI hostWebAPI  = WebAPILocator.getHostWebAPI();
        UserWebAPI userWebAPI = WebAPILocator.getUserWebAPI();
        User systemUser = userWebAPI.getSystemUser();
        boolean respectFrontendRoles = !userWebAPI.isLoggedToBackend(req);
        String serverName = req.getServerName();
        Host host = null;
        if (UtilMethods.isSet(serverName)) {
        host = hostWebAPI.findByName(serverName, systemUser, respectFrontendRoles);
        if(host == null)
          host = hostWebAPI.findByAlias(serverName, systemUser, respectFrontendRoles);
        //If no host matches then we return the default host
        if(host == null)
          host = hostWebAPI.findDefaultHost(systemUser, respectFrontendRoles);
        } else {
          host = hostWebAPI.findDefaultHost(systemUser, respectFrontendRoles);
        }
        req.getSession().setAttribute(com.dotmarketing.util.WebKeys.CURRENT_HOST, host);
     
        //List<Layout> layouts = APILocator.getLayoutAPI().loadLayoutsForUser(loginAsUser);
        PortletURLImpl portletURLImp = new PortletURLImpl(req, layouts.get(0).getPortletIds().get(0), layouts.get(0).getId(), false);
View Full Code Here

Examples of com.dotmarketing.business.web.HostWebAPI

          " (" + PortalUtil.getUser(req).getUserId() + "), the user is not logged in as a different user. " +
              "Remote IP: " + req.getRemoteAddr());

    }
   
    HostWebAPI hostWebAPI  = WebAPILocator.getHostWebAPI();
    UserWebAPI userWebAPI = WebAPILocator.getUserWebAPI();
    User systemUser = userWebAPI.getSystemUser();
    boolean respectFrontendRoles = !userWebAPI.isLoggedToBackend(req);
    String serverName = req.getServerName();
    Host host = null;
    if (UtilMethods.isSet(serverName)) {
    host = hostWebAPI.findByName(serverName, systemUser, respectFrontendRoles);
    if(host == null)
      host = hostWebAPI.findByAlias(serverName, systemUser, respectFrontendRoles);
    //If no host matches then we return the default host
    if(host == null)
      host = hostWebAPI.findDefaultHost(systemUser, respectFrontendRoles);
    } else {
      host = hostWebAPI.findDefaultHost(systemUser, respectFrontendRoles);
    }
   
    req.getSession().setAttribute(com.dotmarketing.util.WebKeys.CURRENT_HOST, host);
    return mapping.findForward(Constants.COMMON_REFERER);
View Full Code Here

Examples of com.dotmarketing.business.web.HostWebAPI

        Logger.debug(this, "Link not Found");
        response.sendError(404, "Link not Found");
        return;
      }

      HostWebAPI hostWebAPI = new HostWebAPIImpl();
      Host host = hostWebAPI.getCurrentHost(request);
      String hostId = host.getIdentifier();
      List<Contentlet> itemsList = new ArrayList<Contentlet>();

     
      Folder folder = folderAPI.findFolderByPath(Config.getStringProperty("org.dotcms.XMLSitemap.XML_SITEMAPS_FOLDER","/XMLSitemaps/"), hostId, userAPI.getSystemUser(), true);
View Full Code Here

Examples of com.dotmarketing.business.web.HostWebAPI

    }
    else{
      request.getSession().removeAttribute("LOGIN_TO_EDIT_MODE");
     
    }
    HostWebAPI hostWebAPI = WebAPILocator.getHostWebAPI();
    Host host;
    try {
      host = hostWebAPI.getCurrentHost(request);
      request.getSession().setAttribute(com.dotmarketing.util.WebKeys.CMS_SELECTED_HOST_ID, host.getIdentifier());
    } catch (PortalException e) {
      Logger.error(LoginEditModeServlet.class,e.getMessage(),e);
    } catch (SystemException e) {
      Logger.error(LoginEditModeServlet.class,e.getMessage(),e);
View Full Code Here

Examples of com.dotmarketing.business.web.HostWebAPI

        String uri = request.getRequestURI();
        if(request.getAttribute(WebKeys.CLICKSTREAM_URI_OVERRIDE) != null){
            uri = (String) request.getAttribute(WebKeys.CLICKSTREAM_URI_OVERRIDE);
        }
       
    HostWebAPI hostWebAPI = WebAPILocator.getHostWebAPI();
        Host host= null;
       
    try {
      host = hostWebAPI.getCurrentHost(request);
    } catch (PortalException e) {
        Logger.error(ClickstreamRequestFactory.class, "Unable to retrieve current request host for URI " + uri);
    } catch (SystemException e) {
        Logger.error(ClickstreamRequestFactory.class, "Unable to retrieve current request host for URI  " + uri);
    } catch (DotDataException e) {
View Full Code Here

Examples of com.dotmarketing.business.web.HostWebAPI

   * @param user user to activate
   * @param request
   */
  public static void sendActivationAccountEmail(User user, HttpServletRequest request) {
    try {
      HostWebAPI hostWebAPI = WebAPILocator.getHostWebAPI();
 
      Host host = hostWebAPI.getCurrentHost(request);
        Company company = PublicCompanyFactory.getDefaultCompany();
        Date date = UtilMethods.addDays(new Date(), 7);
        String linkparam = user.getUserId() + "##" + UtilMethods.dateToJDBC(date);
        Logger.debug(AccountActivationAction.class, "linkparam="+linkparam);
        String linkparamEncrypted = PublicEncryptionFactory.encryptString(linkparam);
View Full Code Here

Examples of com.dotmarketing.business.web.HostWebAPI

        }

        /*
         * Getting host object form the session
         */
        HostWebAPI hostWebAPI = WebAPILocator.getHostWebAPI();
        Host host;
    try {
      host = hostWebAPI.getCurrentHost(request);
    } catch (PortalException e) {
        Logger.error(this, "Unable to retrieve current request host for URI " + uri);
        throw new ServletException(e.getMessage(), e);
    } catch (SystemException e) {
        Logger.error(this, "Unable to retrieve current request host for URI  " + uri);
        throw new ServletException(e.getMessage(), e);
    } catch (DotDataException e) {
        Logger.error(this, "Unable to retrieve current request host for URI  " + uri);
        throw new ServletException(e.getMessage(), e);
    } catch (DotSecurityException e) {
        Logger.error(this, "Unable to retrieve current request host for URI  " + uri);
        throw new ServletException(e.getMessage(), e);
    }

        /*
         * If someone is trying to go right to an asset without going through
         * the cms, give them a 404
         */

        if (UtilMethods.isSet(ASSET_PATH) && uri.startsWith(ASSET_PATH)) {
            response.sendError(403, "Forbidden");
            return;
        }

        String pointer = null;
       
        boolean isVanityURL = UtilMethods.isSet(VirtualLinksCache.getPathFromCache(host.getHostname() + ":" + uri));
        if (!isVanityURL)
          isVanityURL = UtilMethods.isSet(VirtualLinksCache.getPathFromCache(uri));

        if(!uri.equals(pointer) && !uri.endsWith("/")
            && ! RegEX.contains(uri, folderPathRegEx)
            && uri.indexOf("/dotCMS/") == -1
            && !isVanityURL ) {
          Enumeration enm = req.getParameterNames();
          StringBuffer params = new StringBuffer("");
            for (; enm.hasMoreElements(); ) {
              String name = (String)enm.nextElement();
              params.append(name + "=" + req.getParameter(name));
              if(enm.hasMoreElements())
                params.append(StringPool.AMPERSAND);
            }
      response.sendRedirect(uri + "/" + (params.length() > 0 ? "?" + params : ""));
      return;
    }

        //Verify if the request is for a specific language
        Long languageId;
        if ( !UtilMethods.isSet( req.getParameter( "language_id" ) ) ) {
            languageId = APILocator.getLanguageAPI().getDefaultLanguage().getId();
        } else {
            languageId = Long.parseLong( req.getParameter( "language_id" ) );
        }

        /* if edit mode */
        if (PREVIEW_MODE || EDIT_MODE) {
      try {
        pointer = WorkingCache.getPathFromCache(uri, host);

        if(!UtilMethods.isSet(pointer)){//DOTCMS-7062
          pointer = LiveCache.getPathFromCache(uri, host);
        }

            if (!UtilMethods.isSet(pointer)
                && !uri.equals("/")
                && (uri.endsWith(dotExtension)
                    || InodeUtils.isSet(APILocator
                        .getFolderAPI().findFolderByPath(uri, host,APILocator.getUserAPI().getSystemUser(),false)
                        .getInode()))) {
               
              String url = uri;
                if (!uri.endsWith(dotExtension)) {
                    url += "index" + dotExtension;
                }
                request.getRequestDispatcher("/html/portlet/ext/htmlpages/page_not_found_404.jsp?url=" + url + "&hostId=" + host.getIdentifier()).forward(
                        req, res);
                return;
            }
            LogFactory.getLog(this.getClass()).debug("CMS preview pointer = " + uri + ":" + pointer);
      } catch (Exception e) {
        Logger.debug(this.getClass(), "Can't find pointer " + uri);
      }
            /* if live mode */
        } else {

      try {
                pointer = LiveCache.getPathFromCache( uri, host, languageId );
            } catch (Exception e) {
        Logger.debug(this.getClass(), "Can't find pointer " + uri);
        try {
          if(WebAPILocator.getUserWebAPI().isLoggedToBackend(request)){
            response.setHeader( "Pragma", "no-cache" );
            response.setHeader( "Cache-Control", "no-cache" );
            response.setDateHeader( "Expires", 0 );
            response.sendError(404);
            return;
          }
        } catch (Exception e1) {
          Logger.debug(this.getClass(), "Can't find pointer " + uri);
        }
      }
            // If the cache hits the db the connection needs to be manually
            // closed
            try {
        HibernateUtil.closeSession();
      } catch (DotHibernateException e) {
        Logger.error(CMSFilter.class, e.getMessage(), e);
      }
            LogFactory.getLog(this.getClass()).debug("CMS live pointer = " + uri + ":" + pointer);

        }

        /*
         * Checking if host is active
         */
        boolean hostlive;
        try {
            hostlive = APILocator.getVersionableAPI().hasLiveVersion(host);
        } catch (Exception e1) {
            throw new ServletException(e1);
        }
        if(!ADMIN_MODE && !hostlive) {
          //Checking if it has a maintenance virtual link
          pointer = (String) VirtualLinksCache.getPathFromCache(host.getHostname() + ":/cmsMaintenancePage");
          if(pointer == null) {
            try {
          response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, LanguageUtil.get(company.getCompanyId(), company.getLocale(), "server-unavailable-error-message"));
        } catch (LanguageException e) {
          Logger.error(CMSFilter.class, e.getMessage(), e);
          response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
        }
            return;
          }

        }

        // if absolute link somewhere else
        if (UtilMethods.isSet(pointer) && (pointer.startsWith(httpProtocol) || pointer.startsWith(httpsProtocol))) {
            response.sendRedirect(pointer);
            return;
        }

        // virtual links only after other links
        if (!UtilMethods.isSet(pointer)) {
            if (uri.endsWith("/"))
                uri = uri.substring(0, uri.length() - 1);
            pointer = VirtualLinksCache.getPathFromCache(host.getHostname() + ":" + uri);

            if (!UtilMethods.isSet(pointer)) {
                pointer = VirtualLinksCache.getPathFromCache(uri);
            }

            if (UtilMethods.isSet(pointer)) { // is it a virtual link?
                LogFactory.getLog(this.getClass()).debug("CMS found virtual link pointer = " + uri + ":" + pointer);
                boolean external = false;
                String auxPointer = pointer;
                if(auxPointer.indexOf("http://") != -1 || auxPointer.indexOf("https://") != -1)
                {
                  try {
                    User systemUser = APILocator.getUserAPI().getSystemUser();

                    auxPointer = auxPointer.replace("https://","");
                    auxPointer = auxPointer.replace("http://","");
                    int startIndex = 0;
                    int endIndex = auxPointer.indexOf("/");
                    if(startIndex < endIndex)
                    {
                      String localHostName = auxPointer.substring(startIndex,endIndex);
                      Host localHost = hostWebAPI.findByName(localHostName, systemUser, false);
                      if(localHost ==null || !InodeUtils.isSet(localHost.getInode())){
                        external=true;
                      }
                    }
                    else
View Full Code Here

Examples of com.dotmarketing.business.web.HostWebAPI

   * @return  ActionForward.
   * @exception  Exception.
   */
  public ActionForward unspecified(ActionMapping mapping, ActionForm lf, HttpServletRequest request, HttpServletResponse response) throws Exception
  {
    HostWebAPI hostWebAPI = WebAPILocator.getHostWebAPI();
    try
    {
      String inode = request.getParameter("id");
      String recurrenceStartDate = request.getParameter("recurrenceStartDate");
      String recurrenceEndDate = request.getParameter("recurrenceEndDate");
      Date startDate = null;
      Date endDate = null;
     
      if(UtilMethods.isSet(recurrenceStartDate)){
        startDate = dateFormat.parse(recurrenceStartDate);
      }
      if(!UtilMethods.isSet(inode)){
        return null;
      }
     
     
     
      if(UtilMethods.isSet(recurrenceEndDate)){
     
        endDate = dateFormat.parse(recurrenceEndDate);
      }
      User user = PortalUtil.getUser(request);
      boolean respectCMSAnon = false;
      if(user == null)
      {
        //Assuming is a front-end access
        respectCMSAnon = true;
        user = (User)request.getSession().getAttribute(WebKeys.CMS_USER);
      }
      Event event = eventAPI.find(inode, true, user, respectCMSAnon);
      Host host = hostWebAPI.getCurrentHost(request);
      String iCalEvent = eventAPI.createVCalendarInfo(event, startDate, endDate, host);
           
      //response.setContentType("application/octet-stream");
      response.setContentType("text/calendar");     
      response.setHeader("Content-Disposition", "attachment; filename=\"" + event.getTitle() + ".ics\"");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.