KickJava   Java API By Example, From Geeks To Geeks.

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


1 package info.magnolia.cms.cache;
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  * @author Fabrizio Giustina
25  */

26 public class MockCacheRequest implements HttpServletRequest JavaDoc {
27
28     /**
29      * Stable serialVersionUID.
30      */

31     private static final long serialVersionUID = 222L;
32
33     private HttpServletRequest JavaDoc request;
34
35     private Content node;
36
37     public MockCacheRequest(HttpServletRequest JavaDoc request, Content node) {
38         this.request = request;
39         this.node = node;
40     }
41
42     public String JavaDoc getAuthType() {
43         return request.getAuthType();
44     }
45
46     public Cookie JavaDoc[] getCookies() {
47         return request.getCookies();
48     }
49
50     public long getDateHeader(String JavaDoc arg0) {
51         return request.getDateHeader(arg0);
52     }
53
54     public String JavaDoc getHeader(String JavaDoc arg0) {
55         return request.getHeader(arg0);
56     }
57
58     public Enumeration JavaDoc getHeaders(String JavaDoc arg0) {
59         return request.getHeaders(arg0);
60     }
61
62     public Enumeration JavaDoc getHeaderNames() {
63         return request.getHeaderNames();
64     }
65
66     public int getIntHeader(String JavaDoc arg0) {
67         return request.getIntHeader(arg0);
68     }
69
70     public String JavaDoc getMethod() {
71         return "GET";
72     }
73
74     public String JavaDoc getPathInfo() {
75         return request.getPathInfo();
76     }
77
78     public String JavaDoc getPathTranslated() {
79         return null;
80     }
81
82     public String JavaDoc getContextPath() {
83         return request.getContextPath();
84     }
85
86     public String JavaDoc getQueryString() {
87         return request.getQueryString();
88     }
89
90     public String JavaDoc getRemoteUser() {
91         return request.getRemoteUser();
92     }
93
94     public boolean isUserInRole(String JavaDoc arg0) {
95         return request.isUserInRole(arg0);
96     }
97
98     public Principal JavaDoc getUserPrincipal() {
99         return request.getUserPrincipal();
100     }
101
102     public String JavaDoc getRequestedSessionId() {
103         return request.getRequestedSessionId();
104     }
105
106     public String JavaDoc getRequestURI() {
107         // TODO Auto-generated method stub
108
return request.getContextPath() + getServletPath();
109     }
110
111     public StringBuffer JavaDoc getRequestURL() {
112         // TODO Auto-generated method stub
113
return new StringBuffer JavaDoc("http://" + request.getRemoteAddr() + getRequestURI());
114     }
115
116     public String JavaDoc getServletPath() {
117         // TODO Auto-generated method stub
118
try {
119             return node.getJCRNode().getPath() + ".html";
120         }
121         catch (Exception JavaDoc e) {
122             return null;
123         }
124     }
125
126     public HttpSession JavaDoc getSession(boolean arg0) {
127         return request.getSession(arg0);
128     }
129
130     public HttpSession JavaDoc getSession() {
131         return request.getSession();
132     }
133
134     public boolean isRequestedSessionIdValid() {
135         return request.isRequestedSessionIdValid();
136     }
137
138     public boolean isRequestedSessionIdFromCookie() {
139         return request.isRequestedSessionIdFromCookie();
140     }
141
142     public boolean isRequestedSessionIdFromURL() {
143         return request.isRequestedSessionIdFromURL();
144     }
145
146     /**
147      * @deprecated
148      * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromUrl()
149      */

150     public boolean isRequestedSessionIdFromUrl() {
151         return request.isRequestedSessionIdFromUrl();
152     }
153
154     public Object JavaDoc getAttribute(String JavaDoc arg0) {
155         return request.getAttribute(arg0);
156     }
157
158     public Enumeration JavaDoc getAttributeNames() {
159         return request.getAttributeNames();
160     }
161
162     public String JavaDoc getCharacterEncoding() {
163         return request.getCharacterEncoding();
164     }
165
166     public void setCharacterEncoding(String JavaDoc arg0) throws UnsupportedEncodingException JavaDoc {
167         request.setCharacterEncoding(arg0);
168     }
169
170     public int getContentLength() {
171         return 0;
172     }
173
174     public String JavaDoc getContentType() {
175         // TODO Auto-generated method stub
176
return null;
177     }
178
179     public ServletInputStream JavaDoc getInputStream() throws IOException JavaDoc {
180         // TODO Auto-generated method stub
181
return null;
182     }
183
184     public String JavaDoc getParameter(String JavaDoc arg0) {
185         return request.getParameter(arg0);
186     }
187
188     public Enumeration JavaDoc getParameterNames() {
189         return request.getParameterNames();
190     }
191
192     public String JavaDoc[] getParameterValues(String JavaDoc arg0) {
193         return request.getParameterValues(arg0);
194     }
195
196     public static final Hashtable JavaDoc EMPTY_MAP = new Hashtable JavaDoc(0);
197
198     public Map JavaDoc getParameterMap() {
199         return EMPTY_MAP;
200     }
201
202     public String JavaDoc getProtocol() {
203         return request.getProtocol();
204     }
205
206     public String JavaDoc getScheme() {
207         return request.getScheme();
208     }
209
210     public String JavaDoc getServerName() {
211         return request.getServerName();
212     }
213
214     public int getServerPort() {
215         return request.getServerPort();
216     }
217
218     public BufferedReader JavaDoc getReader() throws IOException JavaDoc {
219         // TODO Auto-generated method stub
220
return null;
221     }
222
223     public String JavaDoc getRemoteAddr() {
224         return request.getRemoteAddr();
225     }
226
227     public String JavaDoc getRemoteHost() {
228         return request.getRemoteHost();
229     }
230
231     public void setAttribute(String JavaDoc arg0, Object JavaDoc arg1) {
232         // TODO Auto-generated method stub
233

234     }
235
236     public void removeAttribute(String JavaDoc arg0) {
237         // TODO Auto-generated method stub
238

239     }
240
241     public Locale JavaDoc getLocale() {
242         return request.getLocale();
243     }
244
245     public Enumeration JavaDoc getLocales() {
246         return request.getLocales();
247     }
248
249     public boolean isSecure() {
250         return request.isSecure();
251     }
252
253     public RequestDispatcher JavaDoc getRequestDispatcher(String JavaDoc arg0) {
254         return null;
255     }
256
257     /**
258      * @deprecated
259      * @see javax.servlet.ServletRequest#getRealPath(java.lang.String)
260      */

261     public String JavaDoc getRealPath(String JavaDoc arg0) {
262         return request.getRealPath(arg0);
263     }
264
265     public int getRemotePort() {
266         return request.getRemotePort();
267     }
268
269     public String JavaDoc getLocalName() {
270         return request.getLocalName();
271     }
272
273     public String JavaDoc getLocalAddr() {
274         return request.getLocalAddr();
275     }
276
277     public int getLocalPort() {
278         return request.getLocalPort();
279     }
280
281 }
282
Popular Tags