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