Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, a division of Red Hat
   * Copyright 2011, Red Hat Middleware, LLC, and individual
   * contributors as indicated by the @authors tag. See the
   * copyright.txt in the distribution for a full listing of
   * individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 
 package org.gatein.wsrp.producer.handlers;
 
 
 import java.util.List;
 import java.util.Map;
 import java.util.Set;

Handles service description calls on behalf of the producer. Implements org.gatein.pc.portlet.container.managed.ManagedObjectRegistryEventListener to listen to portlet deployment operations to be able to update the service description accordingly.

Author(s):
Chris Laprun
Version:
$Revision: 12017 $
Since:
2.4
 
 {
    // JBPORTAL-1220: force call to initCookie... Required so that BEA version < 9.2 will behave properly as a Consumer
    private static final CookieProtocol BEA_8_CONSUMER_FIX = .;
   
Stores service description so that we don't constantly need to regenerate it on each call.
   private static final List<StringOPTIONS = new ArrayList<String>(5);
   static
   {
   }
   {
      super(producer);
      reset();
   }
   {
      WSRP2ExceptionFactory.throwOperationFailedIfValueIsMissing(gs"GetServiceDescription");
      try
      {
         // if a RegistrationContext is provided, we need to validate the registration information
         RegistrationContext registrationContext = gs.getRegistrationContext();
         Registration registration = null;
         if (registrationContext != null)
         {
            registration = .getRegistrationOrFailIfInvalid(registrationContext);
            RegistrationLocal.setRegistration(registration);
         }
         //update the registration properties with the registration requirements
         .updateRegistrationProperties(requirements);
         // if we don't have registration information but a registration is required, send registration props information
         boolean needsRegistrationProperties = registration == null && requirements.isRegistrationRequired();
         // if we allow sending portlet descriptions even when not registered
         boolean needsPortletDescriptions = !(registration == null && requirements.isRegistrationRequired()
            && requirements.isRegistrationRequiredForFullDescription());
         final List<StringportletHandles = WSRPUtils.replaceByEmptyListIfNeeded(gs.getPortletHandles());
         final List<StringdesiredLocales = WSRPUtils.replaceByEmptyListIfNeeded(gs.getDesiredLocales());
         return .getServiceDescription(needsRegistrationPropertiesneedsPortletDescriptionsportletHandlesdesiredLocales);
      }
      finally
      {
         RegistrationLocal.setRegistration(null);
      }
   }

   
Creates a PortletDescription based on the user desired locales (ordered according to user preferences) for the specified component.

Parameters:
portletContext the PortletContext of the portlet for which a PortletDescription is needed
desiredLocales the user desired locales (ordered according to user preferences) to use for the description
Returns:
a PortletDescription describing the specified portlet
   public PortletDescription getPortletDescription(PortletContext portletContextList<StringdesiredLocalesRegistration registrationthrows InvalidHandleOperationFailed
   {
      ParameterValidation.throwIllegalArgExceptionIfNull(portletContext"portlet context");
      final PortletDescription description = .getPortletDescription(portletContextdesiredLocalesregistration);
      if (description == null)
      {
         throw WSRP2ExceptionFactory.throwWSException(InvalidHandle.class"Couldn't find portlet '" + portletContext.getPortletHandle() + "'. Check that it's properly deployed."null);
      }
      return description;
   }

   
Listens to portlet deployment events and updates the service description accordingly.

Parameters:
event
   public void onEvent(ManagedObjectRegistryEvent event)
   {
      if (event instanceof ManagedObjectEvent)
      {
         ManagedObjectEvent managedObjectEvent = (ManagedObjectEvent)event;
         ManagedObject managedObject = managedObjectEvent.getManagedObject();
         // we're only interested in portlet events
         if (managedObject instanceof ManagedPortletContainer)
         {
            ManagedPortletContainer portletContainer = (ManagedPortletContainer)managedObject;
            String applicationId = portletContainer.getManagedPortletApplication().getId();
            String containerId = portletContainer.getId();
            org.gatein.pc.api.PortletContext pc = org.gatein.pc.api.PortletContext.createPortletContext(applicationIdcontainerId);
            // and more specifically, their lifecycle eventds
            if (managedObjectEvent instanceof ManagedObjectLifeCycleEvent)
            {
               ManagedObjectLifeCycleEvent lifeCycleEvent = (ManagedObjectLifeCycleEvent)managedObjectEvent;
               LifeCycleStatus status = lifeCycleEvent.getStatus();
               if (..equals(status))
               {
                  // if the portlet started, add it to the service description
                  final PortletInfo info = portletContainer.getInfo();
                  // but only if it's remotable
                  if (isRemotable(info.getRuntimeOptionsInfo()))
                  {
                     .addPortletDescription(pcinfo);
                  }
               }
               else
               {
                  // otherwise, remove the description of the portlet
                  .removePortletDescription(pc);
               }
            }
         }
      }
   }

   
Retrieves the WSRP-friendly names for the specified Locales.

Parameters:
locales the Locales we want to get the WSRP-friendly versions
Returns:
   private static List<StringgetLocaleNamesFrom(Collection<Localelocales)
   {
      if (locales == null || locales.isEmpty())
      {
         return null;
      }
      List<StringlocaleNames = new ArrayList<String>(locales.size());
      for (Locale locale : locales)
      {
         localeNames.add(WSRPUtils.toString(locale));
      }
      return localeNames;
   }
   private static List<StringgetWindowStateNamesFrom(Collection<WindowStateInfowindowStates)
   {
      List<Stringresult = new ArrayList<String>(windowStates.size());
      for (WindowStateInfo windowStateInfo : windowStates)
      {
         result.add(WSRPUtils.convertJSR168WindowStateNameToWSRPName(windowStateInfo.getWindowStateName()));
      }
      return result;
   }
   private static List<StringgetModeNamesFrom(Collection<ModeInfomodes)
   {
      List<Stringresult = new ArrayList<String>(modes.size());
      for (ModeInfo modeInfo : modes)
      {
         result.add(WSRPUtils.convertJSR168PortletModeNameToWSRPName(modeInfo.getModeName()));
      }
      return result;
   }

   
Resets the service description to its original, pristine state
   public void reset()
   {
   }

   
Whether the specified runtime options contains the remotable option.

Parameters:
runtimeOptions
Returns:
   public boolean isRemotable(Map<StringRuntimeOptionInforuntimeOptions)
   {
      RuntimeOptionInfo runtimeOptionInfo = runtimeOptions.get(.);
      return runtimeOptionInfo != null && "true".equals(runtimeOptionInfo.getValues().get(0));
   }

   
Stores all service description related metadata so that we don't constantly need to re-generate it on each call.
   private class ServiceDescriptionInfo
   {
      
When were we last generated?
      private long lastGenerated;
      
Event descriptions
      private Map<QNameEventDescriptioneventDescriptions;
      
Since events can be declared by several portlets, we need to have a reference counting mechanism on event descriptions so that we can ensure that, when a portlet is removed, we only remove the related event description if and only if no other portlets reference it.
      private Map<QNameIntegereventReferenceCount;
      
Portlet descriptions
      private Map<StringPortletDescriptionInfoportletDescriptions;
      
Registration properties
      private ModelDescription registrationProperties;
      
Whether we've already been initialized or not
      private boolean initialized = false;
      
Does the associated producer require registration?
      private boolean requireRegistrations;
      private ServiceDescriptionInfo()
      {
         reset();
      }

      
Resets all metadata.
      void reset()
      {
          = 0;
          = new HashMap<QNameEventDescription>(37);
          = new HashMap<QNameInteger>(37);
          = new HashMap<StringPortletDescriptionInfo>(37);
          = null;
          = false;
          = false;
      }

      
Updates the held registration properties based on the new specified producer registration requirements.

Parameters:
requirements the newly specified registration requirements from which we want to update
      private void updateRegistrationProperties(ProducerRegistrationRequirements requirements)
      {
         // only update our information if the new requirements are posterior to our last modification, since, presumably, we updated them at that time
         long lastModified = requirements.getLastModified();
         if (lastModified > )
         {
            if (.isDebugEnabled())
            {
               .debug("Re-generating registration properties information for service description.");
            }
            // do not create a ModelDescription if there is no registration properties
            Map<QNameRegistrationPropertyDescriptioninfo = requirements.getRegistrationProperties();
            if (ParameterValidation.existsAndIsNotEmpty(info))
            {
                = Utils.convertRegistrationPropertiesToModelDescription(info);
            }
            else
            {
                = null;
            }
            // update need to register
             = requirements.isRegistrationRequired();
            // we just got re-generated
             = SupportsLastModified.now();
         }
      }

      
Updates portlet descriptions from the set of remotable portlets known by the associated producer.
      private void updatePortletDescriptions()
      {
         try
         {
            Set<Portletportlets = .getRemotablePortlets();
            if (ParameterValidation.existsAndIsNotEmpty(portlets))
            {
               for (Portlet portlet : portlets)
               {
                  addPortletDescription(portlet.getContext(), portlet.getInfo());
               }
            }
             = true;
         }
         catch (PortletInvokerException e)
         {
            .warn("Couldn't get remotable portlets"e);
         }
      }

      
Retrieves a ServiceDescription instance ready to be sent to the consumer with the specified information.

Parameters:
needsRegistrationProperties do we want to include registration properties?
needsPortletDescriptions do we want to include portlet descriptions?
portletHandles list of portlet handles that we only want to include in the service description
desiredLocales desired locales for which the service description should be adapted along a best effort policy
Returns:
a ServiceDescription instance ready to be sent to the consumer with the specified information.
      private ServiceDescription getServiceDescription(boolean needsRegistrationPropertiesboolean needsPortletDescriptionsList<StringportletHandlesList<StringdesiredLocales)
      {
         // initialize if needed
         initIfNeeded();
         // only add registration properties if we asked for them
         ModelDescription registrationProperties = needsRegistrationProperties ? this. : null;
         // set the service description details
         ServiceDescription serviceDescription = WSRPTypeFactory.createServiceDescription(false);
         serviceDescription.setRequiresInitCookie();
         serviceDescription.getSupportedOptions().addAll();
         serviceDescription.setRegistrationPropertyDescription(registrationProperties);
         serviceDescription.setRequiresRegistration();
         // init supported locales. Note that this doesn't mean that all portlets support all these languages but rather that at least one portlet supports at least one of these languages.
         final Set<StringknownPortletHandles = .keySet();
         Set<StringsupportedLocales = new HashSet<String>(knownPortletHandles.size() * 2);
         // if we asked for portlet decriptions, add them to the service description we will return
         Collection<PortletDescriptionportlets;
         if (needsPortletDescriptions)
         {
            // if we don't have a list of portlet handles, select all of them
            if (!ParameterValidation.existsAndIsNotEmpty(portletHandles))
            {
               portletHandles = new ArrayList<String>(knownPortletHandles);
            }
            // for each selected portlet
            portlets = new ArrayList<PortletDescription>(portletHandles.size());
            for (String handle : portletHandles)
            {
               // retrieve the associated description
               PortletDescriptionInfo descriptionInfo = .get(handle);
               if (descriptionInfo != null)
               {
                  // add the languages that the portlet supports to the set of supported languages
                  supportedLocales.addAll(descriptionInfo.getSupportedLanguages());
                  // and add the best-effort localized description for this portlet based on the locales the consumer asked for
                  portlets.add(descriptionInfo.getBestDescriptionFor(desiredLocales));
               }
            }
            serviceDescription.getOfferedPortlets().addAll(portlets);
         }
         serviceDescription.getLocales().addAll(supportedLocales);
         // events
         Collection<EventDescriptionevents = .values();
         serviceDescription.getEventDescriptions().addAll(events);
         return serviceDescription;
      }

      
Initializes this service description if we were not already
      private void initIfNeeded()
      {
         if (!)
         {
            updatePortletDescriptions();
         }
      }

      
Adds the specified event metadata in the specified locale

Parameters:
info
locale
      private void addEventInfo(EventInfo infoLocale locale)
      {
         QName name = info.getName();
         if (!.containsKey(name))
         {
            EventDescription desc = WSRPTypeFactory.createEventDescription(name);
            desc.setDescription(Utils.convertToWSRPLocalizedString(info.getDescription(), locale));
            desc.setLabel(Utils.convertToWSRPLocalizedString(info.getDisplayName(), locale));
            Collection<QNamealiases = info.getAliases();
            if (ParameterValidation.existsAndIsNotEmpty(aliases))
            {
               desc.getAliases().addAll(aliases);
            }
            // todo: deal with type info...
            .put(namedesc);
            .put(name, 1);
         }
         else
         {
            Integer current = .get(name);
            .put(namecurrent + 1); // increase reference count
         }
      }

      
Removes the even information associated with the specified QName

Parameters:
name the name of the event which information we want to remove
      private void removeEvent(QName name)
      {
         // retrieve the reference count for this event
         Integer current = .get(name);
         if (current != null)
         {
            if (current == 1)
            {
               // only remove the even description if we only have one reference to it left
               .remove(name);
               .remove(name);
            }
            else
            {
               // otherwise, simply decrease the reference count for that event
               .put(namecurrent - 1);
            }
         }
      }
      private void addPortletDescription(org.gatein.pc.api.PortletContext contextPortletInfo info)
      {
         String handle = context.getId();
         PortletDescriptionInfo desc = createPortletDescription(infohandle);
         .put(handledesc);
      }

      
Creates the portlet description metadata associated with the specified portlet.

Parameters:
info the portlet metadata from the portlet container
handle the portlet handle of the portlet for which we want to create the metadata
Returns:
the metadata for the portlet
      {
         if (.isDebugEnabled())
         {
            .debug("Constructing portlet description for: " + handle);
         }
         // supported MIME types, modes, window states and locales
         CapabilitiesInfo capInfo = info.getCapabilities();
         Collection<MediaTypeallMediaTypes = capInfo.getMediaTypes();
         List<MarkupTypemarkupTypes = 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);
         }
         // prepare languages for which we will generated a portlet description
         Set<LocalesupportedLocales = info.getCapabilities().getAllLocales();
         List<StringsupportedLanguages;
         if (supportedLocales.size() == 0)
         {
            // if the portlet doesn't specify supported languages, use English as failback per PLT.25.8.1
            supportedLocales = Collections.singleton(.);
            supportedLanguages = Collections.singletonList("en");
         }
         else
         {
            supportedLanguages = WSRPUtils.convertLocalesToRFC3066LanguageTags(new ArrayList<Locale>(supportedLocales));
         }
         PortletDescriptionInfo descriptionInfo = .get(handle);
         if (descriptionInfo == null)
         {
            descriptionInfo = new PortletDescriptionInfo(supportedLanguages);
            .put(handledescriptionInfo);
         }
         // iterate over locales and create a portlet description for each
         MetaInfo metaInfo = info.getMeta();
         for (Locale localeMatch : supportedLocales)
         {
            PortletDescription desc = WSRPTypeFactory.createPortletDescription(handlemarkupTypes);
            // group ID
            desc.setGroupID(info.getApplicationName());
            // description
            desc.setDescription(Utils.convertToWSRPLocalizedString(metaInfo.getMetaValue(.), localeMatch));
            // short title
            desc.setShortTitle(Utils.convertToWSRPLocalizedString(metaInfo.getMetaValue(.), localeMatch));
            // title
            desc.setTitle(Utils.convertToWSRPLocalizedString(metaInfo.getMetaValue(.), localeMatch));
            // display name
            desc.setDisplayName(Utils.convertToWSRPLocalizedString(metaInfo.getMetaValue(.), localeMatch));
            // keywords
            // metaInfo contains comma-separated keywords: we need to extract them into a list
            org.oasis.wsrp.v2.LocalizedString concatenatedKeywords = Utils.convertToWSRPLocalizedString(metaInfo.getMetaValue(.), localeMatch);
            if (concatenatedKeywords != null)
            {
               String commaSeparatedKeywords = concatenatedKeywords.getValue();
               if (commaSeparatedKeywords != null && commaSeparatedKeywords.length() > 0)
               {
                  String lang = concatenatedKeywords.getLang();
                  String[] keywordArray = commaSeparatedKeywords.split(",");
                  for (String keyword : keywordArray)
                  {
                     // todo: fix resource name
                     desc.getKeywords().add(WSRPTypeFactory.createLocalizedString(langconcatenatedKeywords.getResourceName(), keyword.trim()));
                  }
               }
            }
            // events
            EventingInfo eventsInfo = info.getEventing();
            if (eventsInfo != null)
            {
               // produced events are mapped to published events in wsrp
               Map<QName, ? extends EventInfoproducedEvents = eventsInfo.getProducedEvents();
               if (ParameterValidation.existsAndIsNotEmpty(producedEvents))
               {
                  List<QNamepublishedEvents = desc.getPublishedEvents();
                  for (Map.Entry<QName, ? extends EventInfoentry : producedEvents.entrySet())
                  {
                     publishedEvents.add(entry.getKey());
                     addEventInfo(entry.getValue(), localeMatch);
                  }
               }
               // consumed events -> handled events in wsrp
               Map<QName, ? extends EventInfoconsumedEvents = eventsInfo.getConsumedEvents();
               if (ParameterValidation.existsAndIsNotEmpty(consumedEvents))
               {
                  List<QNamehandledEvents = desc.getHandledEvents();
                  for (Map.Entry<QName, ? extends EventInfoentry : consumedEvents.entrySet())
                  {
                     handledEvents.add(entry.getKey());
                     addEventInfo(entry.getValue(), localeMatch);
                  }
               }
            }
            // public parameters
            NavigationInfo navigationInfo = info.getNavigation();
            if (navigationInfo != null)
            {
               Collection<? extends ParameterInfoparameterInfos = navigationInfo.getPublicParameters();
               if (ParameterValidation.existsAndIsNotEmpty(parameterInfos))
               {
                  List<ParameterDescriptionpublicValueDescriptions = 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<QNamenames = paramDesc.getNames();
                     names.add(parameterInfo.getName());
                     Collection<QNamealiases = parameterInfo.getAliases();
                     if (ParameterValidation.existsAndIsNotEmpty(aliases))
                     {
                        names.addAll(aliases);
                     }
                     publicValueDescriptions.add(paramDesc);
                  }
               }
            }
            // security
            SecurityInfo secInfo = info.getSecurity();
            if (secInfo.containsTransportGuarantee(.)
               || secInfo.containsTransportGuarantee(.))
            {
               desc.setOnlySecure(true);
            }
            // add the portlet description to the appropriate PortletDescriptionInfo
            descriptionInfo.addDescriptionFor(WSRPUtils.toString(localeMatch), desc);
         }
         /* todo:
         *[O]ID portletID
         *[O]string userCategories[]
         *[O]string userProfileItems[]
         *[O]string portletManagedModes[]
         *[O]boolean usesMethodGet
         *[O]boolean defaultMarkupSecure
         *[O]boolean userContextStoredInSession
         *[O]boolean templatesStoredInSession
         *[O]boolean hasUserSpecificState
         *[O]boolean doesUrlTemplateProcessing
         *[O]boolean mayReturnPortletState
         *[O]Extension extensions[]
         */
         return descriptionInfo;
      }

      
