Package com.dotmarketing.cmis.proxy

Examples of com.dotmarketing.cmis.proxy.DotRequestProxy


     * TODO: I don't think it will work - jorge.urdaneta
     */

    InvocationHandler dotInvocationHandler = new DotInvocationHandler(new HashMap());

    DotRequestProxy requestProxy = (DotRequestProxy) Proxy
        .newProxyInstance(DotRequestProxy.class.getClassLoader(),
            new Class[] { DotRequestProxy.class },
            dotInvocationHandler);

    DotResponseProxy responseProxy = (DotResponseProxy) Proxy
        .newProxyInstance(DotResponseProxy.class.getClassLoader(),
            new Class[] { DotResponseProxy.class },
            dotInvocationHandler);

    StringWriter out = new StringWriter();
    Context context = null;
   

    uri = UtilMethods.cleanURI(uri);

    // Map with all identifier inodes for a given uri.
    String idInode = APILocator.getIdentifierAPI().find(host, uri)
        .getInode();

    // Checking the path is really live using the livecache
    String cachedUri = (liveMode) ? LiveCache.getPathFromCache(uri, host) : WorkingCache.getPathFromCache(uri, host);

    // if we still have nothing.
    if (!InodeUtils.isSet(idInode) || cachedUri == null) {
      throw new ResourceNotFoundException(String.format(
          "Resource %s not found in Live mode!", uri));
    }

    responseProxy.setContentType( "text/html" );
        requestProxy.setAttribute( "User-Agent", userAgent );
        requestProxy.setAttribute("idInode", String.valueOf(idInode));

    /* Set long lived cookie regardless of who this is */
    String _dotCMSID = UtilMethods.getCookieValue(
        requestProxy.getCookies(),
        com.dotmarketing.util.WebKeys.LONG_LIVED_DOTCMS_ID_COOKIE);


    if (!UtilMethods.isSet(_dotCMSID)) {
      /* create unique generator engine */
      Cookie idCookie = CookieUtil.createCookie();
      responseProxy.addCookie(idCookie);
    }
   
    requestProxy.put("host", host);
    requestProxy.put("host_id", host.getIdentifier());
    requestProxy.put("uri", uri);
    requestProxy.put("user", user);
    if(!liveMode){
      requestProxy.setAttribute(WebKeys.PREVIEW_MODE_SESSION, "true");
    }
    boolean signedIn = false;

    if (user != null) {
      signedIn = true;
    }
    Identifier ident = APILocator.getIdentifierAPI().find(host, uri);


    Logger.debug(HTMLPageAPIImpl.class, "Page Permissions for URI=" + uri);

    HTMLPage pageProxy = new HTMLPage();
    pageProxy.setIdentifier(ident.getInode());

    // Check if the page is visible by a CMS Anonymous role
    try {
      if (!permissionAPI.doesUserHavePermission(pageProxy,
          PermissionAPI.PERMISSION_READ, user, true)) {
        // this page is protected. not anonymous access

        /*******************************************************************
         * If we need to redirect someone somewhere to login before
         * seeing a page, we need to edit the /portal/401.jsp page to
         * sendRedirect the user to the proper login page. We are not
         * using the REDIRECT_TO_LOGIN variable in the config any
         * longer.
         ******************************************************************/
        if (!signedIn) {
          // No need for the below LAST_PATH attribute on the front
          // end http://jira.dotmarketing.net/browse/DOTCMS-2675
          // request.getSession().setAttribute(WebKeys.LAST_PATH,
          // new ObjectValuePair(uri, request.getParameterMap()));
          requestProxy.getSession().setAttribute(
              com.dotmarketing.util.WebKeys.REDIRECT_AFTER_LOGIN,
              uri);

          Logger.debug(HTMLPageAPIImpl.class,
              "VELOCITY CHECKING PERMISSION: Page doesn't have anonymous access"
                  + uri);

          Logger.debug(HTMLPageAPIImpl.class, "401 URI = " + uri);

          Logger.debug(HTMLPageAPIImpl.class, "Unauthorized URI = "
              + uri);
          responseProxy.sendError(401,
              "The requested page/file is unauthorized");
          return "An SYSTEM ERROR OCCURED !";

        } else if (!permissionAPI.getReadRoles(ident).contains(
            APILocator.getRoleAPI().loadLoggedinSiteRole())) {
          // user is logged in need to check user permissions
          Logger.debug(HTMLPageAPIImpl.class,
              "VELOCITY CHECKING PERMISSION: User signed in");

          // check user permissions on this asset
          if (!permissionAPI.doesUserHavePermission(ident,
              PermissionAPI.PERMISSION_READ, user, true)) {
            // the user doesn't have permissions to see this page
            // go to unauthorized page
            Logger
                .warn(HTMLPageAPIImpl.class,
                    "VELOCITY CHECKING PERMISSION: Page doesn't have any access for this user");
            responseProxy.sendError(403,
                "The requested page/file is forbidden");
            return "PAGE NOT FOUND!";
          }
        }
      }

      if(UtilMethods.isSet(contentId)){
        requestProxy.setAttribute(WebKeys.WIKI_CONTENTLET, contentId);
      }
     
      if(langId>0) {
          requestProxy.setAttribute(WebKeys.HTMLPAGE_LANGUAGE, Long.toString(langId));
      }
      LanguageWebAPI langWebAPI = WebAPILocator.getLanguageWebAPI();
            langWebAPI.checkSessionLocale(requestProxy);
     
      context = VelocityUtil.getWebContext(requestProxy, responseProxy);
     
      if(langId>0) {
                context.put("language", Long.toString(langId));
      }
     
      if(! liveMode ){
        context.put("PREVIEW_MODE", new Boolean(true));
      }else{
        context.put("PREVIEW_MODE", new Boolean(false));
      }

      context.put("host", host);
      VelocityEngine ve = VelocityUtil.getEngine();

      Logger.debug(HTMLPageAPIImpl.class, "Got the template!!!!"
          + idInode);

      requestProxy.setAttribute("velocityContext", context);

      String VELOCITY_HTMLPAGE_EXTENSION = Config
          .getStringProperty("VELOCITY_HTMLPAGE_EXTENSION");
      String vTempalate = (liveMode) ?
          "/live/" + idInode + "." + VELOCITY_HTMLPAGE_EXTENSION :
            "/working/" + idInode + "." + VELOCITY_HTMLPAGE_EXTENSION ;

      ve.getTemplate(vTempalate)
          .merge(context, out);

    } catch (Exception e1) {
      Logger.error(this, e1.getMessage(), e1);
    } finally {
      context = null;
      VelocityServlet.velocityCtx.remove();
    }


    if (Config.getBooleanProperty("ENABLE_CLICKSTREAM_TRACKING", false)) {
      Logger.debug(HTMLPageAPIImpl.class, "Into the ClickstreamFilter");
      // Ensure that clickstream is recorded only once per request.
      if (requestProxy.getAttribute(ClickstreamFilter.FILTER_APPLIED) == null) {
        requestProxy.setAttribute(ClickstreamFilter.FILTER_APPLIED,
            Boolean.TRUE);

        if (user != null) {
          UserProxy userProxy = null;
          try {
View Full Code Here


          + processor.getTask().getId();     

      InvocationHandler dotInvocationHandler = new DotInvocationHandler(new HashMap());
     

      DotRequestProxy requestProxy = (DotRequestProxy) Proxy.newProxyInstance(DotRequestProxy.class.getClassLoader(),
          new Class[] { DotRequestProxy.class }, dotInvocationHandler);
      requestProxy.put("host", host);
      requestProxy.put("host_id", host.getIdentifier());
      requestProxy.put("user", processor.getUser());
      DotResponseProxy responseProxy = (DotResponseProxy) Proxy.newProxyInstance(DotResponseProxy.class.getClassLoader(),
          new Class[] { DotResponseProxy.class }, dotInvocationHandler);

      org.apache.velocity.context.Context ctx = VelocityUtil.getWebContext(requestProxy, responseProxy);
      ctx.put("host", host);
View Full Code Here

            String link = "http://" + host.getHostname() + Config.getStringProperty("WORKFLOWS_URL") + "&_EXT_21_inode="
                    + String.valueOf(processor.getTask().getId());

            InvocationHandler dotInvocationHandler = new DotInvocationHandler(new HashMap());

            DotRequestProxy requestProxy = (DotRequestProxy) Proxy.newProxyInstance(DotRequestProxy.class.getClassLoader(),
                    new Class[] { DotRequestProxy.class }, dotInvocationHandler);
            requestProxy.put("host", host);
            requestProxy.put("host_id", host.getIdentifier());
            requestProxy.put("user", processor.getUser());
            DotResponseProxy responseProxy = (DotResponseProxy) Proxy.newProxyInstance(DotResponseProxy.class.getClassLoader(),
                    new Class[] { DotResponseProxy.class }, dotInvocationHandler);

            org.apache.velocity.context.Context ctx = VelocityUtil.getWebContext(requestProxy, responseProxy);
            ctx.put("host", host);
View Full Code Here

        contentTester.init(null, null);

        InvocationHandler dotInvocationHandler = new DotInvocationHandler(new HashMap());

        DotRequestProxy requestProxy = (DotRequestProxy) Proxy
                .newProxyInstance(DotRequestProxy.class.getClassLoader(),
                        new Class[] { DotRequestProxy.class },
                        dotInvocationHandler);

        DotResponseProxy responseProxy = (DotResponseProxy) Proxy
                .newProxyInstance(DotResponseProxy.class.getClassLoader(),
                        new Class[] { DotResponseProxy.class },
                        dotInvocationHandler);

        requestProxy.setAttribute(WebKeys.HTMLPAGE_LANGUAGE, "1");
        requestProxy.setAttribute(com.liferay.portal.util.WebKeys.USER,APILocator.getUserAPI().getSystemUser());

        Template teng1 = engine.getTemplate("/live/"+w.getIdentifier()+"_1."+contentEXT);
        Template tesp1 = engine.getTemplate("/live/"+w.getIdentifier()+"_2."+contentEXT);

        Context ctx = VelocityUtil.getWebContext(requestProxy, responseProxy);
View Full Code Here

TOP

Related Classes of com.dotmarketing.cmis.proxy.DotRequestProxy

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.