Package org.oasis.wsrp.v1

Examples of org.oasis.wsrp.v1.V1DestroyPortletsResponse


         requestPrecursor.markupParams, interactionParams);
   }

   protected PortletInvocationResponse processResponse(Object response, PortletInvocation invocation, RequestPrecursor requestPrecursor) throws PortletInvokerException
   {
      BlockingInteractionResponse blockingInteractionResponse = (BlockingInteractionResponse)response;
      log.debug("Starting processing response");

      String redirectURL = blockingInteractionResponse.getRedirectURL();
      UpdateResponse updateResponse = blockingInteractionResponse.getUpdateResponse();
      if (redirectURL != null && updateResponse != null)
      {
         return new ErrorResponse(new IllegalArgumentException("Response cannot both redirect and update state."));
      }
View Full Code Here


         interaction.getPortletContext(), interaction.getRuntimeContext(), interaction.getUserContext(),
         interaction.getMarkupParams(), interaction.getInteractionParams(), updateResponseHolder, redirectURL,
         new Holder<List<Extension>>());

      // construct response
      BlockingInteractionResponse response = new BlockingInteractionResponse();
      response.setRedirectURL(redirectURL.value);
      response.setUpdateResponse(updateResponseHolder.value);
      return response;
   }
View Full Code Here

      return URLTools.replaceURLsBy(markup, rewriter);
   }

   private org.gatein.pc.api.cache.CacheControl createCacheControl(MarkupContext markupContext)
   {
      CacheControl cacheControl = markupContext.getCacheControl();
      org.gatein.pc.api.cache.CacheControl result = DEFAULT_CACHE_CONTROL;

      int expires;
      if (cacheControl != null)
      {
         expires = cacheControl.getExpires();
         String userScope = cacheControl.getUserScope();

         // check that we support the user scope...
         if (consumer.supportsUserScope(userScope))
         {
            log.debug("RenderHandler.processRenderRequest: trying to cache markup " + userScope + " for " + expires + " seconds.");
            CacheScope scope;
            if (WSRPConstants.CACHE_FOR_ALL.equals(userScope))
            {
               scope = CacheScope.PUBLIC;
            }
            else if (WSRPConstants.CACHE_PER_USER.equals(userScope))
            {
               scope = CacheScope.PRIVATE;
            }
            else
            {
               throw new IllegalArgumentException("Unknown CacheControl user scope: " + userScope); // should not happen
            }

            result = new org.gatein.pc.api.cache.CacheControl(expires, scope, cacheControl.getValidateTag());
         }
      }

      return result;
   }
