//todo: we need to check that the user can actually modify the properties
Portlet portlet = getPortletFrom(portletContext, registration);
PortletInfo info = portlet.getInfo();
PropertyList result = WSRPTypeFactory.createPropertyList();
int propertyNb = properties.size();
if (propertyNb > 0)
{
PreferenceInfo prefInfo;
String key;
List<String> values;
LocalizedString displayName;
for (Map.Entry<String, List<String>> entry : properties.entrySet())
{
key = entry.getKey();
values = entry.getValue();
prefInfo = info.getPreferences().getPreference(key);
String lang = WSRPConstants.DEFAULT_LOCALE;
if (prefInfo != null)
{
displayName = prefInfo.getDisplayName();
if (displayName != null)
{
lang = WSRPUtils.toString(displayName.getDefaultLocale());
}
}
// todo: support multi-valued properties
if (values.size() != 1)
{
throw new UnsupportedOperationException("Currently doesn't support multi-valued properties!");
}
result.getProperties().add(WSRPTypeFactory.createProperty(key, lang, values.get(0))); //todo: check what we should use key
}
}
return result;
}