Changeset 376
- Timestamp:
- 09/03/08 18:33:02 (4 months ago)
- Location:
- trunk/geowebcache/src/main
- Files:
-
- 3 removed
- 1 modified
-
java/org/geowebcache/GeoWebCacheDispatcher.java (modified) (9 diffs)
-
webapp/states_epsg4326.html (deleted)
-
webapp/states_epsg900913.html (deleted)
-
webapp/topp_states_epsg4326.html (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/geowebcache/src/main/java/org/geowebcache/GeoWebCacheDispatcher.java
r370 r376 49 49 50 50 public static final String TYPE_SERVICE = "service"; 51 52 //public static final String TYPE_SEED = "seed"; 53 51 54 52 public static final String TYPE_TRUNCATE = "truncate"; 55 53 … … 57 55 58 56 public static final String TYPE_DEMO = "demo"; 59 60 //WebApplicationContext context = null;61 62 private String servletPrefix = null;63 57 64 58 private TileLayerDispatcher tileLayerDispatcher = null; … … 91 85 */ 92 86 public void setServletPrefix(String servletPrefix) { 93 this.servletPrefix = servletPrefix; 87 //this.servletPrefix = servletPrefix; 88 log.warn("Ignored setServletPrefix("+servletPrefix+")"); 94 89 } 95 90 … … 141 136 HttpServletResponse response) throws Exception { 142 137 143 //context = (WebApplicationContext) getApplicationContext();144 145 138 // Break the request into components, {type, service name} 146 139 String[] requestComps = null; 147 140 try { 148 requestComps = parseRequest(request.getRequestURI()); 141 String normalizedURI = request.getRequestURI().replaceFirst(request.getContextPath(), ""); 142 requestComps = parseRequest(normalizedURI); 143 //requestComps = parseRequest(request.getRequestURI()); 149 144 } catch (GeoWebCacheException gwce) { 150 145 writeError(response, 400, gwce.getMessage()); … … 160 155 handleDemoRequest(requestComps[1],request, response); 161 156 } else { 162 writeError(response, 404, "Unknow path: " + requestComps[0]);157 writeError(response, 404, "Unknown path: " + requestComps[0]); 163 158 } 164 159 } catch (Exception e) { … … 187 182 String[] retStrs = new String[2]; 188 183 String[] splitStr = servletPath.split("/"); 189 // This string should start with / , so the first hit will be "" 190 191 if (servletPrefix != null) { 192 if (log.isDebugEnabled()) { 193 if (splitStr[0].equals(servletPrefix)) { 194 log.info("Matched servlet prefix " + servletPrefix 195 + " to request"); 196 } else { 197 log.error("Servlet prefix " + servletPrefix 198 + " does not match " + splitStr[0]); 199 } 200 } 201 if (splitStr.length < 4) { 202 throw new GeoWebCacheException("Unable to parse " + servletPath 203 + " given prefix " + servletPrefix); 204 } 205 retStrs[0] = splitStr[3]; 206 if(splitStr.length > 4) { 207 retStrs[1] = splitStr[4]; 208 } 209 } else { 210 if (splitStr.length < 3) { 211 throw new GeoWebCacheException("Unable to parse " + servletPath); 212 } 213 if (splitStr.length == 3) { 214 retStrs[0] = splitStr[2]; 215 } else { 216 retStrs[0] = splitStr[2]; 217 retStrs[1] = splitStr[3]; 218 } 184 185 retStrs[0] = splitStr[1]; 186 if(splitStr.length > 2) { 187 retStrs[1] = splitStr[2]; 219 188 } 220 189 return retStrs; … … 313 282 Service service = (Service) services.get(serviceStr); 314 283 if (service == null) { 284 if(serviceStr == null || serviceStr.length() == 0) { 285 serviceStr = ", try service/<name of service>"; 286 } else { 287 serviceStr = " \""+ serviceStr + "\""; 288 } 315 289 throw new GeoWebCacheException( 316 "Unable to find handler for service " + serviceStr);290 "Unable to find handler for service" + serviceStr); 317 291 } 318 292 return service; … … 330 304 * the actual error message, human readable 331 305 */ 332 private void writeError(HttpServletResponse response, int httpCode,306 private static void writeError(HttpServletResponse response, int httpCode, 333 307 String errorMsg) { 334 308 335 response.setContentType("text/ plain");309 response.setContentType("text/html"); 336 310 response.setStatus(httpCode); 337 311 … … 342 316 log.debug(errorMsg); 343 317 318 errorMsg = 319 "<html><body>\n" 320 +"<a id=\"logo\" href=\"http://geowebcache.org\">" 321 +"<img src=\"http://geowebcache.org/trac/chrome/site/geowebcache_logo.png\"" 322 +"height=\"100\" width=\"353\" border=\"0\"/>" 323 +"</a>\n" 324 +"<h4>"+httpCode+": "+errorMsg+"</h4>" 325 +"</body></html>\n"; 326 344 327 try { 345 328 OutputStream os = response.getOutputStream();
