Package org.oasis.wsrp.v1

Examples of org.oasis.wsrp.v1.InteractionParams


      ParameterValidation.throwIllegalArgExceptionIfNull(accessMode, "access mode");
      if (debug)
      {
         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();
                  if (debug)
                  {
                     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);

                  String value = FileUpload.FORM_DATA + ";"
                     + " name=\"" + item.getFieldName() + "\";"
                     + " filename=\"" + item.getName() + "\"";
                  NamedString mimeAttribute = WSRPTypeFactory.createNamedString(FileUpload.CONTENT_DISPOSITION, value);
                  mimeAttributes.add(mimeAttribute);

                  mimeAttribute = WSRPTypeFactory.createNamedString(FileUpload.CONTENT_TYPE, item.getContentType());
                  mimeAttributes.add(mimeAttribute);

                  uploadContext.getMimeAttributes().addAll(mimeAttributes);

                  uploadContexts.add(uploadContext);
               }
               else
               {
                  NamedString formParameter = WSRPTypeFactory.createNamedString(item.getFieldName(), 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;
                  for (String value : values)
                  {
                     formParameter = WSRPTypeFactory.createNamedString(name, value);
                     formParameters.add(formParameter);
                  }
               }
               interactionParams.getFormParameters().addAll(formParameters);
            }
         }
      }
      catch (Exception e)
      {
View Full Code Here


      ParameterValidation.throwIllegalArgExceptionIfNull(accessMode, "access mode");
      if (debug)
      {
         log.debug("Portlet is requesting " + accessMode + " access mode");
      }
      InteractionParams interactionParams = WSRPTypeFactory.createInteractionParams(WSRPUtils.getStateChangeFromAccessMode(accessMode));
      interactionParams.getExtensions().addAll(ExtensionAccess.getConsumerExtensionAccessor().getRequestExtensionsFor(InteractionParams.class));

      // 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
      try
      {
         MultiPartResult multiPartResult = MultiPartUtil.getMultiPartContent(invocation.getRequestContext());
         if (multiPartResult != null)
         {
            interactionParams.getFormParameters().addAll(multiPartResult.getFormParameters());
            interactionParams.getUploadContexts().addAll(multiPartResult.getUploadContexts());
         }

         // Also check for form parameters from the Invocation
         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;
               for (String value : values)
               {
                  formParameter = WSRPTypeFactory.createNamedString(name, value);
                  formParameters.add(formParameter);
               }
            }
            interactionParams.getFormParameters().addAll(formParameters);
         }
        
      }
      catch (Exception e)
      {
View Full Code Here

   public static InteractionParams toV2InteractionParams(V1InteractionParams v1InteractionParams)
   {
      if (v1InteractionParams != null)
      {
         InteractionParams interactionParams = WSRPTypeFactory.createInteractionParams(toV2StateChange(v1InteractionParams.getPortletStateChange()));
         interactionParams.setInteractionState(v1InteractionParams.getInteractionState());
         interactionParams.getExtensions().addAll(Lists.transform(v1InteractionParams.getExtensions(), EXTENSION));
         interactionParams.getFormParameters().addAll(Lists.transform(v1InteractionParams.getFormParameters(), NAMEDSTRING));
         interactionParams.getUploadContexts().addAll(Lists.transform(v1InteractionParams.getUploadContexts(), UPLOADCONTEXT));

         return interactionParams;
      }
      else
      {
View Full Code Here

   public static PerformBlockingInteraction toV2PerformBlockingInteraction(V1PerformBlockingInteraction performBlockingInteraction)
   {
      if (performBlockingInteraction != null)
      {
         InteractionParams interactionParams = toV2InteractionParams(performBlockingInteraction.getInteractionParams());
         MarkupParams markupParams = toV2MarkupParams(performBlockingInteraction.getMarkupParams());
         PortletContext portletContext = toV2PortletContext(performBlockingInteraction.getPortletContext());
         RuntimeContext runtimeContext = toV2RuntimeContext(performBlockingInteraction.getRuntimeContext(), portletContext.getPortletHandle());

         return WSRPTypeFactory.createPerformBlockingInteraction(toV2RegistrationContext(performBlockingInteraction.getRegistrationContext()),
View Full Code Here

   public static InteractionParams createInteractionParams(StateChange portletStateChange)
   {
      ParameterValidation.throwIllegalArgExceptionIfNull(portletStateChange, "portletStateChange");

      InteractionParams interactionParams = new InteractionParams();
      interactionParams.setPortletStateChange(portletStateChange);
      return interactionParams;
   }
View Full Code Here

      throws AccessDenied, InconsistentParameters, InvalidCookie, InvalidHandle, InvalidRegistration, InvalidSession,
      InvalidUserCategory, MissingParameters, ModifyRegistrationRequired, OperationFailed, PortletStateChangeRequired,
      ResourceSuspended, UnsupportedLocale, UnsupportedMimeType, UnsupportedMode, UnsupportedWindowState
   {
      WSRP2ExceptionFactory.throwOperationFailedIfValueIsMissing(performBlockingInteraction, PBI);
      final InteractionParams interactionParams = performBlockingInteraction.getInteractionParams();
      WSRP2ExceptionFactory.throwMissingParametersIfValueIsMissing(interactionParams, "InteractionParams", PBI);

      RequestProcessor<BlockingInteractionResponse> requestProcessor = ProcessorFactory.getProcessorFor(producer, performBlockingInteraction);

      PortletInvocationResponse response;
View Full Code Here

   }

   PortletInvocation initInvocation(WSRPPortletInvocationContext context)
   {
      ActionInvocation invocation = new ActionInvocation(context);
      InteractionParams interactionParams = performBlockingInteraction.getInteractionParams();

      // Request context
      WSRPRequestContext requestContext = WSRPRequestContext.createRequestContext(markupRequest, interactionParams);
      invocation.setRequestContext(requestContext);

      // Interaction state, navigational state is already taken care of in RequestProcessor.prepareInvocation
      StateString interactionState = createNavigationalState(interactionParams.getInteractionState());
      invocation.setInteractionState(interactionState);

      // Form parameters
      invocation.setForm(requestContext.getForm());

      // Extensions
      processExtensionsFrom(interactionParams.getClass(), interactionParams.getExtensions());

      return invocation;
   }
View Full Code Here

   public static InteractionParams createInteractionParams(StateChange portletStateChange)
   {
      ParameterValidation.throwIllegalArgExceptionIfNull(portletStateChange, "portletStateChange");

      InteractionParams interactionParams = new InteractionParams();
      interactionParams.setPortletStateChange(portletStateChange);
      return interactionParams;
   }
View Full Code Here

      ParameterValidation.throwIllegalArgExceptionIfNull(accessMode, "access mode");
      if (debug)
      {
         log.debug("Portlet is requesting " + accessMode + " access mode");
      }
      InteractionParams interactionParams = WSRPTypeFactory.createInteractionParams(WSRPUtils.getStateChangeFromAccessMode(accessMode));
      interactionParams.getExtensions().addAll(ExtensionAccess.getConsumerExtensionAccessor().getRequestExtensionsFor(InteractionParams.class));

      // 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
      {
         MultiPartResult multiPartResult = MultiPartUtil.getMultiPartContent(invocation.getRequestContext());
         if (multiPartResult != null)
         {
            interactionParams.getFormParameters().addAll(multiPartResult.getFormParameters());
            interactionParams.getUploadContexts().addAll(multiPartResult.getUploadContexts());
         }

         // Also check for form parameters from the Invocation
         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;
               for (String value : values)
               {
                  formParameter = WSRPTypeFactory.createNamedString(name, value);
                  formParameters.add(formParameter);
               }
            }
            interactionParams.getFormParameters().addAll(formParameters);
         }
        
      }
      catch (Exception e)
      {
View Full Code Here

   public static InteractionParams createInteractionParams(StateChange portletStateChange)
   {
      ParameterValidation.throwIllegalArgExceptionIfNull(portletStateChange, "portletStateChange");

      InteractionParams interactionParams = new InteractionParams();
      interactionParams.setPortletStateChange(portletStateChange);
      return interactionParams;
   }
View Full Code Here

TOP

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

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.