1 package info.magnolia.cms.cache; 2 3 import info.magnolia.cms.core.Content; 4 5 import java.io.BufferedReader ; 6 import java.io.IOException ; 7 import java.io.UnsupportedEncodingException ; 8 import java.security.Principal ; 9 import java.util.Enumeration ; 10 import java.util.Hashtable ; 11 import java.util.Locale ; 12 import java.util.Map ; 13 14 import javax.servlet.RequestDispatcher ; 15 import javax.servlet.ServletInputStream ; 16 import javax.servlet.http.Cookie ; 17 import javax.servlet.http.HttpServletRequest ; 18 import javax.servlet.http.HttpSession ; 19 20 21 26 public class MockCacheRequest implements HttpServletRequest { 27 28 31 private static final long serialVersionUID = 222L; 32 33 private HttpServletRequest request; 34 35 private Content node; 36 37 public MockCacheRequest(HttpServletRequest request, Content node) { 38 this.request = request; 39 this.node = node; 40 } 41 42 public String getAuthType() { 43 return request.getAuthType(); 44 } 45 46 public Cookie [] getCookies() { 47 return request.getCookies(); 48 } 49 50 public long getDateHeader(String arg0) { 51 return request.getDateHeader(arg0); 52 } 53 54 public String getHeader(String arg0) { 55 return request.getHeader(arg0); 56 } 57 58 public Enumeration getHeaders(String arg0) { 59 return request.getHeaders(arg0); 60 } 61 62 public Enumeration getHeaderNames() { 63 return request.getHeaderNames(); 64 } 65 66 public int getIntHeader(String arg0) { 67 return request.getIntHeader(arg0); 68 } 69 70 public String getMethod() { 71 return "GET"; 72 } 73 74 public String getPathInfo() { 75 return request.getPathInfo(); 76 } 77 78 public String getPathTranslated() { 79 return null; 80 } 81 82 public String getContextPath() { 83 return request.getContextPath(); 84 } 85 86 public String getQueryString() { 87 return request.getQueryString(); 88 } 89 90 public String getRemoteUser() { 91 return request.getRemoteUser(); 92 } 93 94 public boolean isUserInRole(String arg0) { 95 return request.isUserInRole(arg0); 96 } 97 98 public Principal getUserPrincipal() { 99 return request.getUserPrincipal(); 100 } 101 102 public String getRequestedSessionId() { 103 return request.getRequestedSessionId(); 104 } 105 106 public String getRequestURI() { 107 return request.getContextPath() + getServletPath(); 109 } 110 111 public StringBuffer getRequestURL() { 112 return new StringBuffer ("http://" + request.getRemoteAddr() + getRequestURI()); 114 } 115 116 public String getServletPath() { 117 try { 119 return node.getJCRNode().getPath() + ".html"; 120 } 121 catch (Exception e) { 122 return null; 123 } 124 } 125 126 public HttpSession getSession(boolean arg0) { 127 return request.getSession(arg0); 128 } 129 130 public HttpSession 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 150 public boolean isRequestedSessionIdFromUrl() { 151 return request.isRequestedSessionIdFromUrl(); 152 } 153 154 public Object getAttribute(String arg0) { 155 return request.getAttribute(arg0); 156 } 157 158 public Enumeration getAttributeNames() { 159 return request.getAttributeNames(); 160 } 161 162 public String getCharacterEncoding() { 163 return request.getCharacterEncoding(); 164 } 165 166 public void setCharacterEncoding(String arg0) throws UnsupportedEncodingException { 167 request.setCharacterEncoding(arg0); 168 } 169 170 public int getContentLength() { 171 return 0; 172 } 173 174 public String getContentType() { 175 return null; 177 } 178 179 public ServletInputStream getInputStream() throws IOException { 180 return null; 182 } 183 184 public String getParameter(String arg0) { 185 return request.getParameter(arg0); 186 } 187 188 public Enumeration getParameterNames() { 189 return request.getParameterNames(); 190 } 191 192 public String [] getParameterValues(String arg0) { 193 return request.getParameterValues(arg0); 194 } 195 196 public static final Hashtable EMPTY_MAP = new Hashtable (0); 197 198 public Map getParameterMap() { 199 return EMPTY_MAP; 200 } 201 202 public String getProtocol() { 203 return request.getProtocol(); 204 } 205 206 public String getScheme() { 207 return request.getScheme(); 208 } 209 210 public String getServerName() { 211 return request.getServerName(); 212 } 213 214 public int getServerPort() { 215 return request.getServerPort(); 216 } 217 218 public BufferedReader getReader() throws IOException { 219 return null; 221 } 222 223 public String getRemoteAddr() { 224 return request.getRemoteAddr(); 225 } 226 227 public String getRemoteHost() { 228 return request.getRemoteHost(); 229 } 230 231 public void setAttribute(String arg0, Object arg1) { 232 234 } 235 236 public void removeAttribute(String arg0) { 237 239 } 240 241 public Locale getLocale() { 242 return request.getLocale(); 243 } 244 245 public Enumeration getLocales() { 246 return request.getLocales(); 247 } 248 249 public boolean isSecure() { 250 return request.isSecure(); 251 } 252 253 public RequestDispatcher getRequestDispatcher(String arg0) { 254 return null; 255 } 256 257 261 public String getRealPath(String arg0) { 262 return request.getRealPath(arg0); 263 } 264 265 public int getRemotePort() { 266 return request.getRemotePort(); 267 } 268 269 public String getLocalName() { 270 return request.getLocalName(); 271 } 272 273 public String getLocalAddr() { 274 return request.getLocalAddr(); 275 } 276 277 public int getLocalPort() { 278 return request.getLocalPort(); 279 } 280 281 } 282 | Popular Tags |