Package org.gatein.pc.api.invocation

Examples of org.gatein.pc.api.invocation.ResourceInvocation


            actionInvocation.setForm(allParams);

            invocation = type.cast(actionInvocation);
        } else if (type.equals(ResourceInvocation.class)) {
            ResourceInvocation resourceInvocation = new ResourceInvocation(pic);
            resourceInvocation.setRequestContext(new AbstractRequestContext(servletRequest));

            String resourceId = servletRequest.getParameter(Constants.RESOURCE_ID_PARAMETER);
            if (!ParameterValidation.isNullOrEmpty(resourceId)) {
                resourceInvocation.setResourceId(resourceId);
            } else if (!ParameterValidation.isNullOrEmpty(prc.getRequestParameter(Constants.RESOURCE_ID_PARAMETER))) {
                resourceInvocation.setResourceId(prc.getRequestParameter(Constants.RESOURCE_ID_PARAMETER));
            }

            String cachability = servletRequest.getParameter(Constants.CACHELEVEL_PARAMETER);
            if (!ParameterValidation.isNullOrEmpty(cachability)) {
                // we need to convert the given value to upper case as it might come from WSRP in lower case
                resourceInvocation.setCacheLevel(CacheLevel.create(cachability.toUpperCase(Locale.ENGLISH)));
            }

            String resourceState = servletRequest.getParameter(ExoPortletInvocationContext.RESOURCE_STATE_PARAM_NAME);
            if (!ParameterValidation.isNullOrEmpty(resourceState)) {
                resourceInvocation.setResourceState(StateString.create(resourceState));
            }
            // remove the resource state from remaining params
            allParams.remove(ExoPortletInvocationContext.RESOURCE_STATE_PARAM_NAME);

            // deal with WSRP-specific parameters: add them to the invocation attributes if they exist and remove them from form
            // params
            String url = servletRequest.getParameter(WSRP_URL);
            if (!ParameterValidation.isNullOrEmpty(url)) {
                resourceInvocation.setAttribute(WSRP_URL, url);
            }
            allParams.remove(WSRP_URL);

            String preferOperation = servletRequest.getParameter(WSRP_PREFER_OPERATION);
            if (!ParameterValidation.isNullOrEmpty(preferOperation)) {
                resourceInvocation.setAttribute(WSRP_PREFER_OPERATION, preferOperation);
            }
            allParams.remove(WSRP_PREFER_OPERATION);

            String requiresRewrite = servletRequest.getParameter(WSRP_REQUIRES_REWRITE);
            if (!ParameterValidation.isNullOrEmpty(requiresRewrite)) {
                resourceInvocation.setAttribute(WSRP_REQUIRES_REWRITE, requiresRewrite);
            }
            allParams.remove(WSRP_REQUIRES_REWRITE);
            // End WSRP-specific parameters handling

            resourceInvocation.setForm(allParams);

            invocation = type.cast(resourceInvocation);
        } else if (type.equals(EventInvocation.class)) {
            invocation = type.cast(new EventInvocation(pic));
        } else if (type.equals(RenderInvocation.class)) {
View Full Code Here


            actionInvocation.setForm(allParams);

            invocation = type.cast(actionInvocation);
        } else if (type.equals(ResourceInvocation.class)) {
            ResourceInvocation resourceInvocation = new ResourceInvocation(pic);
            resourceInvocation.setRequestContext(new AbstractRequestContext(servletRequest));

            String resourceId = servletRequest.getParameter(Constants.RESOURCE_ID_PARAMETER);
            if (!ParameterValidation.isNullOrEmpty(resourceId)) {
                resourceInvocation.setResourceId(resourceId);
            } else if (!ParameterValidation.isNullOrEmpty(prc.getRequestParameter(Constants.RESOURCE_ID_PARAMETER))) {
                resourceInvocation.setResourceId(prc.getRequestParameter(Constants.RESOURCE_ID_PARAMETER));
            }

            String cachability = servletRequest.getParameter(Constants.CACHELEVEL_PARAMETER);
            if (!ParameterValidation.isNullOrEmpty(cachability)) {
                // we need to convert the given value to upper case as it might come from WSRP in lower case
                resourceInvocation.setCacheLevel(CacheLevel.create(cachability.toUpperCase(Locale.ENGLISH)));
            }

            String resourceState = servletRequest.getParameter(ExoPortletInvocationContext.RESOURCE_STATE_PARAM_NAME);
            if (!ParameterValidation.isNullOrEmpty(resourceState)) {
                resourceInvocation.setResourceState(StateString.create(resourceState));
            }
            // remove the resource state from remaining params
            allParams.remove(ExoPortletInvocationContext.RESOURCE_STATE_PARAM_NAME);

            // deal with WSRP-specific parameters: add them to the invocation attributes if they exist and remove them from form
            // params
            String url = servletRequest.getParameter(WSRP_URL);
            if (!ParameterValidation.isNullOrEmpty(url)) {
                resourceInvocation.setAttribute(WSRP_URL, url);
            }
            allParams.remove(WSRP_URL);

            String preferOperation = servletRequest.getParameter(WSRP_PREFER_OPERATION);
            if (!ParameterValidation.isNullOrEmpty(preferOperation)) {
                resourceInvocation.setAttribute(WSRP_PREFER_OPERATION, preferOperation);
            }
            allParams.remove(WSRP_PREFER_OPERATION);

            String requiresRewrite = servletRequest.getParameter(WSRP_REQUIRES_REWRITE);
            if (!ParameterValidation.isNullOrEmpty(requiresRewrite)) {
                resourceInvocation.setAttribute(WSRP_REQUIRES_REWRITE, requiresRewrite);
            }
            allParams.remove(WSRP_REQUIRES_REWRITE);
            // End WSRP-specific parameters handling

            resourceInvocation.setForm(allParams);

            invocation = type.cast(resourceInvocation);
        } else if (type.equals(EventInvocation.class)) {
            invocation = type.cast(new EventInvocation(pic));
        } else if (type.equals(RenderInvocation.class)) {
View Full Code Here

                if (navState != null) {
                    uiPortlet.setNavigationalState(ParametersStateString.create(navState));
                }

                //
                ResourceInvocation resourceInvocation = uiPortlet.create(ResourceInvocation.class, context);

                // set the resourceId to be used in case of a problem
                resourceId = resourceInvocation.getResourceId();

                //
                PortletInvocationResponse portletResponse = uiPortlet.invoke(resourceInvocation);

                //
View Full Code Here

      return request.getUserContext();
   }

   protected PortletInvocation internalInitInvocation(WSRPPortletInvocationContext context)
   {
      ResourceInvocation resourceInvocation = new ResourceInvocation(context);

      ResourceParams resourceParams = this.request.getResourceParams();

      // only set the resource id if it's different from the place holder we use if the portlet doesn't set one
      String id = this.request.getResourceParams().getResourceID();
      if (!WSRPResourceURL.DEFAULT_RESOURCE_ID.equals(id))
      {
         resourceInvocation.setResourceId(id);
      }

      WSRPRequestContext requestContext = WSRPRequestContext.createRequestContext(markupRequest, resourceParams);
      resourceInvocation.setRequestContext(requestContext);
      resourceInvocation.setForm(requestContext.getForm());

      //TODO: property set validation token for caching (ie ETAG)
      String validationToken = null;
      resourceInvocation.setValidationToken(validationToken);

      resourceInvocation.setResourceState(createNavigationalState(resourceParams.getResourceState()));

      String resourceCacheability = resourceParams.getResourceCacheability();
      if (resourceCacheability != null)
      {
         CacheLevel cacheLevel = WSRPUtils.getCacheLevelFromResourceCacheability(resourceParams.getResourceCacheability());
         resourceInvocation.setCacheLevel(cacheLevel);
      }
      else
      {
         // according to JSR 286, cache level must default to ResourceURL.PAGE
         resourceInvocation.setCacheLevel(CacheLevel.PAGE);
      }

      return resourceInvocation;
   }