Retrieves the PortletDescription associated to the specified PortletContext with metadata using the desired locales, scoped to the specified Registration.

Parameters:
context the PortletContext identifying the portlet we want to retrieve the description of
desiredLocales the locales from which we are ready to accept a description
registration the Registration associated with the calling consumer
Returns:
the description associated to the specified portlet or null if no such portlet exists or if the org.gatein.registration.RegistrationPolicy associated with the producer doesn't allow access to the portlet description for the specified registration
      public PortletDescription getPortletDescription(PortletContext contextList<StringdesiredLocalesRegistration registration)
      {
         initIfNeeded();
         org.gatein.pc.api.PortletContext pcContext = WSRPUtils.convertToPortalPortletContext(context);
         // does the specified registration allow access to the specified portlet?
         if (.getRegistrationManager().getPolicy().allowAccessTo(pcContextregistration"getPortletDescription"))
         {
            PortletDescription description = getPortletDescription(context.getPortletHandle(), desiredLocales);
            // the producer doesn't know of the portlet so it's not a producer-offered portlet
            if (description == null)
            {
               // however, it might be a clone so check if the registration knows of a clone with that portlet context
               if (registration.knows(pcContext))
               {
                  try
                  {
                     // clones have the same metadata as original portlets so retrieve initial context from portlet info and get description from it
                     Portlet portlet = .getPortletWith(pcContextregistration);
                     PortletInfo info = portlet.getInfo();
                     org.gatein.pc.api.PortletContext original = org.gatein.pc.api.PortletContext.createPortletContext(info.getApplicationName(), info.getName());
                     return getPortletDescription(original.getId(), desiredLocales);
                  }
                  catch (Exception e)
                  {
                     .debug("Couldn't retrieve portlet " + pcContexte);
                     return null;
                  }
               }
            }
            return description;
         }
         else
         {
            return null;
         }
      }
      private PortletDescription getPortletDescription(final String portletHandleList<StringdesiredLocales)
      {
         PortletDescriptionInfo descriptionInfo = .get(portletHandle);
         if (descriptionInfo != null)
         {
            return descriptionInfo.getBestDescriptionFor(desiredLocales);
         }
         else
         {
            return null;
         }
      }

      
