Package org.oasis.wsrp.v2

Examples of org.oasis.wsrp.v2.RuntimeContext


    */
   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

               {
                  List<ParameterDescription> publicValueDescriptions = desc.getNavigationalPublicValueDescriptions();
                  for (ParameterInfo parameterInfo : parameterInfos)
                  {
                     String id = parameterInfo.getId();
                     ParameterDescription paramDesc = WSRPTypeFactory.createParameterDescription(id);
                     paramDesc.setDescription(Utils.convertToWSRPLocalizedString(parameterInfo.getDescription(), localeMatch));
                     paramDesc.setLabel(WSRPTypeFactory.createLocalizedString(id));
                     List<QName> names = paramDesc.getNames();
                     names.add(parameterInfo.getName());
                     Collection<QName> aliases = parameterInfo.getAliases();
                     if (ParameterValidation.existsAndIsNotEmpty(aliases))
                     {
                        names.addAll(aliases);
View Full Code Here

      // 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();
View Full Code Here

      }

      // deal with implicit cloning and state modification
      if (instanceContext.wasModified())
      {
         PortletContext updatedPortletContext = WSRPUtils.convertToWSRPPortletContext(instanceContext.getPortletContext());
         updateResponse.setPortletContext(updatedPortletContext);
      }
      return updateResponse;
   }
View Full Code Here

      throws AccessDenied, InconsistentParameters, InvalidHandle, InvalidRegistration, InvalidUserCategory,
      MissingParameters, ModifyRegistrationRequired, OperationFailed, OperationNotSupported, ResourceSuspended
   {
      WSRP2ExceptionFactory.throwOperationFailedIfValueIsMissing(clonePortlet, "ClonePortlet");

      PortletContext portletContext = clonePortlet.getPortletContext();
      WSRP2ExceptionFactory.throwMissingParametersIfValueIsMissing(portletContext, "PortletContext", "ClonePortlet");

      Registration registration = producer.getRegistrationOrFailIfInvalid(clonePortlet.getRegistrationContext());

      UserContext userContext = clonePortlet.getUserContext();
      checkUserAuthorization(userContext);

      org.gatein.pc.api.PortletContext portalPC = WSRPUtils.convertToPortalPortletContext(portletContext);
      try
      {
         RegistrationLocal.setRegistration(registration);
         org.gatein.pc.api.PortletContext response = producer.getPortletInvoker().createClone(PortletStateType.OPAQUE, portalPC);
         return WSRPUtils.convertToWSRPPortletContext(response);
      }
      catch (NoSuchPortletException e)
      {
         throw WSRP2ExceptionFactory.throwWSException(InvalidHandle.class, "Failed to create clone for portlet '" + portletContext.getPortletHandle(), e);
      }
      catch (InvalidPortletIdException e)
      {
         throw WSRP2ExceptionFactory.throwWSException(InconsistentParameters.class, "Failed to create clone for portlet '" + portletContext.getPortletHandle(), e);
      }
      catch (PortletInvokerException e)
      {
         throw WSRP2ExceptionFactory.throwWSException(OperationFailed.class, "Failed to create clone for portlet '" + portletContext.getPortletHandle(), e);
      }
      finally
      {
         RegistrationLocal.setRegistration(null);
      }
View Full Code Here

               org.gatein.pc.api.PortletContext exportedPortletContext = producer.getPortletInvoker().exportPortlet(PortletStateType.OPAQUE, portalPC);
               //Change the registration to the new registration and try and do an import. This should force the new import to be under the new registration context
               RegistrationLocal.setRegistration(toRegistration);
               org.gatein.pc.api.PortletContext copiedPortletContext = producer.getPortletInvoker().importPortlet(PortletStateType.OPAQUE, exportedPortletContext);

               PortletContext wsrpClonedPC = WSRPUtils.convertToWSRPPortletContext(copiedPortletContext);

               CopiedPortlet copiedPortlet = WSRPTypeFactory.createCopiedPortlet(wsrpClonedPC, portletContext.getPortletHandle());
               copiedPortlets.add(copiedPortlet);
            }
            catch (Exception e)
View Full Code Here

TOP

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

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.