/* (non-Javadoc)
* @see org.apache.jetspeed.search.ObjectHandler#parseObject(java.lang.Object)
*/
public ParsedObject parseObject(Object o)
{
BaseParsedObject result = null;
if(o instanceof PortletDefinition)
{
result = new BaseParsedObject();
PortletDefinition pd = (PortletDefinition)o;
//need to get Locale here
String displayNameText = pd.getDisplayNameText(JetspeedLocale.getDefaultLocale());
result.setTitle(displayNameText);
String description = pd.getDescriptionText(JetspeedLocale.getDefaultLocale());
result.setDescription(description);
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(ParsedObject.ID, pd.getPortletName());
PortletApplication pa = (PortletApplication)pd.getApplication();
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
for (Description d : pd.getDescriptions())
{
fieldMap.put(ParsedObject.FIELDNAME_DESCRIPTION, d.getDescription());
}
//Handle keywords and titles
for (DisplayName d : pd.getDisplayNames())
{
fieldMap.put(ParsedObject.FIELDNAME_TITLE, d.getDisplayName());
}
HashSet keywordSet = new HashSet();
for (Language lang : pd.getLanguages())
{
fieldMap.put(ParsedObject.FIELDNAME_TITLE, lang.getTitle());
fieldMap.put(ParsedObject.FIELDNAME_TITLE, lang.getShortTitle());
for (String keyword : lang.getKeywordList())
{
keywordSet.add(keyword);
}
}
String[] temp = new String[keywordSet.size()];
result.setKeywords((String[])keywordSet.toArray(temp));
result.setFields(fieldMap);
}
return result;
}