result.setClassName(pd.getClass().getName());
result.setKey(KEY_PREFIX + pd.getUniqueName());
result.setType(ParsedObject.OBJECT_TYPE_PORTLET);
//TODO: this is common to PAs as well, possible refactor
MultiHashMap fieldMap = new MultiHashMap();
fieldMap.put(ID, pd.getName());
PortletApplication pa = (PortletApplication)pd.getPortletApplicationDefinition();
fieldMap.put(PORTLET_APPLICATION, pa.getName());
Collection mdFields = pd.getMetadata().getFields();
for (Iterator fieldIter = mdFields.iterator(); fieldIter.hasNext();)
{
LocalizedField field = (LocalizedField) fieldIter.next();
fieldMap.put(field.getName(), field.getValue());
}
//Handle descriptions
Iterator descIter = pd.getDescriptionSet().iterator();
while (descIter.hasNext())
{
Description desc = (Description) descIter.next();
fieldMap.put(ParsedObject.FIELDNAME_DESCRIPTION, desc.getDescription());
}
//Handle keywords and titles
Iterator displayNameIter = pd.getDisplayNameSet().iterator();
while (displayNameIter.hasNext())
{
DisplayName displayName = (DisplayName) displayNameIter.next();
fieldMap.put(ParsedObject.FIELDNAME_TITLE, displayName.getDisplayName());
}
HashSet keywordSet = new HashSet();
Iterator langIter = pd.getLanguageSet().iterator();
while (langIter.hasNext())
{
Language lang = (Language) langIter.next();
fieldMap.put(ParsedObject.FIELDNAME_TITLE, lang.getTitle());
fieldMap.put(ParsedObject.FIELDNAME_TITLE, lang.getShortTitle());
Iterator keywordIter = lang.getKeywords();
if (keywordIter != null)
{
while (keywordIter.hasNext())