1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
package org.apache.tapestry.portlet; |
16 | |
|
17 | |
import org.apache.hivemind.util.Defense; |
18 | |
import org.apache.tapestry.describe.DescriptionReceiver; |
19 | |
import org.apache.tapestry.web.WebRequest; |
20 | |
import org.apache.tapestry.web.WebSession; |
21 | |
import org.apache.tapestry.web.WebUtils; |
22 | |
|
23 | |
import javax.portlet.PortletRequest; |
24 | |
import javax.portlet.PortletSession; |
25 | |
import java.security.Principal; |
26 | |
import java.util.List; |
27 | |
import java.util.Locale; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
public class PortletWebRequest implements WebRequest |
37 | |
{ |
38 | |
|
39 | |
private final PortletRequest _portletRequest; |
40 | |
|
41 | |
private WebSession _webSession; |
42 | |
|
43 | |
public PortletWebRequest(PortletRequest portletRequest) |
44 | 0 | { |
45 | 0 | Defense.notNull(portletRequest, "portletRequest"); |
46 | |
|
47 | 0 | _portletRequest = portletRequest; |
48 | 0 | } |
49 | |
|
50 | |
public List getParameterNames() |
51 | |
{ |
52 | 0 | return WebUtils.toSortedList(_portletRequest.getParameterNames()); |
53 | |
} |
54 | |
|
55 | |
public String getParameterValue(String parameterName) |
56 | |
{ |
57 | 0 | return _portletRequest.getParameter(parameterName); |
58 | |
} |
59 | |
|
60 | |
public String[] getParameterValues(String parameterName) |
61 | |
{ |
62 | 0 | return _portletRequest.getParameterValues(parameterName); |
63 | |
} |
64 | |
|
65 | |
public String getContextPath() |
66 | |
{ |
67 | 0 | return _portletRequest.getContextPath(); |
68 | |
} |
69 | |
|
70 | |
public WebSession getSession(boolean create) |
71 | |
{ |
72 | 0 | if (_webSession != null) return _webSession; |
73 | |
|
74 | 0 | PortletSession session = _portletRequest.getPortletSession(create); |
75 | |
|
76 | 0 | if (session != null) _webSession = new PortletWebSession(session); |
77 | |
|
78 | 0 | return _webSession; |
79 | |
} |
80 | |
|
81 | |
public String getScheme() |
82 | |
{ |
83 | 0 | return _portletRequest.getScheme(); |
84 | |
} |
85 | |
|
86 | |
public String getServerName() |
87 | |
{ |
88 | 0 | return _portletRequest.getServerName(); |
89 | |
} |
90 | |
|
91 | |
public int getServerPort() |
92 | |
{ |
93 | 0 | return _portletRequest.getServerPort(); |
94 | |
} |
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
public String getRequestURI() |
102 | |
{ |
103 | 0 | return "<PortletRequest>"; |
104 | |
} |
105 | |
|
106 | |
public void forward(String URL) |
107 | |
{ |
108 | 0 | unsupported("forward"); |
109 | 0 | } |
110 | |
|
111 | |
public String getActivationPath() |
112 | |
{ |
113 | 0 | return ""; |
114 | |
} |
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
public String getPathInfo() |
120 | |
{ |
121 | 0 | return null; |
122 | |
} |
123 | |
|
124 | |
public List getAttributeNames() |
125 | |
{ |
126 | 0 | return WebUtils.toSortedList(_portletRequest.getAttributeNames()); |
127 | |
} |
128 | |
|
129 | |
public Object getAttribute(String name) |
130 | |
{ |
131 | 0 | return _portletRequest.getAttribute(name); |
132 | |
} |
133 | |
|
134 | |
public void setAttribute(String name, Object attribute) |
135 | |
{ |
136 | 0 | if (attribute == null) |
137 | 0 | _portletRequest.removeAttribute(name); |
138 | |
else |
139 | 0 | _portletRequest.setAttribute(name, attribute); |
140 | 0 | } |
141 | |
|
142 | |
protected final void unsupported(String methodName) |
143 | |
{ |
144 | 0 | throw new UnsupportedOperationException(PortletMessages.unsupportedMethod(methodName)); |
145 | |
} |
146 | |
|
147 | |
public void describeTo(DescriptionReceiver receiver) |
148 | |
{ |
149 | 0 | receiver.describeAlternate(_portletRequest); |
150 | 0 | } |
151 | |
|
152 | |
public Locale getLocale() |
153 | |
{ |
154 | 0 | return _portletRequest.getLocale(); |
155 | |
} |
156 | |
|
157 | |
public String getHeader(String name) |
158 | |
{ |
159 | 0 | unsupported("getHeader"); |
160 | |
|
161 | 0 | return null; |
162 | |
} |
163 | |
|
164 | |
public long getDateHeader(String name) |
165 | |
{ |
166 | 0 | unsupported("getDateHeader"); |
167 | |
|
168 | 0 | return -1; |
169 | |
} |
170 | |
|
171 | |
public int getIntHeader(String name) |
172 | |
{ |
173 | 0 | unsupported("getIntHeader"); |
174 | |
|
175 | 0 | return -1; |
176 | |
} |
177 | |
|
178 | |
public String getRemoteUser() |
179 | |
{ |
180 | 0 | return _portletRequest.getRemoteUser(); |
181 | |
} |
182 | |
|
183 | |
public Principal getUserPrincipal() |
184 | |
{ |
185 | 0 | return _portletRequest.getUserPrincipal(); |
186 | |
} |
187 | |
|
188 | |
public boolean isUserInRole(String role) |
189 | |
{ |
190 | 0 | return _portletRequest.isUserInRole(role); |
191 | |
} |
192 | |
|
193 | |
public boolean isSecure() |
194 | |
{ |
195 | 0 | return _portletRequest.isSecure(); |
196 | |
} |
197 | |
} |