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
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
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
38 import org.apache.turbine.util.RunData;
39
40
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
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 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 }