1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.modules.actions.portlets.security;
18
19 import java.util.Iterator;
20
21
22 import org.apache.velocity.context.Context;
23
24
25 import org.apache.turbine.util.RunData;
26 import org.apache.turbine.util.StringUtils;
27
28
29 import org.apache.jetspeed.services.JetspeedSecurity;
30 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
31 import org.apache.jetspeed.services.logging.JetspeedLogger;
32 import org.apache.jetspeed.services.resources.JetspeedResources;
33
34
35 import org.apache.jetspeed.modules.actions.portlets.VelocityPortletAction;
36 import org.apache.jetspeed.portal.portlets.VelocityPortlet;
37
38
39 /***
40 * This action sets up the template context for browsing of security roles in the Turbine database.
41 *
42 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
43 * @version $Id: RoleBrowserAction.java,v 1.9 2004/02/23 02:53:08 jford Exp $
44 */
45 public class RoleBrowserAction extends VelocityPortletAction
46 {
47
48 /***
49 * Static initialization of the logger for this class
50 */
51 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(RoleBrowserAction.class.getName());
52
53 /***
54 * Build the maximized state content for this portlet. (Same as normal state).
55 *
56 * @param portlet The velocity-based portlet that is being built.
57 * @param context The velocity context for this request.
58 * @param rundata The turbine rundata context for this request.
59 */
60 protected void buildMaximizedContext( VelocityPortlet portlet,
61 Context context,
62 RunData rundata )
63 {
64 buildNormalContext( portlet, context, rundata);
65 }
66
67 /***
68 * Build the configure state content for this portlet.
69 * TODO: we could configure this portlet with configurable skins, etc..
70 *
71 * @param portlet The velocity-based portlet that is being built.
72 * @param context The velocity context for this request.
73 * @param rundata The turbine rundata context for this request.
74 */
75 protected void buildConfigureContext( VelocityPortlet portlet,
76 Context context,
77 RunData rundata )
78 {
79
80 buildNormalContext( portlet, context, rundata);
81 }
82
83 /***
84 * Build the normal state content for this portlet.
85 *
86 * @param portlet The velocity-based portlet that is being built.
87 * @param context The velocity context for this request.
88 * @param rundata The turbine rundata context for this request.
89 */
90 protected void buildNormalContext( VelocityPortlet portlet,
91 Context context,
92 RunData rundata )
93 {
94 try
95 {
96 Iterator roles = JetspeedSecurity.getRoles();
97 context.put(SecurityConstants.CONTEXT_ROLES, roles);
98 }
99 catch (Exception e)
100 {
101
102 logger.error("Error in Jetspeed Role Security", e);
103
104 rundata.setMessage("Error in Jetspeed Role Security: " + e.toString());
105 rundata.setStackTrace(StringUtils.stackTrace(e), e);
106 rundata.setScreenTemplate(JetspeedResources.getString("template.error","Error"));
107 }
108 }
109
110
111 }