// iterate over locales and create a portlet description for each
MetaInfo metaInfo = info.getMeta();
for (Locale localeMatch : supportedLocales)
{
PortletDescription desc = WSRPTypeFactory.createPortletDescription(handle, markupTypes);
// group ID
desc.setGroupID(info.getApplicationName());
// description
desc.setDescription(Utils.convertToWSRPLocalizedString(metaInfo.getMetaValue(MetaInfo.DESCRIPTION), localeMatch));
// short title
desc.setShortTitle(Utils.convertToWSRPLocalizedString(metaInfo.getMetaValue(MetaInfo.SHORT_TITLE), localeMatch));
// title
desc.setTitle(Utils.convertToWSRPLocalizedString(metaInfo.getMetaValue(MetaInfo.TITLE), localeMatch));
// display name
desc.setDisplayName(Utils.convertToWSRPLocalizedString(metaInfo.getMetaValue(MetaInfo.DISPLAY_NAME), 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(MetaInfo.KEYWORDS), 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(lang, concatenatedKeywords.getResourceName(), keyword.trim()));
}
}
}
// events
EventingInfo eventsInfo = info.getEventing();
if (eventsInfo != null)
{
// produced events are mapped to published events in wsrp
Map<QName, ? extends EventInfo> producedEvents = eventsInfo.getProducedEvents();
if (ParameterValidation.existsAndIsNotEmpty(producedEvents))
{
List<QName> publishedEvents = desc.getPublishedEvents();
for (Map.Entry<QName, ? extends EventInfo> entry : producedEvents.entrySet())
{
publishedEvents.add(entry.getKey());
addEventInfo(entry.getValue(), localeMatch);
}
}
// consumed events -> handled events in wsrp
Map<QName, ? extends EventInfo> consumedEvents = eventsInfo.getConsumedEvents();
if (ParameterValidation.existsAndIsNotEmpty(consumedEvents))
{
List<QName> handledEvents = desc.getHandledEvents();
for (Map.Entry<QName, ? extends EventInfo> entry : consumedEvents.entrySet())
{
handledEvents.add(entry.getKey());
addEventInfo(entry.getValue(), localeMatch);
}
}
}
// public parameters
NavigationInfo navigationInfo = info.getNavigation();
if (navigationInfo != null)
{
Collection<? extends ParameterInfo> parameterInfos = navigationInfo.getPublicParameters();
if (ParameterValidation.existsAndIsNotEmpty(parameterInfos))
{
List<ParameterDescription> publicValueDescriptions = 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<QName> names = paramDesc.getNames();
names.add(parameterInfo.getName());
Collection<QName> aliases = parameterInfo.getAliases();
if (ParameterValidation.existsAndIsNotEmpty(aliases))
{
names.addAll(aliases);
}
publicValueDescriptions.add(paramDesc);
}
}
}
// security
SecurityInfo secInfo = info.getSecurity();
if (secInfo.containsTransportGuarantee(TransportGuarantee.INTEGRAL)
|| secInfo.containsTransportGuarantee(TransportGuarantee.CONFIDENTIAL))
{
desc.setOnlySecure(true);
}
// add the portlet description to the appropriate PortletDescriptionInfo
descriptionInfo.addDescriptionFor(WSRPUtils.toString(localeMatch), desc);
}