View Full Code Here

      {
         handler = actionHandler;
      }
      else if (invocation instanceof ResourceInvocation)
      {
         ResourceInvocation resourceInvocation = (ResourceInvocation)invocation;
         String resourceInvocationId = resourceInvocation.getResourceId();
         String resourceId;
         String resourceURL;
         String preferOperationAsString;

         if (!ParameterValidation.isNullOrEmpty(resourceInvocationId))
         {
            Map<String, String> resourceMap = WSRPResourceURL.decodeResource(resourceInvocationId);
            resourceId = resourceMap.get(WSRP2RewritingConstants.RESOURCE_ID);
            resourceURL = resourceMap.get(WSRPRewritingConstants.RESOURCE_URL);
            preferOperationAsString = resourceMap.get(WSRP2RewritingConstants.RESOURCE_PREFER_OPERATION);

            // put the values in the invocation so that we don't need to redecode the resource id
            resourceInvocation.setAttribute(WSRPRewritingConstants.RESOURCE_URL, resourceURL);
            resourceInvocation.setAttribute(WSRP2RewritingConstants.RESOURCE_ID, resourceId);
            resourceInvocation.setAttribute(WSRP2RewritingConstants.RESOURCE_PREFER_OPERATION, preferOperationAsString);
         }
         else
         {
            // GateIn-specific: WSRP-specific URL parameters might also be put as attributes by UIPortlet when the invocation is created
            resourceId = null;
            resourceURL = (String)resourceInvocation.getAttribute(WSRPRewritingConstants.RESOURCE_URL);
            preferOperationAsString = (String)resourceInvocation.getAttribute(WSRP2RewritingConstants.RESOURCE_PREFER_OPERATION);
         }

         boolean preferOperation = (preferOperationAsString != null && Boolean.parseBoolean(preferOperationAsString));

         if (consumer.isUsingWSRP2() && (preferOperation || resourceURL == null || (resourceId != null && resourceId.length() > 0)))
View Full Code Here

         windowState = WindowState.NORMAL;
      }

      //
      PortletInvocationContext portletInvocationContext = context.createPortletInvocationContext(portletResourceRequest.getWindowId(), pageNavigationalState);
      ResourceInvocation resourceInvocation = new ResourceInvocation(portletInvocationContext);

      //
      resourceInvocation.setResourceId(portletResourceRequest.getResourceId());
      resourceInvocation.setCacheLevel(cacheability);
      resourceInvocation.setMode(mode);
      resourceInvocation.setWindowState(windowState);
      resourceInvocation.setNavigationalState(portletNS);
      resourceInvocation.setPublicNavigationalState(publicNS);
      resourceInvocation.setResourceState(portletResourceRequest.getResourceState());
      resourceInvocation.setForm(portletResourceRequest.getBodyParameters() != null ? ParameterMap.clone(portletResourceRequest.getBodyParameters()) : null);

      //
      try
      {
         return context.invoke(resourceInvocation);
View Full Code Here

                if (navState != null) {
                    uiPortlet.setNavigationalState(ParametersStateString.create(navState));
                }

                //
                ResourceInvocation resourceInvocation = uiPortlet.create(ResourceInvocation.class, context);

                // set the resourceId to be used in case of a problem
                resourceId = resourceInvocation.getResourceId();

                //
                PortletInvocationResponse portletResponse = uiPortlet.invoke(resourceInvocation);

                //
View Full Code Here

         {
            PortalRequestContext context = (PortalRequestContext)event.getRequestContext();
            HttpServletResponse response = context.getResponse();

            //
            ResourceInvocation resourceInvocation = uiPortlet.create(ResourceInvocation.class, context);

            //
            PortletInvocationResponse portletResponse = uiPortlet.invoke(resourceInvocation);

            // todo: handle the error response better than this.
View Full Code Here

         invocation = type.cast(actionInvocation);
      }
      else if (type.equals(ResourceInvocation.class))
      {
         ResourceInvocation resourceInvocation = new ResourceInvocation(pic);
         resourceInvocation.setRequestContext(new AbstractRequestContext(servletRequest));

         String resourceId = servletRequest.getParameter(Constants.RESOURCE_ID_PARAMETER);
         if (resourceId != null)
         {
            resourceInvocation.setResourceId(resourceId);
         }

         String cachability = servletRequest.getParameter(Constants.CACHELEVEL_PARAMETER);
         if (cachability != null)
         {
            resourceInvocation.setCacheLevel(CacheLevel.valueOf(cachability));
         }

         String resourceState = servletRequest.getParameter(ExoPortletInvocationContext.RESOURCE_STATE_PARAM_NAME);
         if (resourceState != null)
         {
            resourceInvocation.setResourceState(StateString.create(resourceState));
         }

         resourceInvocation.setForm(allParams);

         invocation = type.cast(resourceInvocation);
      }
      else if (type.equals(EventInvocation.class))
      {
View Full Code Here

            actionInvocation.setForm(allParams);

            invocation = type.cast(actionInvocation);
        } else if (type.equals(ResourceInvocation.class)) {
            ResourceInvocation resourceInvocation = new ResourceInvocation(pic);
            resourceInvocation.setRequestContext(new AbstractRequestContext(servletRequest));

            String resourceId = servletRequest.getParameter(Constants.RESOURCE_ID_PARAMETER);
            if (!ParameterValidation.isNullOrEmpty(resourceId)) {
                resourceInvocation.setResourceId(resourceId);
            } else if (!ParameterValidation.isNullOrEmpty(prc.getRequestParameter(Constants.RESOURCE_ID_PARAMETER))) {
                resourceInvocation.setResourceId(prc.getRequestParameter(Constants.RESOURCE_ID_PARAMETER));
            }

            String cachability = servletRequest.getParameter(Constants.CACHELEVEL_PARAMETER);
            if (!ParameterValidation.isNullOrEmpty(cachability)) {
                // we need to convert the given value to upper case as it might come from WSRP in lower case
                resourceInvocation.setCacheLevel(CacheLevel.create(cachability.toUpperCase(Locale.ENGLISH)));
            }

            String resourceState = servletRequest.getParameter(ExoPortletInvocationContext.RESOURCE_STATE_PARAM_NAME);
            if (!ParameterValidation.isNullOrEmpty(resourceState)) {
                resourceInvocation.setResourceState(StateString.create(resourceState));
            }
            // remove the resource state from remaining params
            allParams.remove(ExoPortletInvocationContext.RESOURCE_STATE_PARAM_NAME);

            // deal with WSRP-specific parameters: add them to the invocation attributes if they exist and remove them from form
            // params
            String url = servletRequest.getParameter(WSRP_URL);
            if (!ParameterValidation.isNullOrEmpty(url)) {
                resourceInvocation.setAttribute(WSRP_URL, url);
            }
            allParams.remove(WSRP_URL);

            String preferOperation = servletRequest.getParameter(WSRP_PREFER_OPERATION);
            if (!ParameterValidation.isNullOrEmpty(preferOperation)) {
                resourceInvocation.setAttribute(WSRP_PREFER_OPERATION, preferOperation);
            }
            allParams.remove(WSRP_PREFER_OPERATION);

            String requiresRewrite = servletRequest.getParameter(WSRP_REQUIRES_REWRITE);
            if (!ParameterValidation.isNullOrEmpty(requiresRewrite)) {
                resourceInvocation.setAttribute(WSRP_REQUIRES_REWRITE, requiresRewrite);
            }
            allParams.remove(WSRP_REQUIRES_REWRITE);
            // End WSRP-specific parameters handling

            resourceInvocation.setForm(allParams);

            invocation = type.cast(resourceInvocation);
        } else if (type.equals(EventInvocation.class)) {
            invocation = type.cast(new EventInvocation(pic));
        } else if (type.equals(RenderInvocation.class)) {
View Full Code Here

TOP

Related Classes of org.gatein.pc.api.invocation.ResourceInvocation

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.