1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.portal.portlets;
18
19 import org.apache.jetspeed.om.profile.ProfileLocator;
20 import org.apache.jetspeed.services.Profiler;
21 import org.apache.jetspeed.om.profile.Profile;
22 import org.apache.jetspeed.om.profile.PSMLDocument;
23 import org.apache.jetspeed.om.profile.Portlets;
24 import org.apache.jetspeed.services.PortalToolkit;
25 import org.apache.jetspeed.portal.PortletSet;
26 import org.apache.jetspeed.services.rundata.JetspeedRunData;
27 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
28 import org.apache.jetspeed.services.logging.JetspeedLogger;
29 import org.apache.jetspeed.util.JetspeedClearElement;
30
31 import org.apache.ecs.ConcreteElement;
32
33 import org.apache.turbine.util.RunData;
34
35 /***
36 Aggregate Portlet aggregates the content of other portlets.
37
38 This portlet is a test for an alternate aggregation algorithm (from getSet)
39
40 @author <A HREF="mailto:taylor@apache.org">David Sean Taylor</A>
41 @version $Id: AggregatePortlet.java,v 1.8 2004/02/23 04:03:34 jford Exp $
42 */
43
44 public class AggregatePortlet extends AbstractPortlet
45 {
46
47 /***
48 * Static initialization of the logger for this class
49 */
50 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(AggregatePortlet.class.getName());
51
52 /***
53 Returns an HTML representation of this portlet. Usually a Portlet would
54 initialized itself within init() and then when getContent is called it
55 would return its presentation.
56 */
57 public ConcreteElement getContent(RunData rundata)
58 {
59 String key = ((JetspeedRunData)rundata).getProfile().getId()
60 + "." + this.getID();
61
62 String path = (String)rundata.getUser().getTemp(key);
63 if (path == null)
64 {
65 path = this.getPortletConfig().getInitParameter("path");
66 }
67
68 if (null == path)
69 {
70 return new JetspeedClearElement("Path parameter not set");
71 }
72 ProfileLocator locator = Profiler.createLocator();
73 locator.createFromPath(path);
74 String id = locator.getId();
75
76 try
77 {
78 Profile profile = Profiler.getProfile(locator);
79 PSMLDocument doc = profile.getDocument();
80
81 if (doc == null)
82 {
83 return null;
84 }
85 Portlets portlets = doc.getPortlets();
86 PortletSet ps = PortalToolkit.getSet(portlets);
87 return ps.getContent(rundata);
88 }
89 catch (Exception e)
90 {
91 logger.error("Exception", e);
92 return new JetspeedClearElement("Error in aggregation portlet: " + e.toString());
93 }
94 }
95
96
97
98 }