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