1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
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 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
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 |
| |
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 |
| |
149 |
0
| public String getHeader(String name)
|
150 |
| { |
151 |
0
| unsupported("getHeader");
|
152 |
| |
153 |
0
| return null;
|
154 |
| } |
155 |
| } |