KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > util > MockCacheRequest


1 package info.magnolia.cms.util;
2
3 import info.magnolia.cms.core.Content;
4
5 import java.io.BufferedReader JavaDoc;
6 import java.io.IOException JavaDoc;
7 import java.io.UnsupportedEncodingException JavaDoc;
8 import java.security.Principal JavaDoc;
9 import java.util.Enumeration JavaDoc;
10 import java.util.Hashtable JavaDoc;
11 import java.util.Locale JavaDoc;
12 import java.util.Map JavaDoc;
13
14 import javax.servlet.RequestDispatcher JavaDoc;
15 import javax.servlet.ServletInputStream JavaDoc;
16 import javax.servlet.http.Cookie JavaDoc;
17 import javax.servlet.http.HttpServletRequest JavaDoc;
18 import javax.servlet.http.HttpSession JavaDoc;
19
20
21 /**
22  * Fake request created from a real request used to generate cache content.
23  * @author niko
24  */

25 public class MockCacheRequest implements HttpServletRequest JavaDoc {
26
27     private HttpServletRequest JavaDoc request;
28
29     private Content node;
30
31     public MockCacheRequest(HttpServletRequest JavaDoc request, Content node) {
32         this.request = request;
33         this.node = node;
34     }
35
36     public String JavaDoc getAuthType() {
37         return request.getAuthType();
38     }
39
40     public Cookie JavaDoc[] getCookies() {
41         return request.getCookies();
42     }
43
44     public long getDateHeader(String JavaDoc arg0) {
45         return request.getDateHeader(arg0);
46     }
47
48     public String JavaDoc getHeader(String JavaDoc arg0) {
49         return request.getHeader(arg0);
50     }
51
52     public Enumeration JavaDoc getHeaders(String JavaDoc arg0) {
53         return request.getHeaders(arg0);
54     }
55
56     public Enumeration JavaDoc getHeaderNames() {
57         return request.getHeaderNames();
58     }
59
60     public int getIntHeader(String JavaDoc arg0) {
61         return request.getIntHeader(arg0);
62     }
63
64     public String JavaDoc getMethod() {
65         return "GET";
66     }
67
68     public String JavaDoc getPathInfo() {
69         return request.getPathInfo();
70     }
71
72     public String JavaDoc getPathTranslated() {
73         return null;
74     }
75
76     public String JavaDoc getContextPath() {
77         return request.getContextPath();
78     }
79
80     public String JavaDoc getQueryString() {
81         return request.getQueryString();
82     }
83
84     public String JavaDoc getRemoteUser() {
85         return request.getRemoteUser();
86     }
87
88     public boolean isUserInRole(String JavaDoc arg0) {
89         return request.isUserInRole(arg0);
90     }
91
92     public Principal JavaDoc getUserPrincipal() {
93         return request.getUserPrincipal();
94     }
95
96     public String JavaDoc getRequestedSessionId() {
97         return request.getRequestedSessionId();
98     }
99
100     public String JavaDoc getRequestURI() {
101         // TODO Auto-generated method stub
102
return request.getContextPath() + getServletPath();
103     }
104
105     public StringBuffer JavaDoc getRequestURL() {
106         // TODO Auto-generated method stub
107
return new StringBuffer JavaDoc("http://" + request.getRemoteAddr() + getRequestURI());
108     }
109
110     public String JavaDoc getServletPath() {
111         // TODO Auto-generated method stub
112
try {
113             return node.getJCRNode().getPath() + ".html";
114         }
115         catch (Exception JavaDoc e) {
116             return null;
117         }
118     }
119
120     public HttpSession JavaDoc getSession(boolean arg0) {
121         return request.getSession(arg0);
122     }
123
124     public HttpSession JavaDoc getSession() {
125         return request.getSession();
126     }
127
128     public boolean isRequestedSessionIdValid() {
129         return request.isRequestedSessionIdValid();
130     }
131
132     public boolean isRequestedSessionIdFromCookie() {
133         return request.isRequestedSessionIdFromCookie();
134     }
135
136     public boolean isRequestedSessionIdFromURL() {
137         return request.isRequestedSessionIdFromURL();
138     }
139
140     public boolean isRequestedSessionIdFromUrl() {
141         return request.isRequestedSessionIdFromUrl();
142     }
143
144     public Object JavaDoc getAttribute(String JavaDoc arg0) {
145         return request.getAttribute(arg0);
146     }
147
148     public Enumeration JavaDoc getAttributeNames() {
149         return request.getAttributeNames();
150     }
151
152     public String JavaDoc getCharacterEncoding() {
153         return request.getCharacterEncoding();
154     }
155
156     public void setCharacterEncoding(String JavaDoc arg0) throws UnsupportedEncodingException JavaDoc {
157         request.setCharacterEncoding(arg0);
158     }
159
160     public int getContentLength() {
161         return 0;
162     }
163
164     public String JavaDoc getContentType() {
165         // TODO Auto-generated method stub
166
return null;
167     }
168
169     public ServletInputStream JavaDoc getInputStream() throws IOException JavaDoc {
170         // TODO Auto-generated method stub
171
return null;
172     }
173
174     public String JavaDoc getParameter(String JavaDoc arg0) {
175         return request.getParameter(arg0);
176     }
177
178     public Enumeration JavaDoc getParameterNames() {
179         return request.getParameterNames();
180     }
181
182     public String JavaDoc[] getParameterValues(String JavaDoc arg0) {
183         return request.getParameterValues(arg0);
184     }
185
186     public static final Hashtable JavaDoc EMPTY_MAP = new Hashtable JavaDoc(0);
187
188     public Map JavaDoc getParameterMap() {
189         return EMPTY_MAP;
190     }
191
192     public String JavaDoc getProtocol() {
193         return request.getProtocol();
194     }
195
196     public String JavaDoc getScheme() {
197         return request.getScheme();
198     }
199
200     public String JavaDoc getServerName() {
201         return request.getServerName();
202     }
203
204     public int getServerPort() {
205         return request.getServerPort();
206     }
207
208     public BufferedReader JavaDoc getReader() throws IOException JavaDoc {
209         // TODO Auto-generated method stub
210
return null;
211     }
212
213     public String JavaDoc getRemoteAddr() {
214         return request.getRemoteAddr();
215     }
216
217     public String JavaDoc getRemoteHost() {
218         return request.getRemoteHost();
219     }
220
221     public void setAttribute(String JavaDoc arg0, Object JavaDoc arg1) {
222         // TODO Auto-generated method stub
223

224     }
225
226     public void removeAttribute(String JavaDoc arg0) {
227         // TODO Auto-generated method stub
228

229     }
230
231     public Locale JavaDoc getLocale() {
232         return request.getLocale();
233     }
234
235     public Enumeration JavaDoc getLocales() {
236         return request.getLocales();
237     }
238
239     public boolean isSecure() {
240         return request.isSecure();
241     }
242
243     public RequestDispatcher JavaDoc getRequestDispatcher(String JavaDoc arg0) {
244         // TODO Auto-generated method stub
245
return null;
246     }
247
248     public String JavaDoc getRealPath(String JavaDoc arg0) {
249         return request.getRealPath(arg0);
250     }
251
252     public int getRemotePort() {
253         return request.getRemotePort();
254     }
255
256     public String JavaDoc getLocalName() {
257         return request.getLocalName();
258     }
259
260     public String JavaDoc getLocalAddr() {
261         return request.getLocalAddr();
262     }
263
264     public int getLocalPort() {
265         return request.getLocalPort();
266     }
267
268 }
269
Popular Tags