Package org.oasis.wsrp.v2

Examples of org.oasis.wsrp.v2.MarkupResponse


   {
      forceSessionAccess();

      GetMarkup getMarkup = WSRPTypeFactory.createGetMarkup(registrationContext, portletContext, runtimeContext, userContext, markupParams);

      MarkupResponse response = producer.getMarkup(getMarkup);

      markupContext.value = response.getMarkupContext();
      sessionContext.value = response.getSessionContext();
      extensions.value = response.getExtensions();
   }
View Full Code Here


         V1ToV2Converter.toV2RuntimeContext(runtimeContext, portletContext.getPortletHandle()),
         V1ToV2Converter.toV2UserContext(userContext),
         V1ToV2Converter.toV2MarkupParams(markupParams)
      );

      MarkupResponse response;
      try
      {
         response = producer.getMarkup(getMarkup);
      }
      catch (UnsupportedWindowState unsupportedWindowState)
      {
         throw V2ToV1Converter.toV1Exception(V1UnsupportedWindowState.class, unsupportedWindowState);
      }
      catch (InvalidCookie invalidCookie)
      {
         throw V2ToV1Converter.toV1Exception(V1InvalidCookie.class, invalidCookie);
      }
      catch (InvalidSession invalidSession)
      {
         throw V2ToV1Converter.toV1Exception(V1InvalidSession.class, invalidSession);
      }
      catch (AccessDenied accessDenied)
      {
         throw V2ToV1Converter.toV1Exception(V1AccessDenied.class, accessDenied);
      }
      catch (InconsistentParameters inconsistentParameters)
      {
         throw V2ToV1Converter.toV1Exception(V1InconsistentParameters.class, inconsistentParameters);
      }
      catch (InvalidHandle invalidHandle)
      {
         throw V2ToV1Converter.toV1Exception(V1InvalidHandle.class, invalidHandle);
      }
      catch (UnsupportedLocale unsupportedLocale)
      {
         throw V2ToV1Converter.toV1Exception(V1UnsupportedLocale.class, unsupportedLocale);
      }
      catch (UnsupportedMode unsupportedMode)
      {
         throw V2ToV1Converter.toV1Exception(V1UnsupportedMode.class, unsupportedMode);
      }
      catch (OperationFailed operationFailed)
      {
         throw V2ToV1Converter.toV1Exception(V1OperationFailed.class, operationFailed);
      }
      catch (MissingParameters missingParameters)
      {
         throw V2ToV1Converter.toV1Exception(V1MissingParameters.class, missingParameters);
      }
      catch (InvalidUserCategory invalidUserCategory)
      {
         throw V2ToV1Converter.toV1Exception(V1InvalidUserCategory.class, invalidUserCategory);
      }
      catch (InvalidRegistration invalidRegistration)
      {
         throw V2ToV1Converter.toV1Exception(V1InvalidRegistration.class, invalidRegistration);
      }
      catch (UnsupportedMimeType unsupportedMimeType)
      {
         throw V2ToV1Converter.toV1Exception(V1UnsupportedMimeType.class, unsupportedMimeType);
      }
      catch (ModifyRegistrationRequired modifyRegistrationRequired)
      {
         throw WSRP1ExceptionFactory.createWSException(V1OperationFailed.class, "Need to call modifyRegistration", modifyRegistrationRequired);
      }
      catch (ResourceSuspended resourceSuspended)
      {
         throw WSRP1ExceptionFactory.createWSException(V1OperationFailed.class, "Resource suspended", resourceSuspended);
      }

      markupContext.value = V2ToV1Converter.toV1MarkupContext(response.getMarkupContext());
      sessionContext.value = V2ToV1Converter.toV1SessionContext(response.getSessionContext());
      extensions.value = Lists.transform(response.getExtensions(), V2ToV1Converter.EXTENSION);
   }
