%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.request.PortalRequest |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * 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 | { |
|
49 | private final String contextPath; |
|
50 | private final String servletPath; |
|
51 | private final HttpSession session; |
|
52 | ||
53 | public PortalRequest(HttpServletRequest request) |
|
54 | { |
|
55 | 0 | super(request); |
56 | 0 | contextPath = request.getContextPath(); |
57 | 0 | servletPath = request.getServletPath(); |
58 | 0 | session = request.getSession(true); |
59 | 0 | } |
60 | ||
61 | public String getContextPath() |
|
62 | { |
|
63 | 0 | return this.contextPath; |
64 | } |
|
65 | ||
66 | public String getServletPath() |
|
67 | { |
|
68 | 0 | return this.servletPath; |
69 | } |
|
70 | ||
71 | public HttpSession getSession() |
|
72 | { |
|
73 | 0 | return this.session; |
74 | } |
|
75 | ||
76 | public HttpSession getSession(boolean create) |
|
77 | { |
|
78 | 0 | return this.session; |
79 | } |
|
80 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |