/** * 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(); if (!gwcFacade.isServiceEnabled(service)) { throw new org.geowebcache.service.HttpErrorCodeException(400, "Service is disabled"); } } return invocation.proceed(); }
/** * 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(); } }
mimeType = MimeType.createFromExtension(fileExtension); if (mimeType == null) { throw new HttpErrorCodeException(400, "Unsupported format: " + fileExtension); GridSubset gridSubset = tileLayer.getGridSubset(gridSetId); if (gridSubset == null) { throw new HttpErrorCodeException(400, "Unsupported gridset: " + gridSetId); throw new HttpErrorCodeException(404, e.getMessage(), e); } catch (GeoWebCacheException e) { throw new HttpErrorCodeException(400, e.getMessage(), e);
public Conveyor getRestConveyor(HttpServletRequest request, HttpServletResponse response) throws GeoWebCacheException, OWSException { final String path = request.getPathInfo(); // special simpler case for GetCapabilities if (path.endsWith("/service/wmts/rest/WMTSCapabilities.xml")) { ConveyorTile tile = new ConveyorTile(sb, null, request, response); tile.setHint(GET_CAPABILITIES); tile.setRequestHandler(ConveyorTile.RequestHandler.SERVICE); return tile; } // all other paths are handled via the RestRequest enumeration, matching patterns and // extracting variables for (RestRequest restRequest : RestRequest.values()) { Map<String, String> values = restRequest.toKVP(request); if (values != null) { return getKvpConveyor(request, response, values); } } // we implement all WMTS supported request, this means that the provided request name is // invalid throw new HttpErrorCodeException(404, "Unknown resource " + request.getPathInfo()); }
throw new HttpErrorCodeException(HttpServletResponse.SC_BAD_REQUEST, "Layer name not provided"); layerGroup = catalog.getLayerGroup(id); if (layerGroup == null) { throw new HttpErrorCodeException(HttpServletResponse.SC_BAD_REQUEST, "No GeoServer Layer or LayerGroup exists with id '" + id + "'"); layerGroup = catalog.getLayerGroupByName(name); if (layerGroup == null) { throw new HttpErrorCodeException(HttpServletResponse.SC_NOT_FOUND, "GeoServer Layer or LayerGroup '" + name + "' not found"); throw new HttpErrorCodeException(HttpServletResponse.SC_BAD_REQUEST, "Layer with id '" + id + "' found but name does not match: '" + name + "'/'" + actualName + "'");