Removes the description for the portlet identified by the specified context

Parameters:
pc
      {
         String handle = WSRPUtils.convertToWSRPPortletContext(pc).getPortletHandle();
         PortletDescription description = getPortletDescription(handlenull);
         if (description != null)
         {
            // remove associated events
            for (QName event : description.getHandledEvents())
            {
               removeEvent(event);
            }
            for (QName event : description.getPublishedEvents())
            {
               removeEvent(event);
            }
            .remove(handle);
         }
      }

      
Records the description for each supported languages for a given portlet. These are generated only once when the associated portlets are added so that we only need to filter the proper information when we return a service description to the consumer.
      private class PortletDescriptionInfo
      {
         
Associates a language to a portlet description
         private Map<StringPortletDescriptionlanguageToDescription;
         private PortletDescriptionInfo(List<StringsupportedLanguages)
         {
             = new HashMap<StringPortletDescription>(supportedLanguages.size());
            for (String supportedLanguage : supportedLanguages)
            {
               .put(supportedLanguagenull);
            }
         }

         
Retrieves a Set of all supported languages by the portlet.

Returns:
a Set of languages by the associated portlet
         public Set<StringgetSupportedLanguages()
         {
            return .keySet();
         }

         
Retrieves the best description for the specified languages based on what the portlet supports.

Parameters:
desiredLanguages a List of ordered (most desired first) languages for which we're willing to accept a description for the associated portlet
Returns:
         public PortletDescription getBestDescriptionFor(List<StringdesiredLanguages)
         {
            String language = null;
            Set<StringsupportedLanguages = getSupportedLanguages();
            if (desiredLanguages != null && !desiredLanguages.isEmpty())
            {
               // check first if we have an exact match
               for (String languageTag : desiredLanguages)
               {
                  if (supportedLanguages.contains(languageTag))
                  {
                     language = languageTag;
                     break// exit loop as soon as we've found a match
                  }
               }
               // if we haven't found an exact match, check if we can find a partial match based on country
               if (language == null)
               {
                  for (String desiredLanguage : desiredLanguages)
                  {
                     for (String supportedLanguage : supportedLanguages)
                     {
                        if (supportedLanguage.startsWith(desiredLanguage))
                        {
                           language = supportedLanguage;
                           break// exit loop as soon as we've found a match
                        }
                     }
                  }
               }
            }
            if (language == null)
            {
               // if we still haven't determined a language, use the first available one
               for (String supportedLanguage : supportedLanguages)
               {
                  language = supportedLanguage;
                  break;
               }
            }
            return .get(language);
         }

         
Adds the specified portlet description for the specified language.

Parameters:
language the language for which we're adding a description
desc the portlet description to associate to the specified language
         public void addDescriptionFor(String languagePortletDescription desc)
         {
            .put(languagedesc);
         }
      }
   }
New to GrepCode? Check out our FAQ X