View Javadoc

1   /*
2    * Copyright 2003,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  
18   */
19  
20  package org.apache.pluto.portlet;
21  
22  import java.util.Enumeration;
23  
24  import javax.portlet.*;
25  
26  public class PortletRequestWrapper extends javax.servlet.http.HttpServletRequestWrapper 
27  implements PortletRequest 
28  {
29  
30      /***
31      * Creates a ServletRequest adaptor wrapping the given request object.
32      * @throws java.lang.IllegalArgumentException if the request is null.
33      */
34      public PortletRequestWrapper(PortletRequest portletRequest)
35      {
36          super((javax.servlet.http.HttpServletRequest)portletRequest);
37  
38          if (portletRequest == null) 
39          {
40              throw new IllegalArgumentException("Request cannot be null");
41          }
42      }
43  
44      // javax.portlet.PortletRequest implementation -------------------------------------------------
45      public boolean isWindowStateAllowed(WindowState state)
46      {
47          return this.getPortletRequest().isWindowStateAllowed(state);
48      }
49      
50      public boolean isPortletModeAllowed(PortletMode mode)
51      {
52          return this.getPortletRequest().isPortletModeAllowed(mode);
53      }
54  
55      public PortletMode getPortletMode()
56      {
57          return this.getPortletRequest().getPortletMode();
58      }
59  
60      public WindowState getWindowState()
61      {
62          return this.getPortletRequest().getWindowState();
63      }
64      
65      public PortletPreferences getPreferences()
66      {
67          return this.getPortletRequest().getPreferences();
68      }
69      
70      public PortletSession getPortletSession()
71      {
72          return this.getPortletRequest().getPortletSession();
73      }
74  
75      public PortletSession getPortletSession(boolean create)
76      {
77          return this.getPortletRequest().getPortletSession(create);
78      }
79  
80      public String getProperty(String name)
81      {
82          return this.getPortletRequest().getProperty(name);      
83      }
84  
85      public Enumeration getProperties(String name)
86      {
87          return this.getPortletRequest().getProperties(name);
88      }
89  
90      public Enumeration getPropertyNames()
91      {
92          return this.getPortletRequest().getPropertyNames();
93      }
94  
95      public PortalContext getPortalContext()
96      {
97          return this.getPortletRequest().getPortalContext();
98      }
99  
100     public java.lang.String getAuthType()
101     {
102         return this.getPortletRequest().getAuthType();
103     }
104 
105     public String getContextPath()
106     {
107         return this.getPortletRequest().getContextPath();
108     }
109 
110     public java.lang.String getRemoteUser()
111     {
112         return this.getPortletRequest().getRemoteUser();
113     }
114 
115     public java.security.Principal getUserPrincipal()
116     {
117         return this.getPortletRequest().getUserPrincipal();
118     }
119 
120     public boolean isUserInRole(java.lang.String role)
121     {
122         return this.getPortletRequest().isUserInRole(role);
123     }
124 
125     public Object getAttribute(String name)
126     {
127         return this.getPortletRequest().getAttribute(name);
128     }
129 
130     public java.util.Enumeration getAttributeNames()
131     {
132         return this.getPortletRequest().getAttributeNames();
133     }
134 
135     public String getParameter(String name)
136     {
137         return this.getPortletRequest().getParameter(name);
138     }
139     
140     public java.util.Enumeration getParameterNames()
141     {
142         return this.getPortletRequest().getParameterNames();
143     }
144     
145     public String[] getParameterValues(String name)
146     {
147         return this.getPortletRequest().getParameterValues(name);
148     }
149 
150     public java.util.Map getParameterMap()
151     {
152         return this.getPortletRequest().getParameterMap();
153     }
154 
155     public boolean isSecure()
156     {
157         return this.getPortletRequest().isSecure();
158     }
159 
160     public void setAttribute(String name, Object o)
161     {
162         this.getPortletRequest().setAttribute(name,o);
163     }
164    
165     public void removeAttribute(String name)
166     {
167         this.getPortletRequest().removeAttribute(name);
168     }
169     
170     public String getRequestedSessionId()
171     {
172         return this.getPortletRequest().getRequestedSessionId();
173     }
174 
175     public boolean isRequestedSessionIdValid()
176     {
177         return this.getPortletRequest().isRequestedSessionIdValid();
178     }
179     
180     public String getResponseContentType()
181     {
182         return this.getPortletRequest().getResponseContentType();
183     }
184     
185     public java.util.Enumeration getResponseContentTypes()
186     {
187         return this.getPortletRequest().getResponseContentTypes();
188     }
189     
190     public java.util.Locale getLocale()
191     {
192         return this.getPortletRequest().getLocale();
193     }
194     
195     public java.util.Enumeration getLocales()
196     {
197         return this.getPortletRequest().getLocales();
198     }
199 
200     public String getScheme()
201     {
202         return this.getPortletRequest().getScheme();
203     }
204     
205     public String getServerName()
206     {
207         return this.getPortletRequest().getServerName();
208     }
209     
210     public int getServerPort()
211     {
212         return this.getPortletRequest().getServerPort();
213     }
214 
215     // --------------------------------------------------------------------------------------------
216     
217     // additional methods -------------------------------------------------------------------------
218     /***
219     * Return the wrapped ServletRequest object.
220     */
221     public PortletRequest getPortletRequest()
222     {
223         return (PortletRequest) super.getRequest();
224     }
225     
226     /***
227     * Sets the request being wrapped. 
228     * @throws java.lang.IllegalArgumentException if the request is null.
229     */
230     public void setRequest(PortletRequest request)
231     {
232         if (request == null) 
233         {
234             throw new IllegalArgumentException("Request cannot be null");
235         }    
236         setRequest((javax.servlet.http.HttpServletRequest)request);
237     }
238     // --------------------------------------------------------------------------------------------
239 }
240