View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.orchestra.lib.jsf;
20  
21  import java.io.IOException;
22  import java.io.InputStream;
23  import java.net.MalformedURLException;
24  import java.net.URL;
25  import java.security.Principal;
26  import java.util.Iterator;
27  import java.util.Locale;
28  import java.util.Map;
29  import java.util.Set;
30  
31  import javax.faces.context.ExternalContext;
32  
33  import org.apache.myfaces.orchestra.requestParameterProvider.RequestParameterProviderManager;
34  
35  /**
36   * Class used by _PortletFacesContextWrapper to allow orchestra work in portlets
37   * 
38   * This class wraps encodeActionURL and encodeResourceURL to include
39   * conversationContext param like RequestParameterResponseWrapper does. In portlets
40   * we can't do the same than is servlets, because the params added here must be
41   * encoded by the portlet container and in portlets we don't have servlet redirect
42   * cases.
43   * 
44   * @author Leonardo Uribe(latest modification by $Author: lu4242 $)
45   * @version $Revision: 798382 $ $Date: 2009-07-27 22:23:02 -0500 (lun, 27 jul 2009) $
46   */
47  public class PortletExternalContextWrapper extends ExternalContext
48  {
49      private ExternalContext _delegate;
50  
51      public PortletExternalContextWrapper(ExternalContext context)
52      {
53          super();
54          this._delegate = context;
55      }
56  
57      public void dispatch(String arg0) throws IOException
58      {
59          _delegate.dispatch(arg0);
60      }
61  
62      public String encodeActionURL(String url)
63      {
64          if (url != null)
65          {
66              url = RequestParameterProviderManager.getInstance().encodeAndAttachParameters(url);
67          }
68          return _delegate.encodeActionURL(url);
69      }
70  
71      public String encodeNamespace(String arg0)
72      {
73          return _delegate.encodeNamespace(arg0);
74      }
75  
76      public String encodeResourceURL(String url)
77      {
78          if (url != null)
79          {
80              url = RequestParameterProviderManager.getInstance().encodeAndAttachParameters(url);
81          }
82          return _delegate.encodeResourceURL(url);
83      }
84  
85      public Map getApplicationMap()
86      {
87          return _delegate.getApplicationMap();
88      }
89  
90      public String getAuthType()
91      {
92          return _delegate.getAuthType();
93      }
94  
95      public Object getContext()
96      {
97          return _delegate.getContext();
98      }
99  
100     public String getInitParameter(String arg0)
101     {
102         return _delegate.getInitParameter(arg0);
103     }
104 
105     public Map getInitParameterMap()
106     {
107         return _delegate.getInitParameterMap();
108     }
109 
110     public String getRemoteUser()
111     {
112         return _delegate.getRemoteUser();
113     }
114 
115     public Object getRequest()
116     {
117         return _delegate.getRequest();
118     }
119 
120     public String getRequestContextPath()
121     {
122         return _delegate.getRequestContextPath();
123     }
124 
125     public Map getRequestCookieMap()
126     {
127         return _delegate.getRequestCookieMap();
128     }
129 
130     public Map getRequestHeaderMap()
131     {
132         return _delegate.getRequestHeaderMap();
133     }
134 
135     public Map getRequestHeaderValuesMap()
136     {
137         return _delegate.getRequestHeaderValuesMap();
138     }
139 
140     public Locale getRequestLocale()
141     {
142         return _delegate.getRequestLocale();
143     }
144 
145     public Iterator getRequestLocales()
146     {
147         return _delegate.getRequestLocales();
148     }
149 
150     public Map getRequestMap()
151     {
152         return _delegate.getRequestMap();
153     }
154 
155     public Map getRequestParameterMap()
156     {
157         return _delegate.getRequestParameterMap();
158     }
159 
160     public Iterator getRequestParameterNames()
161     {
162         return _delegate.getRequestParameterNames();
163     }
164 
165     public Map getRequestParameterValuesMap()
166     {
167         return _delegate.getRequestParameterValuesMap();
168     }
169 
170     public String getRequestPathInfo()
171     {
172         return _delegate.getRequestPathInfo();
173     }
174 
175     public String getRequestServletPath()
176     {
177         return _delegate.getRequestServletPath();
178     }
179 
180     public URL getResource(String arg0) throws MalformedURLException
181     {
182         return _delegate.getResource(arg0);
183     }
184 
185     public InputStream getResourceAsStream(String arg0)
186     {
187         return _delegate.getResourceAsStream(arg0);
188     }
189 
190     public Set getResourcePaths(String arg0)
191     {
192         return _delegate.getResourcePaths(arg0);
193     }
194 
195     public Object getResponse()
196     {
197         return _delegate.getResponse();
198     }
199 
200     public Object getSession(boolean arg0)
201     {
202         return _delegate.getSession(arg0);
203     }
204 
205     public Map getSessionMap()
206     {
207         return _delegate.getSessionMap();
208     }
209 
210     public Principal getUserPrincipal()
211     {
212         return _delegate.getUserPrincipal();
213     }
214 
215     public boolean isUserInRole(String arg0)
216     {
217         return _delegate.isUserInRole(arg0);
218     }
219 
220     public void redirect(String arg0) throws IOException
221     {
222         _delegate.redirect(arg0);
223     }
224 
225     public void log(String s, Throwable throwable)
226     {
227         _delegate.log(s, throwable);
228     }
229 
230     public void log(String s)
231     {
232         _delegate.log(s);
233     }
234     
235     //Methods since 1.2
236     
237     public String getResponseContentType()
238     {
239         return _delegate.getResponseContentType();
240     }
241 
242     public void setRequest(java.lang.Object request)
243     {
244         _delegate.setRequest(request);
245     }
246 
247     public void setRequestCharacterEncoding(java.lang.String encoding)
248         throws java.io.UnsupportedEncodingException
249     {
250         _delegate.setRequestCharacterEncoding(encoding);
251     }
252     
253     public void setResponse(java.lang.Object response)
254     {
255         _delegate.setResponse(response);
256     }
257     
258     public void setResponseCharacterEncoding(java.lang.String encoding)
259     {
260         _delegate.setResponseCharacterEncoding(encoding);
261     }
262 
263     public String getResponseCharacterEncoding()
264     {
265         return _delegate.getResponseCharacterEncoding();
266     }
267         
268     public String getRequestCharacterEncoding()
269     {
270         return _delegate.getRequestCharacterEncoding();
271     }
272 }