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;
2728// jetspeed services29import org.apache.jetspeed.services.JetspeedSecurity;
30import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
31import org.apache.jetspeed.services.logging.JetspeedLogger;
32import org.apache.jetspeed.services.resources.JetspeedResources;
3334// jetspeed velocity35import org.apache.jetspeed.modules.actions.portlets.VelocityPortletAction;
36import org.apache.jetspeed.portal.portlets.VelocityPortlet;
373839/***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 */45publicclassRoleBrowserActionextendsVelocityPortletAction46 {
4748/***49 * Static initialization of the logger for this class50 */51privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(RoleBrowserAction.class.getName());
5253/***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 */60protectedvoid buildMaximizedContext( VelocityPortlet portlet,
61 Context context,
62 RunData rundata )
63 {
64 buildNormalContext( portlet, context, rundata);
65 }
6667/***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 */75protectedvoid buildConfigureContext( VelocityPortlet portlet,
76 Context context,
77 RunData rundata )
78 {
7980 buildNormalContext( portlet, context, rundata);
81 }
8283/***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 */90protectedvoid buildNormalContext( VelocityPortlet portlet,
91 Context context,
92 RunData rundata )
93 {
94try95 {
96 Iterator roles = JetspeedSecurity.getRoles();
97 context.put(SecurityConstants.CONTEXT_ROLES, roles);
98 }
99catch (Exception e)
100 {
101// log the error msg102 logger.error("Error in Jetspeed Role Security", e);
103104 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 }
109110111 }