KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > modules > actions > portlets > security > GroupBrowserAction


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 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.modules.actions.portlets.security;
18
19 import java.util.Iterator JavaDoc;
20
21 // velocity
22
import org.apache.velocity.context.Context;
23
24 // turbine util
25
import org.apache.turbine.util.RunData;
26 import org.apache.turbine.util.StringUtils;
27
28
29 // jetspeed security
30
import org.apache.jetspeed.services.JetspeedSecurity;
31
32 // jetspeed services
33
import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
34 import org.apache.jetspeed.services.logging.JetspeedLogger;
35 import org.apache.jetspeed.services.resources.JetspeedResources;
36
37 // jetspeed velocity
38
import org.apache.jetspeed.modules.actions.portlets.VelocityPortletAction;
39 import org.apache.jetspeed.portal.portlets.VelocityPortlet;
40
41
42 /**
43  * This action sets up the template context for browsing of security groups in the Turbine database.
44  *
45  * @author <a HREF="mailto:taylor@apache.org">David Sean Taylor</a>
46  * @version $Id: GroupBrowserAction.java,v 1.7 2004/02/23 02:53:08 jford Exp $
47  */

48
49 public class GroupBrowserAction extends VelocityPortletAction
50 {
51     /**
52      * Static initialization of the logger for this class
53      */

54     private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(GroupBrowserAction.class.getName());
55     
56     /**
57      * Build the maximized state content for this portlet. (Same as normal state).
58      *
59      * @param portlet The velocity-based portlet that is being built.
60      * @param context The velocity context for this request.
61      * @param rundata The turbine rundata context for this request.
62      */

63     protected void buildMaximizedContext( VelocityPortlet portlet,
64                                           Context context,
65                                           RunData rundata )
66     {
67         buildNormalContext( portlet, context, rundata);
68     }
69
70     /**
71      * Build the configure state content for this portlet.
72      * TODO: we could configure this portlet with configurable skins, etc..
73      *
74      * @param portlet The velocity-based portlet that is being built.
75      * @param context The velocity context for this request.
76      * @param rundata The turbine rundata context for this request.
77      */

78     protected void buildConfigureContext( VelocityPortlet portlet,
79                                           Context context,
80                                           RunData rundata )
81     {
82
83         buildNormalContext( portlet, context, rundata);
84     }
85
86     /**
87      * Build the normal state content for this portlet.
88      *
89      * @param portlet The velocity-based portlet that is being built.
90      * @param context The velocity context for this request.
91      * @param rundata The turbine rundata context for this request.
92      */

93     protected void buildNormalContext( VelocityPortlet portlet,
94                                        Context context,
95                                        RunData rundata )
96     {
97         try
98         {
99             Iterator JavaDoc groups = JetspeedSecurity.getGroups();
100             context.put(SecurityConstants.CONTEXT_GROUPS, groups);
101         }
102         catch (Exception JavaDoc e)
103         {
104            // log the error msg
105
logger.error("Exception", e);
106
107             rundata.setMessage("Error in Jetspeed Group Security: " + e.toString());
108             rundata.setStackTrace(StringUtils.stackTrace(e), e);
109             rundata.setScreenTemplate(JetspeedResources.getString("template.error","Error"));
110         }
111     }
112
113 }
114
Popular Tags