Package org.gatein.common.net.media

Examples of org.gatein.common.net.media.MediaType


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


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

      length = (length > 0 ? length : Tools.DEFAULT_BUFFER_SIZE * 8);
      byte[] bytes = IOTools.getBytes(urlConnection.getInputStream(), length);


      ResourceContext resourceContext;
      MediaType type = MediaType.create(contentType);

      // GTNCOMMON-14
      if (isInterpretableAsText(type))
      {
         // determine the charset of the content, if any
         String charset = "UTF-8";
         if (contentType != null)
         {
            for (String part : contentType.split(";"))
            {
               if (part.startsWith("charset="))
               {
                  charset = part.substring("charset=".length());
               }
            }
         }

         String markup = new String(bytes, charset);

         resourceContext = WSRPTypeFactory.createResourceContext(contentType, markup, null);

         // process markup if needed
         SubtypeDef subtype = type.getSubtype();
         if (SubtypeDef.HTML.equals(subtype) || SubtypeDef.CSS.equals(subtype) || subtype.getName().contains("javascript") || SubtypeDef.XML.equals(subtype))
         {
            resourceContext.setRequiresRewriting(true);
         }
      }
View Full Code Here

   }

   public void setCharacterEncoding(String s)
   {
      List<Parameter> parameters = new ArrayList<Parameter>();
      MediaType mediaType = null;
     
      String contentTypeString = getContentType();
      if (contentTypeString != null)
      {
         ContentType contentType = ContentType.create(contentTypeString);
View Full Code Here

      final Map<MediaType, MediaTypeInfo> mediaTypes = new HashMap<MediaType, MediaTypeInfo>(markupTypes.size());
      capabilities = new WSRPCapabilitiesInfo();

      for (MarkupType markupType : markupTypes)
      {
         MediaType mediaType = MediaType.create(markupType.getMimeType());
         MediaTypeInfo mediaTypeInfo = new MediaTypeInfo(markupType);
         mediaTypes.put(mediaType, mediaTypeInfo);
         capabilities.addModes(mediaTypeInfo.modes);
         capabilities.addWindowStates(mediaTypeInfo.windowStates);
         capabilities.addLocales(mediaTypeInfo.locales);
View Full Code Here

      final Map<MediaType, MediaTypeInfo> mediaTypes = new HashMap<MediaType, MediaTypeInfo>(markupTypes.size());
      capabilities = new WSRPCapabilitiesInfo();

      for (MarkupType markupType : markupTypes)
      {
         MediaType mediaType = MediaType.create(markupType.getMimeType());
         MediaTypeInfo mediaTypeInfo = new MediaTypeInfo(markupType);
         mediaTypes.put(mediaType, mediaTypeInfo);
         capabilities.addModes(mediaTypeInfo.modes);
         capabilities.addWindowStates(mediaTypeInfo.windowStates);
         capabilities.addLocales(mediaTypeInfo.locales);
View Full Code Here

         // create markup params
         org.gatein.pc.api.spi.UserContext userContext = invocation.getUserContext();
         ParameterValidation.throwIllegalArgExceptionIfNull(userContext, USER_CONTEXT);
         PortletInvocationContext context = invocation.getContext();
         ParameterValidation.throwIllegalArgExceptionIfNull(context, INVOCATION_CONTEXT);
         final MediaType contentType = context.getResponseContentType();
         ParameterValidation.throwIllegalArgExceptionIfNull(contentType, CONTENT_TYPE);

         String mode;
         try
         {
            mode = WSRPUtils.getWSRPNameFromJSR168PortletMode(invocation.getMode());
         }
         catch (Exception e)
         {
            log.debug("Mode was null in context.");
            mode = WSRPConstants.VIEW_MODE;
         }

         String windowState;
         try
         {
            windowState = WSRPUtils.getWSRPNameFromJSR168WindowState(invocation.getWindowState());
         }
         catch (Exception e)
         {
            log.debug("WindowState was null in context.");
            windowState = WSRPConstants.NORMAL_WINDOW_STATE;
         }

         this.markupParams = WSRPTypeFactory.createMarkupParams(securityContext.isSecure(),
            WSRPUtils.convertLocalesToRFC3066LanguageTags(userContext.getLocales()),
            Collections.singletonList(contentType.getValue()), mode, windowState);
         String userAgent = WSRPConsumerImpl.getHttpRequest(invocation).getHeader(USER_AGENT);
         String requestVerb = WSRPConsumerImpl.getHttpRequest(invocation).getMethod();
         getMarkupParams().setClientData(WSRPTypeFactory.createClientData(userAgent, requestVerb));
         getMarkupParams().getExtensions().addAll(ExtensionAccess.getConsumerExtensionAccessor().getRequestExtensionsFor(MarkupParams.class));
View Full Code Here

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

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

         // create markup params
         org.gatein.pc.api.spi.UserContext userContext = invocation.getUserContext();
         ParameterValidation.throwIllegalArgExceptionIfNull(userContext, USER_CONTEXT);
         PortletInvocationContext context = invocation.getContext();
         ParameterValidation.throwIllegalArgExceptionIfNull(context, INVOCATION_CONTEXT);
         final MediaType contentType = context.getResponseContentType();
         ParameterValidation.throwIllegalArgExceptionIfNull(contentType, CONTENT_TYPE);

         String mode;
         try
         {
            mode = WSRPUtils.getWSRPNameFromJSR168PortletMode(invocation.getMode());
         }
         catch (Exception e)
         {
            log.debug("Mode was null in context.");
            mode = WSRPConstants.VIEW_MODE;
         }

         String windowState;
         try
         {
            windowState = WSRPUtils.getWSRPNameFromJSR168WindowState(invocation.getWindowState());
         }
         catch (Exception e)
         {
            log.debug("WindowState was null in context.");
            windowState = WSRPConstants.NORMAL_WINDOW_STATE;
         }

         this.markupParams = WSRPTypeFactory.createMarkupParams(securityContext.isSecure(),
            WSRPUtils.convertLocalesToRFC3066LanguageTags(userContext.getLocales()),
            Collections.singletonList(contentType.getValue()), mode, windowState);
         String userAgent = WSRPConsumerImpl.getHttpRequest(invocation).getHeader(USER_AGENT);
         getMarkupParams().setClientData(WSRPTypeFactory.createClientData(userAgent));
         getMarkupParams().getExtensions().addAll(ExtensionAccess.getConsumerExtensionAccessor().getRequestExtensionsFor(MarkupParams.class));

         // navigational state
View Full Code Here

TOP

Related Classes of org.gatein.common.net.media.MediaType

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.