View Full Code Here

   public V1MarkupResponse getMarkup(V1GetMarkup getMarkup) throws V1UnsupportedWindowState, V1InvalidCookie, V1InvalidSession, V1AccessDenied, V1InconsistentParameters, V1InvalidHandle, V1UnsupportedLocale, V1UnsupportedMode, V1OperationFailed, V1MissingParameters, V1InvalidUserCategory, V1InvalidRegistration, V1UnsupportedMimeType
   {
      try
      {
         MarkupResponse markupResponse = producer.getMarkup(V1ToV2Converter.toV2GetMarkup(getMarkup));
         return V2ToV1Converter.toV1MarkupResponse(markupResponse);
      }
      catch (UnsupportedMimeType unsupportedMimeType)
      {
         throw V2ToV1Converter.toV1Exception(V1UnsupportedMimeType.class, unsupportedMimeType);
View Full Code Here

   public static MarkupResponse createMarkupResponse(MarkupContext markupContext)
   {
      ParameterValidation.throwIllegalArgExceptionIfNull(markupContext, "MarkupContext");

      MarkupResponse markupResponse = new MarkupResponse();
      markupResponse.setMarkupContext(markupContext);
      return markupResponse;
   }
View Full Code Here

         CapabilitiesInfo capInfo = info.getCapabilities();
         Collection<MediaType> allMediaTypes = capInfo.getMediaTypes();
         List<MarkupType> markupTypes = new ArrayList<MarkupType>(allMediaTypes.size());
         for (MediaType mediaType : allMediaTypes)
         {
            MarkupType markupType = WSRPTypeFactory.createMarkupType(mediaType.getValue(),
               getModeNamesFrom(capInfo.getModes(mediaType)), getWindowStateNamesFrom(capInfo.getWindowStates(mediaType)),
               getLocaleNamesFrom(capInfo.getLocales(mediaType)));
            markupTypes.add(markupType);
         }
View Full Code Here

    */
   private MarkupRequest createMarkupRequestFrom(List<MarkupType> markupTypes, MimeRequest params, Portlet portlet)
      throws UnsupportedMimeType, UnsupportedMode, UnsupportedWindowState, UnsupportedLocale
   {
      List<String> desiredMIMETypes = params.getMimeTypes();
      MarkupType markupType = null;

      // Get the MIME type to use
      // todo: MIME type resolution should really be done in common... maybe as part of GTNCOMMON-14?
      for (String desiredMIMEType : desiredMIMETypes)
      {
         desiredMIMEType = desiredMIMEType.trim();

         // first deal with full wildcards
         if ("*".equals(desiredMIMEType) || "*/*".equals(desiredMIMEType))
         {
            markupType = markupTypes.get(0);
            break;
         }
         else
         {
            MediaType mt = MediaType.create(desiredMIMEType);
            String superType = mt.getType().getName();
            String subType = mt.getSubtype().getName();
            boolean isWildcard = "*".equals(subType);

            for (MarkupType type : markupTypes)
            {
               if (isWildcard && type.getMimeType().startsWith(superType))
               {
                  markupType = type;
                  break;
               }
               else if (desiredMIMEType.equals(type.getMimeType()))
               {
                  markupType = type;
                  break;
               }
            }
         }

         // if we've found a match, do not examine the other possible matches
         if (markupType != null)
         {
            break;
         }
      }

      // no MIME type was found: error!
      if (markupType == null)
      {
         throw WSRP2ExceptionFactory.throwWSException(UnsupportedMimeType.class, "None of the specified MIME types are supported by portlet '" + portlet.getContext().getId() + "'", null);
      }

      // use user-desired locales
      List<String> desiredLocales = new ArrayList<String>(params.getLocales());
      List<String> supportedLocales = new ArrayList<String>(markupType.getLocales());
      desiredLocales.retainAll(supportedLocales);

      if (desiredLocales.isEmpty())
      {
         desiredLocales = params.getLocales();
      }

      // copy MarkupType as this is one shared instance
      MarkupType markupTypeCopy = WSRPTypeFactory.createMarkupType(markupType.getMimeType(), markupType.getModes(), markupType.getWindowStates(), desiredLocales);
      markupTypeCopy.getExtensions().addAll(markupType.getExtensions());

      // get the mode
      String mode;
      try
      {
         mode = getMatchingOrFailFrom(markupTypeCopy.getModes(), params.getMode(), PORTLET_MODE);
      }
      catch (IllegalArgumentException e)
      {
         throw WSRP2ExceptionFactory.throwWSException(UnsupportedMode.class, "Unsupported mode '" + params.getMode() + "'", e);
      }

      // get the window state
      String windowState;
      try
      {
         windowState = getMatchingOrFailFrom(markupTypeCopy.getWindowStates(), params.getWindowState(), WINDOW_STATE);
      }
      catch (IllegalArgumentException e)
      {
         throw WSRP2ExceptionFactory.throwWSException(UnsupportedWindowState.class, "Unsupported window state '" + params.getWindowState() + "'", e);
      }
View Full Code Here

      final RuntimeContext runtimeContext = getRuntimeContext();
      WSRP2ExceptionFactory.throwMissingParametersIfValueIsMissing(runtimeContext, "RuntimeContext", contextName);
      checkForSessionIDs(runtimeContext);

      // get parameters
      final MimeRequest params = getParams();
      WSRP2ExceptionFactory.throwMissingParametersIfValueIsMissing(params, "MarkupParams", contextName);

      // get portlet handle
      PortletContext wsrpPC = getPortletContext();
      WSRP2ExceptionFactory.throwMissingParametersIfValueIsMissing(wsrpPC, "PortletContext", contextName);
      org.gatein.pc.api.PortletContext portletContext = WSRPUtils.convertToPortalPortletContext(wsrpPC);

      // check locales
      final List<String> desiredLocales = params.getLocales();
      for (String locale : desiredLocales)
      {
         try
         {
            WSRPUtils.getLocale(locale);
         }
         catch (IllegalArgumentException e)
         {
            throw WSRP2ExceptionFactory.throwWSException(UnsupportedLocale.class, e.getLocalizedMessage(), null);
         }
      }

      // retrieve the portlet
      try
      {
         // calls RegistrationLocal.setRegistration so no need to here
         portlet = producer.getPortletWith(portletContext, registration);
      }
      catch (PortletInvokerException e)
      {
         throw WSRP2ExceptionFactory.throwWSException(OperationFailed.class, "Could not retrieve portlet '" + portletContext + "'", e);
      }

      // get portlet description for the desired portlet...
      portletDescription = producer.getPortletDescription(wsrpPC, null, registration);
      if (Boolean.TRUE.equals(portletDescription.isUsesMethodGet()))
      {
         throw WSRP2ExceptionFactory.throwWSException(OperationFailed.class, "Portlets using GET method in forms are not currently supported.", null);
      }

      List<MarkupType> markupTypes = portletDescription.getMarkupTypes();

      // based on the markup parameters and portlet description generate the most appropriate markup request
      markupRequest = createMarkupRequestFrom(markupTypes, params, portlet);

      // prepare information for invocation
      final org.oasis.wsrp.v2.UserContext wsrpUserContext = getUserContext();
      checkUserContext(wsrpUserContext);
      SecurityContext securityContext = createSecurityContext(params, runtimeContext, wsrpUserContext);
      final MediaType mediaType = createMediaType(markupRequest);
      PortalContext portalContext = createPortalContext(params, markupRequest);
      UserContext userContext = createUserContext(wsrpUserContext, markupRequest.getLocale(), desiredLocales);
      String portletInstanceKey = runtimeContext.getPortletInstanceKey();
      instanceContext = createInstanceContext(portletContext, getAccessMode(), portletInstanceKey);
      WindowContext windowContext = createWindowContext(portletContext.getId(), runtimeContext);

      // prepare the invocation context
      WSRPPortletInvocationContext context = new WSRPPortletInvocationContext(mediaType, securityContext, portalContext, userContext, instanceContext, windowContext);
      // and use it to initialize the invocation that will send to the PortletInvoker
      PortletInvocation invocation = initInvocation(context);

      // mark the invocation as coming from WSRP, useful for bridges and/or web framework
      final HashMap<String, Object> attributes = new HashMap<String, Object>();
      attributes.put(WSRPConstants.FROM_WSRP_ATTRIBUTE_NAME, Boolean.TRUE);
      invocation.setRequestAttributes(attributes);

      invocation.setTarget(portlet.getContext());
      invocation.setWindowState(WSRPUtils.getJSR168WindowStateFromWSRPName(markupRequest.getWindowState()));
      invocation.setMode(WSRPUtils.getJSR168PortletModeFromWSRPName(markupRequest.getMode()));

      NavigationalContext navigationalContext = params.getNavigationalContext();
      if (navigationalContext != null)
      {
         StateString navigationalState = createNavigationalState(navigationalContext.getOpaqueValue());
         invocation.setNavigationalState(navigationalState);
View Full Code Here

      {
         // initialize if needed
         initIfNeeded();

         // only add registration properties if we asked for them
         ModelDescription registrationProperties = needsRegistrationProperties ? this.registrationProperties : null;

         // set the service description details
         ServiceDescription serviceDescription = WSRPTypeFactory.createServiceDescription(false);
         serviceDescription.setRequiresInitCookie(BEA_8_CONSUMER_FIX);
         serviceDescription.getSupportedOptions().addAll(OPTIONS);
View Full Code Here

      invocation.setTarget(portlet.getContext());
      invocation.setWindowState(WSRPUtils.getJSR168WindowStateFromWSRPName(markupRequest.getWindowState()));
      invocation.setMode(WSRPUtils.getJSR168PortletModeFromWSRPName(markupRequest.getMode()));

      NavigationalContext navigationalContext = params.getNavigationalContext();
      if (navigationalContext != null)
      {
         StateString navigationalState = createNavigationalState(navigationalContext.getOpaqueValue());
         invocation.setNavigationalState(navigationalState);

         List<NamedString> publicParams = navigationalContext.getPublicValues();


         if (ParameterValidation.existsAndIsNotEmpty(publicParams))
         {
            Map<String, String[]> publicNS = WSRPUtils.createPublicNSFrom(publicParams);
View Full Code Here

   protected UpdateResponse createUpdateResponse(UpdateNavigationalStateResponse stateResponse)
   {
      UpdateResponse updateResponse = WSRPTypeFactory.createUpdateResponse();
      updateResponse.setNewMode(WSRPUtils.convertJSR168PortletModeNameToWSRPName(getNewStateOrNull(stateResponse, true)));
      updateResponse.setNewWindowState(WSRPUtils.convertJSR168WindowStateNameToWSRPName(getNewStateOrNull(stateResponse, false)));
      NavigationalContext navigationalContext = WSRPTypeFactory.createNavigationalContextOrNull(
         stateResponse.getNavigationalState(),
         stateResponse.getPublicNavigationalStateUpdates()
      );
      updateResponse.setNavigationalContext(navigationalContext);
View Full Code Here

TOP

Related Classes of org.oasis.wsrp.v2.MarkupResponse

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.