View Full Code Here

      return getRenderRequest(request).getRuntimeContext();
   }

   protected Object performRequest(Object request) throws Exception
   {
      GetMarkup renderRequest = getRenderRequest(request);
      log.debug("getMarkup on '" + renderRequest.getPortletContext().getPortletHandle() + "'");

      // invocation
      Holder<SessionContext> sessionContextHolder = new Holder<SessionContext>();
      Holder<MarkupContext> markupContextHolder = new Holder<MarkupContext>();
      consumer.getMarkupService().getMarkup(renderRequest.getRegistrationContext(), renderRequest.getPortletContext(),
         renderRequest.getRuntimeContext(), renderRequest.getUserContext(), renderRequest.getMarkupParams(),
         markupContextHolder, sessionContextHolder, new Holder<List<Extension>>());
      MarkupResponse markupResponse = new MarkupResponse();
      markupResponse.setMarkupContext(markupContextHolder.value);
      markupResponse.setSessionContext(sessionContextHolder.value);
      return markupResponse;
View Full Code Here

      InstanceContext instanceContext = invocation.getInstanceContext();
      ParameterValidation.throwIllegalArgExceptionIfNull(instanceContext, "instance context");
      AccessMode accessMode = instanceContext.getAccessMode();
      ParameterValidation.throwIllegalArgExceptionIfNull(accessMode, "access mode");
      log.debug("Portlet is requesting " + accessMode + " access mode");
      InteractionParams interactionParams =
         WSRPTypeFactory.createInteractionParams(WSRPUtils.getStateChangeFromAccessMode(accessMode));

      // interaction state
      StateString interactionState = actionInvocation.getInteractionState();
      if (interactionState != null)
      {
         String state = interactionState.getStringValue();
         if (!StateString.JBPNS_PREFIX.equals(state))  // fix-me: see JBPORTAL-900
         {
            interactionParams.setInteractionState(state);
         }
      }

      // check for multi-part
      RequestContextWrapper requestContext = new RequestContextWrapper(actionInvocation.getRequestContext());
      try
      {
         if (FileUpload.isMultipartContent(requestContext))
         {
            // content is multipart, we need to parse it (that includes form parameters)
            FileUpload upload = new FileUpload();
            FileItemIterator iter = upload.getItemIterator(requestContext);
            List<UploadContext> uploadContexts = new ArrayList<UploadContext>(7);
            List<NamedString> formParameters = new ArrayList<NamedString>(7);
            while (iter.hasNext())
            {
               FileItemStream item = iter.next();
               InputStream stream = item.openStream();
               if (!item.isFormField())
               {
                  String contentType = item.getContentType();
                  log.debug("File field " + item.getFieldName() + " with file name " + item.getName() + " and content type "
                     + contentType + " detected.");
                  BufferedInputStream bufIn = new BufferedInputStream(stream);

                  ByteArrayOutputStream baos = new ByteArrayOutputStream();
                  BufferedOutputStream bos = new BufferedOutputStream(baos);

                  int c = bufIn.read();
                  while (c != -1)
                  {
                     bos.write(c);
                     c = bufIn.read();
                  }

                  bos.flush();
                  baos.flush();
                  bufIn.close();
                  bos.close();

                  UploadContext uploadContext = WSRPTypeFactory.createUploadContext(contentType, baos.toByteArray());

                  List<NamedString> mimeAttributes = new ArrayList<NamedString>(2);

                  NamedString mimeAttribute = new NamedString();
                  mimeAttribute.setName(FileUpload.CONTENT_DISPOSITION);
                  mimeAttribute.setValue(FileUpload.FORM_DATA + ";"
                     + " name=\"" + item.getFieldName() + "\";"
                     + " filename=\"" + item.getName() + "\"");
                  mimeAttributes.add(mimeAttribute);

                  mimeAttribute = new NamedString();
                  mimeAttribute.setName(FileUpload.CONTENT_TYPE);
                  mimeAttribute.setValue(item.getContentType());
                  mimeAttributes.add(mimeAttribute);

                  uploadContext.getMimeAttributes().addAll(mimeAttributes);

                  uploadContexts.add(uploadContext);
               }
               else
               {
                  NamedString formParameter = new NamedString();
                  formParameter.setName(item.getFieldName());
                  formParameter.setValue(Streams.asString(stream));
                  formParameters.add(formParameter);
               }
            }
            interactionParams.getUploadContexts().addAll(uploadContexts);
            interactionParams.getFormParameters().addAll(formParameters);
         }
         else
         {
            // if the content is not multipart, then check for form parameters
            Map<String, String[]> params = actionInvocation.getForm();
            if (params != null && !params.isEmpty())
            {
               int capacity = params.size();
               List<NamedString> formParameters = new ArrayList<NamedString>(capacity);
               for (Map.Entry param : params.entrySet())
               {
                  String name = (String)param.getKey();
                  String[] values = (String[])param.getValue();
                  NamedString formParameter = new NamedString();
                  for (String value : values)
                  {
                     formParameter.setName(name);
                     formParameter.setValue(value);
                     formParameters.add(formParameter);
                  }
               }
               interactionParams.getFormParameters().addAll(formParameters);
            }
         }
      }
      catch (Exception e)
      {
View Full Code Here

         if (keywordsNb > 0)
         {
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < keywordsNb; i++)
            {
               LocalizedString keyword = keywords.get(i);
               sb.append(keyword.getValue());
               if (i != keywordsNb - 1)
               {
                  sb.append(","); // not the last one, so concatenate a comma to separate
               }
            }
View Full Code Here

      // process the response
      consumer.getSessionHandler().updateSessionIfNeeded(markupResponse.getSessionContext(), invocation,
         requestPrecursor.getPortletHandle());

      MarkupContext markupContext = markupResponse.getMarkupContext();
      String markup = markupContext.getMarkupString();
      byte[] binary = markupContext.getMarkupBinary();
      if (markup != null && binary != null)
      {
         return new ErrorResponse(new IllegalArgumentException("Markup response cannot contain both string and binary " +
            "markup. Per Section 6.1.10 of the WSRP specification, this is a Producer error."));
      }

      if (markup == null && binary == null)
      {
         if (markupContext.isUseCachedMarkup())
         {
            //todo: deal with cache
         }
         else
         {
            return new ErrorResponse(new IllegalArgumentException("Markup response must contain at least string or binary" +
               " markup. Per Section 6.1.10 of the WSRP specification, this is a Producer error."));
         }
      }

      if (markup != null && markup.length() > 0)
      {
         markup = processMarkup(markup, invocation, Boolean.TRUE.equals(markupContext.isRequiresUrlRewriting()));
      }
      else
      {
         // todo: need to deal with binary
      }

      String mimeType = markupContext.getMimeType();
      if (mimeType == null || mimeType.length() == 0)
      {
         return new ErrorResponse(new IllegalArgumentException("No MIME type was provided for portlet content."));
      }

      // generate appropriate CacheControl
      org.gatein.pc.api.cache.CacheControl cacheControl = createCacheControl(markupContext);

      FragmentResponse result = new FragmentResponse(null, null, mimeType, null, markup,
         markupContext.getPreferredTitle(), cacheControl, invocation.getPortalContext().getModes());

      log.debug("Response processed");
      return result;
   }
View Full Code Here

      return WSRPTypeFactory.createMarkupRequest(portletContext, requestPrecursor.runtimeContext, requestPrecursor.markupParams);
   }

   protected PortletInvocationResponse processResponse(Object response, PortletInvocation invocation, RequestPrecursor requestPrecursor)
   {
      MarkupResponse markupResponse = (MarkupResponse)response;
      log.debug("Starting processing response");

      // process the response
      consumer.getSessionHandler().updateSessionIfNeeded(markupResponse.getSessionContext(), invocation,
         requestPrecursor.getPortletHandle());

      MarkupContext markupContext = markupResponse.getMarkupContext();
      String markup = markupContext.getMarkupString();
      byte[] binary = markupContext.getMarkupBinary();
      if (markup != null && binary != null)
      {
         return new ErrorResponse(new IllegalArgumentException("Markup response cannot contain both string and binary " +
View Full Code Here

      Holder<SessionContext> sessionContextHolder = new Holder<SessionContext>();
      Holder<MarkupContext> markupContextHolder = new Holder<MarkupContext>();
      consumer.getMarkupService().getMarkup(renderRequest.getRegistrationContext(), renderRequest.getPortletContext(),
         renderRequest.getRuntimeContext(), renderRequest.getUserContext(), renderRequest.getMarkupParams(),
         markupContextHolder, sessionContextHolder, new Holder<List<Extension>>());
      MarkupResponse markupResponse = new MarkupResponse();
      markupResponse.setMarkupContext(markupContextHolder.value);
      markupResponse.setSessionContext(sessionContextHolder.value);
      return markupResponse;
   }
View Full Code Here

         {
            requiresRegistration = Boolean.TRUE;
            log.debug("Producer '" + producerId + "' requires registration");

            // check if the configured registration properties match the producer expectations
            ModelDescription regPropDescs = serviceDescription.getRegistrationPropertyDescription();
            if (regPropDescs != null)
            {
               result.setStatus(RefreshResult.Status.SUCCESS);
               List<PropertyDescription> propertyDescriptions = regPropDescs.getPropertyDescriptions();
               if (propertyDescriptions != null && !propertyDescriptions.isEmpty())
               {
                  Map<String, RegistrationProperty> descriptionsMap = getRegistrationPropertyDescriptionsFromWSRP(propertyDescriptions);

                  // check that we don't have unexpected registration properties and if so, mark them as invalid or remove them
View Full Code Here

TOP

Related Classes of org.oasis.wsrp.v1.V1DestroyPortletsResponse

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.