Package org.oasis.wsrp.v2

Examples of org.oasis.wsrp.v2.ResourceParams


      {
         throw new IllegalArgumentException("GetResource needs a valid resource id.");
      }

      // Create ResourceParams
      ResourceParams resourceParams = WSRPTypeFactory.createResourceParams(params.isSecureClientCommunication(),
         params.getLocales(), params.getMimeTypes(), params.getMode(), params.getWindowState(), resourceId,
         WSRPUtils.getStateChangeFromAccessMode(accessMode));

      resourceParams.setNavigationalContext(params.getNavigationalContext());
      resourceParams.setClientData(params.getClientData());
      resourceParams.setResourceCacheability(WSRPUtils.getResourceCacheabilityFromCacheLevel(invocation.getCacheLevel()));

      for (Map.Entry<String, String[]> entry : invocation.getForm().entrySet())
      {
         String name = entry.getKey();
         for (String value : entry.getValue())
         {
            resourceParams.getFormParameters().add(WSRPTypeFactory.createNamedString(name, value));
         }
      }

      StateString resourceState = invocation.getResourceState();
      if (resourceState != null)
      {
         String state = resourceState.getStringValue();
         if (!StateString.JBPNS_PREFIX.equals(state))  // fix-me: see JBPORTAL-900
         {
            resourceParams.setResourceState(state);
         }
      }

      return WSRPTypeFactory.createGetResource(requestPrecursor.getRegistrationContext(), portletContext,
         requestPrecursor.getRuntimeContext(), requestPrecursor.getUserContext(), resourceParams);
View Full Code Here


      {
         throw new IllegalArgumentException("GetResource needs a valid resource id.");
      }

      // Create ResourceParams
      ResourceParams resourceParams = WSRPTypeFactory.createResourceParams(params.isSecureClientCommunication(),
         params.getLocales(), params.getMimeTypes(), params.getMode(), params.getWindowState(), resourceId,
         WSRPUtils.getStateChangeFromAccessMode(accessMode));

      resourceParams.setNavigationalContext(params.getNavigationalContext());
      resourceParams.setClientData(params.getClientData());
      resourceParams.setResourceCacheability(WSRPUtils.getResourceCacheabilityFromCacheLevel(invocation.getCacheLevel()));
      resourceParams.getExtensions().addAll(ExtensionAccess.getConsumerExtensionAccessor().getRequestExtensionsFor(ResourceParams.class));

      for (Map.Entry<String, String[]> entry : invocation.getForm().entrySet())
      {
         String name = entry.getKey();
         for (String value : entry.getValue())
         {
            resourceParams.getFormParameters().add(WSRPTypeFactory.createNamedString(name, value));
         }
      }

      StateString resourceState = invocation.getResourceState();
      if (resourceState != null)
      {
         String state = resourceState.getStringValue();
         if (!StateString.JBPNS_PREFIX.equals(state))  // fix-me: see JBPORTAL-900
         {
            resourceParams.setResourceState(state);
         }
      }
     
      MultiPartResult multiPartResult = MultiPartUtil.getMultiPartContent(invocation.getRequestContext());
      if (multiPartResult != null)
      {
         resourceParams.getFormParameters().addAll(multiPartResult.getFormParameters());
         resourceParams.getUploadContexts().addAll(multiPartResult.getUploadContexts());
      }

      return WSRPTypeFactory.createGetResource(requestPrecursor.getRegistrationContext(), portletContext,
         requestPrecursor.getRuntimeContext(), requestPrecursor.getUserContext(), resourceParams);
   }
View Full Code Here

         WSRPConstants.VIEW_MODE, WSRPConstants.NORMAL_WINDOW_STATE, resourceID, StateChange.READ_ONLY);
   }

   public static ResourceParams createResourceParams(boolean secureClientCommunication, List<String> locales, List<String> mimeTypes, String mode, String windowState, String resourceID, StateChange stateChange, Map<String, String[]> parameters)
   {
      ResourceParams resourceParams = createResourceParams(secureClientCommunication, locales, mimeTypes, mode, windowState, resourceID, stateChange);
      List<NamedString> formParameters = new ArrayList<NamedString>(parameters.size());
      for (String key : parameters.keySet())
      {
         NamedString namedString = new NamedString();
         namedString.setName(key);
         namedString.setValue(parameters.get(key)[0]);
         resourceParams.getFormParameters().add(namedString);
      }
      return resourceParams;
   }
View Full Code Here

      ParameterValidation.throwIllegalArgExceptionIfNull(stateChange, "State Change");
      ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(mode, "mode", "ResourceParams");
      ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(windowState, "window state", "ResourceParams");
      ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(resourceID, "Resource ID", "ResourceParams");

      ResourceParams resourceParams = new ResourceParams();
      resourceParams.setSecureClientCommunication(secureClientCommunication);
      resourceParams.setMode(mode);
      resourceParams.setWindowState(windowState);
      if (ParameterValidation.existsAndIsNotEmpty(locales))
      {
         resourceParams.getLocales().addAll(locales);
      }

      if (ParameterValidation.existsAndIsNotEmpty(mimeTypes))
      {
         resourceParams.getMimeTypes().addAll(mimeTypes);
      }

      resourceParams.setResourceID(resourceID);
      resourceParams.setPortletStateChange(stateChange);

      return resourceParams;
   }
