1/*2 * Copyright 2000-2001,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 at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.portal.portlets;
1819import org.apache.jetspeed.om.profile.ProfileLocator;
20import org.apache.jetspeed.services.Profiler;
21import org.apache.jetspeed.om.profile.Profile;
22import org.apache.jetspeed.om.profile.PSMLDocument;
23import org.apache.jetspeed.om.profile.Portlets;
24import org.apache.jetspeed.services.PortalToolkit;
25import org.apache.jetspeed.portal.PortletSet;
26import org.apache.jetspeed.services.rundata.JetspeedRunData;
27import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
28import org.apache.jetspeed.services.logging.JetspeedLogger;
29import org.apache.jetspeed.util.JetspeedClearElement;
3031import org.apache.ecs.ConcreteElement;
3233import org.apache.turbine.util.RunData;
3435/***36 Aggregate Portlet aggregates the content of other portlets.3738 This portlet is a test for an alternate aggregation algorithm (from getSet)3940 @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*/4344publicclassAggregatePortletextendsAbstractPortlet45 {
4647/***48 * Static initialization of the logger for this class49 */50privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(AggregatePortlet.class.getName());
5152/***53 Returns an HTML representation of this portlet. Usually a Portlet would54 initialized itself within init() and then when getContent is called it55 would return its presentation.56 */57public ConcreteElement getContent(RunData rundata)
58 {
59 String key = ((JetspeedRunData)rundata).getProfile().getId()
60 + "." + this.getID();
6162 String path = (String)rundata.getUser().getTemp(key);
63if (path == null)
64 {
65 path = this.getPortletConfig().getInitParameter("path");
66 }
6768if (null == path)
69 {
70returnnewJetspeedClearElement("Path parameter not set");
71 }
72ProfileLocator locator = Profiler.createLocator();
73 locator.createFromPath(path);
74 String id = locator.getId();
7576try77 {
78Profile profile = Profiler.getProfile(locator);
79PSMLDocument doc = profile.getDocument();
8081if (doc == null)
82 {
83returnnull;
84 }
85Portlets portlets = doc.getPortlets();
86PortletSet ps = PortalToolkit.getSet(portlets);
87return ps.getContent(rundata);
88 }
89catch (Exception e)
90 {
91 logger.error("Exception", e);
92returnnewJetspeedClearElement("Error in aggregation portlet: " + e.toString());
93 }
94 }
95969798 }