Examples of MarkupType


Examples of org.oasis.wsrp.v2.MarkupType

      if (windowStateNames.isEmpty())
      {
         throw new IllegalArgumentException("Cannot create a MarkupType with an empty list of windowStates!");
      }

      MarkupType markupType = new MarkupType();
      markupType.setMimeType(mimeType);

      if (ParameterValidation.existsAndIsNotEmpty(modeNames))
      {
         markupType.getModes().addAll(modeNames);
      }
      if (ParameterValidation.existsAndIsNotEmpty(windowStateNames))
      {
         markupType.getWindowStates().addAll(windowStateNames);
      }
      if (ParameterValidation.existsAndIsNotEmpty(localeNames))
      {
         markupType.getLocales().addAll(localeNames);
      }
      return markupType;
   }
View Full Code Here

Examples of org.oasis.wsrp.v2.MarkupType

         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

Examples of org.oasis.wsrp.v2.MarkupType

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

Examples of org.oasis.wsrp.v2.MarkupType

      if (windowStateNames.isEmpty())
      {
         throw new IllegalArgumentException("Cannot create a MarkupType with an empty list of windowStates!");
      }

      MarkupType markupType = new MarkupType();
      markupType.setMimeType(mimeType);

      if (ParameterValidation.existsAndIsNotEmpty(modeNames))
      {
         markupType.getModes().addAll(modeNames);
      }
      if (ParameterValidation.existsAndIsNotEmpty(windowStateNames))
      {
         markupType.getWindowStates().addAll(windowStateNames);
      }
      if (ParameterValidation.existsAndIsNotEmpty(localeNames))
      {
         markupType.getLocales().addAll(localeNames);
      }
      return markupType;
   }
View Full Code Here

Examples of org.oasis.wsrp.v2.MarkupType

      if (windowStateNames.isEmpty())
      {
         throw new IllegalArgumentException("Cannot create a MarkupType with an empty list of windowStates!");
      }

      MarkupType markupType = new MarkupType();
      markupType.setMimeType(mimeType);

      if (ParameterValidation.existsAndIsNotEmpty(modeNames))
      {
         markupType.getModes().addAll(modeNames);
      }
      if (ParameterValidation.existsAndIsNotEmpty(windowStateNames))
      {
         markupType.getWindowStates().addAll(windowStateNames);
      }
      if (ParameterValidation.existsAndIsNotEmpty(localeNames))
      {
         markupType.getLocales().addAll(localeNames);
      }
      return markupType;
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.