1 16 package org.apache.jetspeed.services.search.handlers; 17 18 import java.util.HashMap ; 20 import java.util.Iterator ; 21 22 import org.apache.jetspeed.om.registry.PortletEntry; 24 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService; 25 import org.apache.jetspeed.services.logging.JetspeedLogger; 26 import org.apache.jetspeed.services.search.ParsedObject; 27 import org.apache.jetspeed.om.registry.Category; 28 29 35 public class PortletEntryToDocHandler extends RegistryEntryToDocHandler 36 { 37 private static final String PARENT = "parent"; 38 private static final String TYPE = "type"; 39 40 { 41 fields.add(PARENT); 42 fields.add(TYPE); 43 } 44 45 48 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(PortletEntryToDocHandler.class.getName()); 49 50 56 public ParsedObject parseObject(Object o) 57 { 58 ParsedObject result = super.parseObject(o); 59 60 if ((o instanceof PortletEntry) == false) 61 { 62 logger.error("PortletEntryToDocHandler: invalid object type: " + o); 63 return null; 64 } 65 66 PortletEntry portletEntry = (PortletEntry) o; 67 68 HashMap fields = new HashMap (); 69 fields.put(PARENT, portletEntry.getParent()); 70 fields.put(TYPE, portletEntry.getType()); 71 72 result.setFields(fields); 73 74 StringBuffer content = new StringBuffer (); 75 String title = portletEntry.getTitle(); 76 content.append(title == null ? portletEntry.getName() : title); 77 content.append(" "); 78 content.append(portletEntry.getDescription()); 79 content.append(" "); 80 Iterator it = portletEntry.listCategories(); 81 while (it.hasNext()) 82 { 83 Category cat = (Category) it.next(); 84 content.append(cat.getName()); 85 content.append(" "); 86 } 87 88 result.setContent(content.toString()); 89 90 result.setType(ParsedObject.OBJECT_TYPE_PORTLET); 91 92 95 return result; 96 } 97 } 98 | Popular Tags |