KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > services > search > handlers > PortletToDocHandler


1 /*
2  * Copyright 2000-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.jetspeed.services.search.handlers;
17
18 import org.apache.jetspeed.portal.Portlet;
19 import org.apache.jetspeed.services.rundata.JetspeedRunDataService;
20 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
21 import org.apache.jetspeed.services.logging.JetspeedLogger;
22 import org.apache.jetspeed.services.search.AbstractObjectHandler;
23 import org.apache.jetspeed.services.search.BaseParsedObject;
24 import org.apache.jetspeed.services.search.ParsedObject;
25
26 import org.apache.turbine.services.TurbineServices;
27 import org.apache.turbine.services.rundata.RunDataService;
28
29 /**
30  * This object handler deals with portlets
31  *
32  * @author <a HREF="mailto:caius1440@hotmail.com">Jeremy Ford</a>
33  * @version $Id: PortletToDocHandler.java,v 1.4 2004/02/23 03:47:46 jford Exp $
34  */

35 public class PortletToDocHandler extends AbstractObjectHandler
36 {
37     /**
38      * Static initialization of the logger for this class
39      */

40     private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(PortletToDocHandler.class.getName());
41     
42     /* (non-Javadoc)
43      * @see org.apache.jetspeed.services.search.ObjectHandler#parseObject(java.lang.Object)
44      */

45     public ParsedObject parseObject(Object JavaDoc o)
46     {
47         ParsedObject result = new BaseParsedObject();
48
49         if ((o instanceof Portlet) == false)
50         {
51             logger.error("PortletToDocHandler: invalid object type: " + o);
52             return null;
53         }
54
55         Portlet portlet = (Portlet) o;
56         
57         
58         JetspeedRunDataService rds = (JetspeedRunDataService) ((TurbineServices) TurbineServices.getInstance())
59                                                                                   .getResources(RunDataService.SERVICE_NAME);
60         result.setContent(portlet.getContent(rds.getCurrentRunData()).toString());
61         result.setDescription(portlet.getDescription());
62         result.setType(this.getClass().getName());
63         //result.setFields();
64
result.setKey(portlet.getName());
65         //result.setKeywords();
66
//result.setLanguage();
67
result.setTitle(portlet.getTitle());
68         //result.setURL();
69

70         return result;
71     }
72 }
73
Popular Tags