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.modules.actions.portlets.security;
1819import java.util.Iterator;
2021// velocity22import org.apache.velocity.context.Context;
2324// turbine util25import org.apache.turbine.util.RunData;
26import org.apache.turbine.util.StringUtils;
272829// jetspeed security30import org.apache.jetspeed.services.JetspeedSecurity;
3132// jetspeed services33import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
34import org.apache.jetspeed.services.logging.JetspeedLogger;
35import org.apache.jetspeed.services.resources.JetspeedResources;
3637// jetspeed velocity38import org.apache.jetspeed.modules.actions.portlets.VelocityPortletAction;
39import org.apache.jetspeed.portal.portlets.VelocityPortlet;
404142/***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 */4849publicclassGroupBrowserActionextendsVelocityPortletAction50 {
51/***52 * Static initialization of the logger for this class53 */54privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(GroupBrowserAction.class.getName());
5556/***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 */63protectedvoid buildMaximizedContext( VelocityPortlet portlet,
64 Context context,
65 RunData rundata )
66 {
67 buildNormalContext( portlet, context, rundata);
68 }
6970/***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 */78protectedvoid buildConfigureContext( VelocityPortlet portlet,
79 Context context,
80 RunData rundata )
81 {
8283 buildNormalContext( portlet, context, rundata);
84 }
8586/***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 */93protectedvoid buildNormalContext( VelocityPortlet portlet,
94 Context context,
95 RunData rundata )
96 {
97try98 {
99 Iterator groups = JetspeedSecurity.getGroups();
100 context.put(SecurityConstants.CONTEXT_GROUPS, groups);
101 }
102catch (Exception e)
103 {
104// log the error msg105 logger.error("Exception", e);
106107 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 }
112113 }