KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > portal > portlets > ApplicationsPortlet


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
17 package org.apache.jetspeed.portal.portlets;
18
19 //Element Construction Set
20
import org.apache.ecs.html.A;
21 import org.apache.ecs.html.Table;
22 import org.apache.ecs.html.TD;
23 import org.apache.ecs.html.TR;
24 import org.apache.ecs.ConcreteElement;
25
26 //Jetspeed stuff
27
import org.apache.jetspeed.portal.Portlet;
28 import org.apache.jetspeed.portal.PortletConfig;
29 import org.apache.jetspeed.portal.PortletException;
30 import org.apache.jetspeed.portal.PortletURIManager;
31 import org.apache.jetspeed.services.PortletFactory;
32 import org.apache.jetspeed.services.Registry;
33 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
34 import org.apache.jetspeed.services.logging.JetspeedLogger;
35 import org.apache.jetspeed.om.registry.PortletEntry;
36
37 //turbine
38
import org.apache.turbine.util.RunData;
39
40 //standard java stuff
41
import java.util.*;
42
43 /**
44  * Handles enumerating Portlets that are also applications
45  *
46  * @author <a HREF="mailto:burton@apache.org">Kevin A. Burton</a>
47  * @author <a HREF="mailto:sgala@hisitech.com">Santiago Gala</a>
48  * @version $Id: ApplicationsPortlet.java,v 1.39 2004/02/23 04:03:34 jford Exp $
49  */

50 public class ApplicationsPortlet extends AbstractPortlet
51 {
52
53     /**
54      * Static initialization of the logger for this class
55      */

56     private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(ApplicationsPortlet.class.getName());
57     
58     /* SGP: here we cache Applications */
59     private Vector applications = new Vector();
60
61     /**
62     */

63     public void init() throws PortletException
64     {
65
66         PortletConfig config = this.getPortletConfig();
67
68         this.setTitle( "Applications" );
69         this.setDescription( "A list of Applications that are installed within Jetspeed" );
70
71         logger.info( "Jetspeed: initializing the ApplicationsPortlet: BEGIN " );
72
73         Enumeration portlets = Registry.get( Registry.PORTLET ).getEntries();
74
75         while ( portlets.hasMoreElements() ) {
76
77             PortletEntry entry = (PortletEntry)portlets.nextElement();
78
79             if ( entry.isApplication() )
80             {
81                 applications.addElement(entry);
82             }
83         }
84
85         logger.info( "Jetspeed: initializing the ApplicationsPortlet: END " );
86
87     }
88
89     /**
90     */

91     public ConcreteElement getContent( RunData data ) {
92
93         Table table = new Table();
94         Enumeration portlets = applications.elements();
95
96         while ( portlets.hasMoreElements() ) {
97
98             PortletEntry entry = (PortletEntry)portlets.nextElement();
99             
100             String JavaDoc url = PortletURIManager.getPortletMaxURI( entry, data ).toString();
101             Portlet portlet = null;
102             try {
103                 portlet = PortletFactory.getPortlet(entry.getName(), "0");
104             } catch (PortletException e) {
105                 continue;
106             }
107             A anchor = new A( url ).addElement( portlet.getTitle() );
108             table.addElement( new TR().addElement( new TD().addElement( anchor ) ) );
109             table.addElement( new TR().addElement( new TD().addElement( portlet.getDescription() ) ) );
110         }
111
112         return table;
113
114     }
115
116
117     public boolean getAllowEdit( RunData rundata ) {
118         return false;
119     }
120
121     public boolean getAllowMaximize( RunData rundata ) {
122         return true;
123     }
124
125
126 }
127
Popular Tags