|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
PortletWebRequest.java | 100% | 88.5% | 83.3% | 88% |
|
1 |
// Copyright 2005 The Apache Software Foundation
|
|
2 |
//
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
5 |
// You may obtain a copy of the License at
|
|
6 |
//
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
//
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
// See the License for the specific language governing permissions and
|
|
13 |
// limitations under the License.
|
|
14 |
|
|
15 |
package org.apache.tapestry.portlet;
|
|
16 |
|
|
17 |
import java.util.List;
|
|
18 |
import java.util.Locale;
|
|
19 |
|
|
20 |
import javax.portlet.PortletRequest;
|
|
21 |
import javax.portlet.PortletSession;
|
|
22 |
|
|
23 |
import org.apache.hivemind.util.Defense;
|
|
24 |
import org.apache.tapestry.describe.DescriptionReceiver;
|
|
25 |
import org.apache.tapestry.web.WebRequest;
|
|
26 |
import org.apache.tapestry.web.WebSession;
|
|
27 |
import org.apache.tapestry.web.WebUtils;
|
|
28 |
|
|
29 |
/**
|
|
30 |
* Implementation of {@link org.apache.tapestry.web.WebRequest}that adapts a
|
|
31 |
* {@link PortletRequest).
|
|
32 |
*
|
|
33 |
* @author Howard M. Lewis Ship
|
|
34 |
* @since 4.0
|
|
35 |
*/
|
|
36 |
public class PortletWebRequest implements WebRequest |
|
37 |
{ |
|
38 |
private final PortletRequest _portletRequest;
|
|
39 |
|
|
40 |
private WebSession _webSession;
|
|
41 |
|
|
42 | 20 |
public PortletWebRequest(PortletRequest portletRequest)
|
43 |
{ |
|
44 | 20 |
Defense.notNull(portletRequest, "portletRequest");
|
45 |
|
|
46 | 20 |
_portletRequest = portletRequest; |
47 |
} |
|
48 |
|
|
49 | 1 |
public List getParameterNames()
|
50 |
{ |
|
51 | 1 |
return WebUtils.toSortedList(_portletRequest.getParameterNames());
|
52 |
} |
|
53 |
|
|
54 | 1 |
public String getParameterValue(String parameterName)
|
55 |
{ |
|
56 | 1 |
return _portletRequest.getParameter(parameterName);
|
57 |
} |
|
58 |
|
|
59 | 1 |
public String[] getParameterValues(String parameterName)
|
60 |
{ |
|
61 | 1 |
return _portletRequest.getParameterValues(parameterName);
|
62 |
} |
|
63 |
|
|
64 | 1 |
public String getContextPath()
|
65 |
{ |
|
66 | 1 |
return _portletRequest.getContextPath();
|
67 |
} |
|
68 |
|
|
69 | 3 |
public WebSession getSession(boolean create) |
70 |
{ |
|
71 | 3 |
if (_webSession != null) |
72 | 1 |
return _webSession;
|
73 |
|
|
74 | 2 |
PortletSession session = _portletRequest.getPortletSession(create); |
75 |
|
|
76 | 2 |
if (session != null) |
77 | 1 |
_webSession = new PortletWebSession(session);
|
78 |
|
|
79 | 2 |
return _webSession;
|
80 |
} |
|
81 |
|
|
82 | 1 |
public String getScheme()
|
83 |
{ |
|
84 | 1 |
return _portletRequest.getScheme();
|
85 |
} |
|
86 |
|
|
87 | 1 |
public String getServerName()
|
88 |
{ |
|
89 | 1 |
return _portletRequest.getServerName();
|
90 |
} |
|
91 |
|
|
92 | 1 |
public int getServerPort() |
93 |
{ |
|
94 | 1 |
return _portletRequest.getServerPort();
|
95 |
} |
|
96 |
|
|
97 |
/**
|
|
98 |
* Returns "<PortletRequest>", because portlets don't have a notion of request URI.
|
|
99 |
*/
|
|
100 |
|
|
101 | 1 |
public String getRequestURI()
|
102 |
{ |
|
103 | 1 |
return "<PortletRequest>"; |
104 |
} |
|
105 |
|
|
106 | 1 |
public void forward(String URL) |
107 |
{ |
|
108 | 1 |
unsupported("forward");
|
109 |
} |
|
110 |
|
|
111 | 0 |
public String getActivationPath()
|
112 |
{ |
|
113 | 0 |
return ""; |
114 |
} |
|
115 |
|
|
116 | 1 |
public List getAttributeNames()
|
117 |
{ |
|
118 | 1 |
return WebUtils.toSortedList(_portletRequest.getAttributeNames());
|
119 |
} |
|
120 |
|
|
121 | 1 |
public Object getAttribute(String name)
|
122 |
{ |
|
123 | 1 |
return _portletRequest.getAttribute(name);
|
124 |
} |
|
125 |
|
|
126 | 4 |
public void setAttribute(String name, Object attribute) |
127 |
{ |
|
128 | 4 |
if (attribute == null) |
129 | 3 |
_portletRequest.removeAttribute(name); |
130 |
else
|
|
131 | 1 |
_portletRequest.setAttribute(name, attribute); |
132 |
} |
|
133 |
|
|
134 | 1 |
protected final void unsupported(String methodName) |
135 |
{ |
|
136 | 1 |
throw new UnsupportedOperationException(PortletMessages.unsupportedMethod(methodName)); |
137 |
} |
|
138 |
|
|
139 | 0 |
public void describeTo(DescriptionReceiver receiver) |
140 |
{ |
|
141 | 0 |
receiver.describeAlternate(_portletRequest); |
142 |
} |
|
143 |
|
|
144 | 0 |
public Locale getLocale()
|
145 |
{ |
|
146 | 0 |
return _portletRequest.getLocale();
|
147 |
} |
|
148 |
} |
|