01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.jetspeed.request;
18:
19: import javax.servlet.http.HttpServletRequest;
20: import javax.servlet.http.HttpServletRequestWrapper;
21: import javax.servlet.http.HttpSession;
22:
23: /**
24: * PortalRequest wraps the original request to the portal and keeps local
25: * references to properties like contextPath, servletPath and the Session
26: * when its created.
27: * <p>
28: * Some web servers like WebSphere don't store these properties inside the
29: * request but derive them dynamically based on the web application context
30: * in which they are invoked.
31: * </p>
32: * <p>
33: * For cross-context invoked portlet applications, getting access to the
34: * portal contextPath using requestContext.getRequest().getContextPath()
35: * this clearly is a problem. Also, access to the Portal Session is not
36: * possible this way.
37: * </p>
38: * <p>
39: * The requestContext.request is actually wrapped by this class which solves
40: * the problem by storing a reference to the actual properties at the time
41: * of creation and returning
42: * </p>
43: *
44: * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
45: * @version $Id$
46: */
47: public class PortalRequest extends HttpServletRequestWrapper {
48: private final String contextPath;
49: private final String servletPath;
50: private final HttpSession session;
51:
52: public PortalRequest(HttpServletRequest request) {
53: super (request);
54: contextPath = request.getContextPath();
55: servletPath = request.getServletPath();
56: session = request.getSession(true);
57: }
58:
59: public String getContextPath() {
60: return this .contextPath;
61: }
62:
63: public String getServletPath() {
64: return this .servletPath;
65: }
66:
67: public HttpSession getSession() {
68: return this .session;
69: }
70:
71: public HttpSession getSession(boolean create) {
72: return this.session;
73: }
74: }
|