View Full Code Here

      List<String> locales = WSRPUtils.convertLocalesToRFC3066LanguageTags(Collections.list(reqLocales));
      List<String> mimeTypes = WSRPConstants.getDefaultMimeTypes();

      Map<String, String[]> parameters = req.getParameterMap();

      ResourceParams resourceParams = WSRPTypeFactory.createResourceParams(req.isSecure(), locales, mimeTypes,
         WSRPConstants.VIEW_MODE, WSRPConstants.NORMAL_WINDOW_STATE, resourceId, StateChange.READ_ONLY, parameters);
      resourceParams.setResourceState(req.getParameter(RESOURCE_STATE));

      String navState = req.getParameter(NAV_STATE);
      if (!ParameterValidation.isNullOrEmpty(navState))
      {
         resourceParams.setNavigationalContext(WSRPTypeFactory.createNavigationalContext(navState, Collections.<NamedString>emptyList()));
      }

      return WSRPTypeFactory.createGetResource(registrationContext, portletContext, runtimeContext, null, resourceParams);
   }
View Full Code Here

   protected PortletInvocation internalInitInvocation(WSRPPortletInvocationContext context)
   {
      ResourceInvocation resourceInvocation = new ResourceInvocation(context);

      ResourceParams resourceParams = this.getResource.getResourceParams();

      // only set the resource id if it's different from the place holder we use if the portlet doesn't set one
      String id = this.getResource.getResourceParams().getResourceID();
      if (!WSRPResourceURL.DEFAULT_RESOURCE_ID.equals(id))
      {
         resourceInvocation.setResourceId(id);
      }

      WSRPRequestContext requestContext = WSRPRequestContext.createRequestContext(markupRequest, resourceParams);
      resourceInvocation.setRequestContext(requestContext);
      resourceInvocation.setForm(requestContext.getForm());

      //TODO: property set validation token for caching (ie ETAG)
      String validationToken = null;
      resourceInvocation.setValidationToken(validationToken);

      resourceInvocation.setResourceState(createNavigationalState(resourceParams.getResourceState()));

      String resourceCacheability = resourceParams.getResourceCacheability();
      if (resourceCacheability != null)
      {
         CacheLevel cacheLevel = WSRPUtils.getCacheLevelFromResourceCacheability(resourceParams.getResourceCacheability());
         resourceInvocation.setCacheLevel(cacheLevel);
      }
      else
      {
         // according to JSR 286, cache level must default to ResourceURL.PAGE
View Full Code Here

      ParameterValidation.throwIllegalArgExceptionIfNull(stateChange, "State Change");
      ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(mode, "mode", "ResourceParams");
      ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(windowState, "window state", "ResourceParams");
      ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(resourceID, "Resource ID", "ResourceParams");

      ResourceParams resourceParams = new ResourceParams();
      resourceParams.setSecureClientCommunication(secureClientCommunication);
      resourceParams.setMode(mode);
      resourceParams.setWindowState(windowState);
      if (ParameterValidation.existsAndIsNotEmpty(locales))
      {
         resourceParams.getLocales().addAll(locales);
      }

      if (ParameterValidation.existsAndIsNotEmpty(mimeTypes))
      {
         resourceParams.getMimeTypes().addAll(mimeTypes);
      }

      resourceParams.setResourceID(resourceID);
      resourceParams.setPortletStateChange(stateChange);

      return resourceParams;
   }
View Full Code Here

      Enumeration reqLocales = req.getLocales();
      List<String> locales = WSRPUtils.convertLocalesToRFC3066LanguageTags(Collections.list(reqLocales));
      List<String> mimeTypes = WSRPConstants.getDefaultMimeTypes();

      ResourceParams resourceParams = WSRPTypeFactory.createResourceParams(req.isSecure(), locales, mimeTypes,
         WSRPConstants.VIEW_MODE, WSRPConstants.NORMAL_WINDOW_STATE, resourceId, StateChange.READ_ONLY);
      resourceParams.setResourceState(req.getParameter(RESOURCE_STATE));

      String navState = req.getParameter(NAV_STATE);
      if (!ParameterValidation.isNullOrEmpty(navState))
      {
         resourceParams.setNavigationalContext(WSRPTypeFactory.createNavigationalContext(navState, Collections.<NamedString>emptyList()));
      }

      return WSRPTypeFactory.createGetResource(registrationContext, portletContext, runtimeContext, null, resourceParams);
   }
View Full Code Here

      ParameterValidation.throwIllegalArgExceptionIfNull(stateChange, "State Change");
      ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(mode, "mode", "ResourceParams");
      ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(windowState, "window state", "ResourceParams");
      ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(resourceID, "Resource ID", "ResourceParams");

      ResourceParams resourceParams = new ResourceParams();
      resourceParams.setSecureClientCommunication(secureClientCommunication);
      resourceParams.setMode(mode);
      resourceParams.setWindowState(windowState);
      if (ParameterValidation.existsAndIsNotEmpty(locales))
      {
         resourceParams.getLocales().addAll(locales);
      }

      if (ParameterValidation.existsAndIsNotEmpty(mimeTypes))
      {
         resourceParams.getMimeTypes().addAll(mimeTypes);
      }

      resourceParams.setResourceID(resourceID);
      resourceParams.setPortletStateChange(stateChange);

      return resourceParams;
   }
View Full Code Here

      GetResource getResource = ResourceServingUtil.decode(req);

      try
      {
         ResourceResponse resource = producer.getResource(getResource);
         ResourceContext resourceContext = resource.getResourceContext();
         byte[] itemBinary = resourceContext.getItemBinary();
         String itemString = resourceContext.getItemString();

         final String mimeType = resourceContext.getMimeType();
         if (!ParameterValidation.isNullOrEmpty(mimeType))
View Full Code Here

TOP

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

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.