Package org.oasis.wsrp.v2

Examples of org.oasis.wsrp.v2.InteractionParams


   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

      try
      {
         RegistrationLocal.setRegistration(registration);

         ExportContext exportContext;
         final Lifetime askedLifetime = exportPortlets.getLifetime();
         if (askedLifetime != null)
         {
            final XMLGregorianCalendar askedLifetimeCurrentTime = askedLifetime.getCurrentTime();
            long currentTime = toLongDate(askedLifetimeCurrentTime);
            long terminationTime = toLongDate(askedLifetime.getTerminationTime());
            long refreshDuration = askedLifetime.getRefreshDuration().getTimeInMillis(askedLifetimeCurrentTime.toGregorianCalendar());
            exportContext = exportManager.createExportContext(exportByValueRequired, currentTime, terminationTime, refreshDuration);
         }
         else
         {
            exportContext = exportManager.createExportContext(exportByValueRequired, -1, -1, -1);
         }

         for (PortletContext portletContext : portletContexts)
         {
            try
            {
               WSRP2ExceptionFactory.throwOperationFailedIfValueIsMissing(portletContext, "Portlet context");
               String portletHandle = portletContext.getPortletHandle();
               WSRP2ExceptionFactory.throwMissingParametersIfValueIsMissing(portletHandle, "Portlet handle", "PortletContext");

               org.gatein.pc.api.PortletContext portalPC = WSRPUtils.convertToPortalPortletContext(portletContext);

               org.gatein.pc.api.PortletContext exportedPortalPC = producer.getPortletInvoker().exportPortlet(PortletStateType.OPAQUE, portalPC);
               if (exportedPortalPC == null)
               {
                  WSRP2ExceptionFactory.throwWSException(InvalidHandle.class, "Could not find a portlet with handle " + portletHandle + " in the producer", null);
               }

               byte[] portletState = WSRPUtils.getStateOrNullFor(exportedPortalPC);

               //get the exportPortletData
               ExportPortletData exportPortletData = exportManager.createExportPortletData(exportContext, portletHandle, portletState);

               //Create the exportedPortlet
               byte[] exportPortletBytes = exportManager.encodeExportPortletData(exportContext, exportPortletData);
               ExportedPortlet exportedPortlet = WSRPTypeFactory.createExportedPortlet(portletHandle, exportPortletBytes);
               exportedPortlets.add(exportedPortlet);
            }

            catch (Exception e)
            {
               if (log.isWarnEnabled())
               {
                  log.warn("Error occured while trying to export a portlet.", e);
               }

               ErrorCodes.Codes errorCode;
               String reason;
               if (e instanceof NoSuchPortletException || e instanceof InvalidHandle)
               {
                  errorCode = ErrorCodes.Codes.INVALIDHANDLE;
                  reason = "The specified portlet handle is invalid";
               }
               else // default error message.
               {
                  errorCode = ErrorCodes.Codes.OPERATIONFAILED;
                  reason = "Error preparing portlet for export";
               }

               final String errorCodeName = errorCode.name();
               if (!failedPortletsMap.containsKey(errorCodeName))
               {
                  List<String> portletHandles = new ArrayList<String>();
                  portletHandles.add(portletContext.getPortletHandle());

                  FailedPortlets failedPortlets = WSRPTypeFactory.createFailedPortlets(portletHandles, errorCode, reason);
                  failedPortletsMap.put(errorCodeName, failedPortlets);
               }
               else
               {
                  FailedPortlets failedPortlets = failedPortletsMap.get(errorCodeName);
                  failedPortlets.getPortletHandles().add(portletContext.getPortletHandle());
               }
            }
         }

         //TODO: handle resourceLists better (should be using for things like errors)
         ResourceList resourceList = null;

         byte[] exportContextBytes = exportManager.encodeExportContextData(exportContext);

         Lifetime lifetime = null;

         if (exportContext.getCurrentTime() > 0)
         {
            lifetime = new Lifetime();
            lifetime.setCurrentTime(toXMLGregorianCalendar(exportContext.getCurrentTime()));
            lifetime.setTerminationTime(toXMLGregorianCalendar(exportContext.getTermintationTime()));
            lifetime.setRefreshDuration(toDuration(exportContext.getRefreshDuration()));
         }

         return WSRPTypeFactory.createExportPortletsResponse(exportContextBytes, exportedPortlets, new ArrayList<FailedPortlets>(failedPortletsMap.values()), lifetime, resourceList);
      }
      catch (Exception e)
View Full Code Here

      {
         RegistrationLocal.setRegistration(registration);

         byte[] importContext = importPortlets.getImportContext();

         Lifetime lifeTime = importPortlets.getLifetime();

         List<ImportedPortlet> importedPortlets = new ArrayList<ImportedPortlet>();
         Map<String, ImportPortletsFailed> failedPortletsMap = new HashMap<String, ImportPortletsFailed>();

         ExportContext exportContext;
         final ExportManager exportManager = producer.getExportManager();
         try
         {
            exportContext = exportManager.createExportContext(importContext);
         }
         catch (Exception e)
         {
            throw WSRPExceptionFactory.createWSException(OperationFailed.class, "Invalid ImportContext.", e);
         }

         for (ImportPortlet importPortlet : importPortletList)
         {
            try
            {
               byte[] portletData = importPortlet.getExportData();

               ExportPortletData exportPortletData;
               if (lifeTime != null)
               {
                  long currentTime = toLongDate(lifeTime.getCurrentTime());
                  long terminationTime = toLongDate(lifeTime.getTerminationTime());
                  long refreshDuration = lifeTime.getRefreshDuration().getTimeInMillis(lifeTime.getCurrentTime().toGregorianCalendar());
                  exportPortletData = exportManager.createExportPortletData(exportContext, currentTime, terminationTime, refreshDuration, portletData);
               }
               else
               {
                  exportPortletData = exportManager.createExportPortletData(exportContext, -1, -1, -1, portletData);
View Full Code Here

   private Lifetime getLifetime(ExportContext exportContext) throws DatatypeConfigurationException
   {
      if (exportContext.getCurrentTime() >= 0)
      {
         Lifetime lifetime = new Lifetime();

         XMLGregorianCalendar currentTime = toXMLGregorianCalendar(exportContext.getCurrentTime());
         XMLGregorianCalendar terminationTime = toXMLGregorianCalendar(exportContext.getTermintationTime());

         Duration duration = toDuration(exportContext.getRefreshDuration());

         lifetime.setCurrentTime(currentTime);
         lifetime.setTerminationTime(terminationTime);
         lifetime.setRefreshDuration(duration);

         return lifetime;
      }
      else
      {
View Full Code Here

TOP

Related Classes of org.oasis.wsrp.v2.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.