/** * Services convert HTTP requests into the internal grid representation and specify what layer * the response should come from. * * <p>The application context is scanned for objects extending Service, thereby making it easy * to add new services. * * @return */ private Map<String, Service> loadServices() { log.info("Loading GWC Service extensions..."); List<Service> plugins = GeoWebCacheExtensions.extensions(Service.class); Map<String, Service> services = new HashMap<String, Service>(); // Give all service objects direct access to the tileLayerDispatcher for (Service aService : plugins) { services.put(aService.getPathName(), aService); } log.info( "Done loading GWC Service extensions. Found : " + new ArrayList<String>(services.keySet())); return services; }
conv = service.getConveyor(request, response); final String layerName = conv.getLayerId(); service.handleRequest(conv); } else { ResponseUtils.writeTile(
EasyMock.expect(testService.getPathName()).andStubReturn("testService"); EasyMock.expect(tld.getTileLayer("testLayer")).andStubReturn(layer); EasyMock.expect(layer.isEnabled()).andStubReturn(true); EasyMock.expectLastCall().anyTimes(); EasyMock.expect( testService.getConveyor( EasyMock.eq(request), EasyMock.anyObject(HttpServletResponse.class)))
protected static void writeTileResponse( ConveyorTile conv, boolean writeExpiration, RuntimeStats stats, String mimeTypeOverride) { HttpServletResponse response = conv.servletResp; Resource data = conv.getBlob(); String mimeStr; if (mimeTypeOverride == null) { mimeStr = conv.getMimeType().getMimeType(); } else { mimeStr = mimeTypeOverride; } response.setCharacterEncoding("utf-8"); response.setStatus((int) conv.getStatus()); TileLayer layer = conv.getLayer(); if (layer != null) { layer.setExpirationHeader(conv.servletResp, (int) conv.getTileIndex()[2]); } if (writeExpiration) { conv.getLayer().setExpirationHeader(response, (int) conv.getTileIndex()[2]); } response.setContentType(mimeStr);
public ConveyorTile getConveyor(HttpServletRequest request, HttpServletResponse response) throws ServiceException { String layerId = super.getLayersParameter(request);
EasyMock.expect(testService.getPathName()).andStubReturn("testService"); EasyMock.expect(tld.getTileLayer("testLayer")).andStubReturn(layer); EasyMock.expect(layer.isEnabled()).andStubReturn(true); EasyMock.expectLastCall().anyTimes(); EasyMock.expect( testService.getConveyor( EasyMock.eq(request), EasyMock.anyObject(HttpServletResponse.class)))
/** NB The following code is shared across Google Maps, Mobile Google Maps and Virtual Earth */ public void handleRequest(ConveyorTile tile) throws GeoWebCacheException { if (tile.getHint() != null) { // boolean requestTiled = true; if (!tile.getHint().equals("not_cached,not_metatiled") && !tile.getHint().equals("not_cached")) { throw new GeoWebCacheException("Hint " + tile.getHint() + " is not known."); } TileLayer tl = tld.getTileLayer(tile.getLayerId()); if (tl == null) { throw new GeoWebCacheException("Unknown layer " + tile.getLayerId()); } if (!tl.isCacheBypassAllowed().booleanValue()) { throw new GeoWebCacheException( "Layer " + tile.getLayerId() + " is not configured to allow bypassing the cache."); } tile.setTileLayer(tl); tl.getNoncachedTile(tile); Service.writeTileResponse(tile, false); } }
public ConveyorTile getConveyor(HttpServletRequest request, HttpServletResponse response) throws ServiceException { String layerId = super.getLayersParameter(request);
public boolean isServiceEnabled(final Service service) { return getConfig().isEnabled(service.getPathName()); }
/** NB The following code is shared across Google Maps, Mobile Google Maps and Virtual Earth */ public void handleRequest(ConveyorTile tile) throws GeoWebCacheException { if (tile.getHint() != null) { // boolean requestTiled = true; if (!tile.getHint().equals("not_cached,not_metatiled") && !tile.getHint().equals("not_cached")) { throw new GeoWebCacheException("Hint " + tile.getHint() + " is not known."); } TileLayer tl = tld.getTileLayer(tile.getLayerId()); if (tl == null) { throw new GeoWebCacheException("Unknown layer " + tile.getLayerId()); } if (!tl.isCacheBypassAllowed().booleanValue()) { throw new GeoWebCacheException( "Layer " + tile.getLayerId() + " is not configured to allow bypassing the cache."); } tile.setTileLayer(tl); tl.getNoncachedTile(tile); Service.writeTileResponse(tile, false); } }
public ConveyorTile getConveyor(HttpServletRequest request, HttpServletResponse response) throws ServiceException, GeoWebCacheException { String layerId = super.getLayersParameter(request);
public boolean isServiceEnabled(final Service service) { return getConfig().isEnabled(service.getPathName()); }
/** NB The following code is shared across Google Maps, Mobile Google Maps and Virtual Earth */ public void handleRequest(ConveyorTile tile) throws GeoWebCacheException { if (tile.getHint() != null) { // boolean requestTiled = true; if (!tile.getHint().equals("not_cached,not_metatiled") && !tile.getHint().equals("not_cached")) { throw new GeoWebCacheException("Hint " + tile.getHint() + " is not known."); } TileLayer tl = tld.getTileLayer(tile.getLayerId()); if (tl == null) { throw new GeoWebCacheException("Unknown layer " + tile.getLayerId()); } if (!tl.isCacheBypassAllowed().booleanValue()) { throw new GeoWebCacheException( "Layer " + tile.getLayerId() + " is not configured to allow bypassing the cache."); } tile.setTileLayer(tl); tl.getNoncachedTile(tile); Service.writeTileResponse(tile, false); } }
Map<String, String[]> params = request.getParameterMap(); String layerId = super.getLayersParameter(request);
/** * Intercepts the {@code getConveyor} and {@code handleRequest} calls to a {@link Service} * instance and checks whether the service is enabled. * * @see * org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation) */ public Object invoke(final MethodInvocation invocation) throws Throwable { final String methodName = invocation.getMethod().getName(); if ("getConveyor".equals(methodName) || "handleRequest".equals(methodName)) { final org.geowebcache.service.Service service = (Service) invocation.getThis(); boolean serviceEnabled; if (service.getPathName().equals("wmts")) { serviceEnabled = geoServer.getService(WMTSInfo.class).isEnabled(); } else { serviceEnabled = gwcFacade.isServiceEnabled(service); } if (!serviceEnabled) { throw new org.geowebcache.service.HttpErrorCodeException( 400, "Service is disabled"); } } return invocation.proceed(); } }
/** * NB The following code is shared across Google Maps, Mobile Google Maps and Virtual Earth */ public void handleRequest(ConveyorTile tile) throws GeoWebCacheException { if (tile.getHint() != null) { //boolean requestTiled = true; if (tile.getHint().equals("not_cached,not_metatiled")) { //requestTiled = false; } else if (!tile.getHint().equals("not_cached")) { throw new GeoWebCacheException("Hint " + tile.getHint() + " is not known."); } TileLayer tl = tld.getTileLayer(tile.getLayerId()); if (tl == null) { throw new GeoWebCacheException("Unknown layer " + tile.getLayerId()); } if(! tl.isCacheBypassAllowed().booleanValue()) { throw new GeoWebCacheException("Layer " + tile.getLayerId() + " is not configured to allow bypassing the cache."); } tile.setTileLayer(tl); tl.getNoncachedTile(tile); Service.writeTileResponse(tile, false); } }
Map<String, String[]> params = request.getParameterMap(); String layerId = super.getLayersParameter(request);
public void testIsServiceEnabled() { Service service = mock(Service.class); when(service.getPathName()).thenReturn("wms"); defaults.setWMSCEnabled(true); assertTrue(mediator.isServiceEnabled(service)); defaults.setWMSCEnabled(false); assertFalse(mediator.isServiceEnabled(service)); when(service.getPathName()).thenReturn("tms"); defaults.setTMSEnabled(true); assertTrue(mediator.isServiceEnabled(service)); defaults.setTMSEnabled(false); assertFalse(mediator.isServiceEnabled(service)); when(service.getPathName()).thenReturn("wmts"); defaults.setWMTSEnabled(true); assertTrue(mediator.isServiceEnabled(service)); defaults.setWMTSEnabled(false); assertFalse(mediator.isServiceEnabled(service)); when(service.getPathName()).thenReturn("somethingElse"); assertTrue(mediator.isServiceEnabled(service)); }
/** * NB The following code is shared across Google Maps, Mobile Google Maps and Virtual Earth */ public void handleRequest(ConveyorTile tile) throws GeoWebCacheException { if (tile.getHint() != null) { // boolean requestTiled = true; if (tile.getHint().equals("not_cached,not_metatiled")) { // requestTiled = false; } else if (!tile.getHint().equals("not_cached")) { throw new GeoWebCacheException("Hint " + tile.getHint() + " is not known."); } TileLayer tl = tld.getTileLayer(tile.getLayerId()); if (tl == null) { throw new GeoWebCacheException("Unknown layer " + tile.getLayerId()); } if (!tl.isCacheBypassAllowed().booleanValue()) { throw new GeoWebCacheException("Layer " + tile.getLayerId() + " is not configured to allow bypassing the cache."); } tile.setTileLayer(tl); tl.getNoncachedTile(tile); Service.writeTileResponse(tile, false); } }
public ConveyorTile getConveyor(HttpServletRequest request, HttpServletResponse response) throws ServiceException, GeoWebCacheException { String layerId = super.getLayersParameter(request);