01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/portal/trunk/portal-render-engine-impl/impl/src/java/org/sakaiproject/portal/charon/velocity/VelocityPortalRenderContext.java $
03: * $Id: SakaiServletRequest.java 29143 2007-04-19 01:10:38Z ajpoland@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.portal.render.portlet.servlet;
21:
22: import java.util.Enumeration;
23: import java.util.HashMap;
24: import java.util.Iterator;
25: import java.util.Map;
26:
27: import javax.servlet.http.HttpServletRequest;
28: import javax.servlet.http.HttpServletRequestWrapper;
29:
30: import org.sakaiproject.portal.api.PortalService;
31: import org.sakaiproject.portal.render.portlet.services.state.PortletState;
32:
33: /**
34: * @author ddwolf
35: * @author ieb
36: * @since Sakai 2.4
37: * @version $Rev: 29143 $
38: */
39: public class SakaiServletRequest extends HttpServletRequestWrapper {
40:
41: private PortletState state;
42:
43: public SakaiServletRequest(HttpServletRequest servletRequest,
44: PortletState state) {
45: super (servletRequest);
46: this .state = state;
47: }
48:
49: @Override
50: public boolean isUserInRole(String string) {
51: boolean retval = SakaiServletUtil.isUserInRole(string, state);
52: return retval;
53: }
54:
55: @Override
56: public String getParameter(String string) {
57: return (String) state.getParameters().get(string);
58: }
59:
60: @Override
61: public Map getParameterMap() {
62: return new HashMap(state.getParameters());
63: }
64:
65: @Override
66: public Enumeration getParameterNames() {
67: final Iterator i = state.getParameters().keySet().iterator();
68: return new Enumeration() {
69:
70: public boolean hasMoreElements() {
71: return i.hasNext();
72: }
73:
74: public Object nextElement() {
75: return i.next();
76: }
77:
78: };
79: }
80:
81: @Override
82: public String[] getParameterValues(String string) {
83: return (String[]) state.getParameters().get(string);
84: }
85:
86: /**
87: * This causes the placement ID to be retrievabl from the request
88: */
89: @Override
90: public Object getAttribute(String attributeName) {
91: if (PortalService.PLACEMENT_ATTRIBUTE.equals(attributeName)) {
92: return state.getId();
93: } else {
94: return super.getAttribute(attributeName);
95: }
96: }
97: }
|