// 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);
serviceDescription.setRegistrationPropertyDescription(registrationProperties);
serviceDescription.setRequiresRegistration(requireRegistrations);
// 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<String> knownPortletHandles = portletDescriptions.keySet();
Set<String> supportedLocales = new HashSet<String>(knownPortletHandles.size() * 2);
// if we asked for portlet decriptions, add them to the service description we will return
Collection<PortletDescription> portlets;
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 = portletDescriptions.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<EventDescription> events = eventDescriptions.values();
serviceDescription.getEventDescriptions().addAll(events);
return serviceDescription;
}