/** * @param layerName * @return the tile layer named {@code layerName} * @throws IllegalArgumentException if no {@link TileLayer} named {@code layeName} is found */ public TileLayer getTileLayerByName(String layerName) throws IllegalArgumentException { TileLayer tileLayer; try { tileLayer = tld.getTileLayer(layerName); } catch (GeoWebCacheException e) { throw new IllegalArgumentException(e.getMessage(), Throwables.getRootCause(e)); } return tileLayer; }
/** * @param layerName * @return the tile layer named {@code layerName} * @throws IllegalArgumentException * if no {@link TileLayer} named {@code layeName} is found */ public TileLayer getTileLayerByName(String layerName) throws IllegalArgumentException { TileLayer tileLayer; try { tileLayer = tld.getTileLayer(layerName); } catch (GeoWebCacheException e) { throw new IllegalArgumentException(e.getMessage(), Throwables.getRootCause(e)); } return tileLayer; }
public boolean tryCacheFetch(ConveyorTile tile) { int expireCache = this.getExpireCache((int) tile.getTileIndex()[2]); if (expireCache != GWCVars.CACHE_DISABLE_CACHE) { try { return tile.retrieve(expireCache * 1000L); } catch (GeoWebCacheException gwce) { log.error(gwce.getMessage()); tile.setErrorMsg(gwce.getMessage()); return false; } } return false; }
private boolean tryCacheFetch(ConveyorTile tile) { int expireCache = this.getExpireCache((int) tile.getTileIndex()[2]); if (expireCache != GWCVars.CACHE_DISABLE_CACHE) { try { return tile.retrieve(expireCache * 1000L); } catch (GeoWebCacheException gwce) { LOGGER.info(gwce.getMessage()); tile.setErrorMsg(gwce.getMessage()); return false; } } return false; }
private boolean tryCacheFetch(ConveyorTile tile) { int expireCache = this.getExpireCache((int) tile.getTileIndex()[2]); if (expireCache != GWCVars.CACHE_DISABLE_CACHE) { try { return tile.retrieve(expireCache * 1000L); } catch (GeoWebCacheException gwce) { LOGGER.info(gwce.getMessage()); tile.setErrorMsg(gwce.getMessage()); return false; } } return false; }
private void capabilityLayerOuter(StringBuilder str) { str.append(" <Layer>\n"); str.append(" <Title>GeoWebCache WMS</Title>\n"); str.append(" <Abstract>Note that not all GeoWebCache instances provide a full WMS service.</Abstract>\n"); str.append(" <LatLonBoundingBox minx=\"-180.0\" miny=\"-90.0\" maxx=\"180.0\" maxy=\"90.0\"/>\n"); Iterable<TileLayer> layerIter = tld.getLayerList(); for (TileLayer layer : layerIter) { if (!layer.isEnabled()) { continue; } try { capabilityLayerInner(str, layer); } catch (GeoWebCacheException e) { log.error(e.getMessage()); } } str.append(" </Layer>\n"); }
public GWCTask call() { try { task.doAction(); } catch (GeoWebCacheException gwce) { log.error(gwce.getMessage(), gwce); } catch (InterruptedException e) { log.info(task.getType() + " task #" + task.getTaskId() + " has been interrupted"); Thread.currentThread().interrupt(); } catch (RuntimeException e) { log.error(task.getType() + " task #" + task.getTaskId() + " failed", e); } return task; } }
/** * METHOD that handles the seeding/truncating task from the POST method. * * @param layerName * @param obj */ protected void handleRequest(String layerName, Object obj) { final SeedRequest sr = (SeedRequest) obj; try { seeder.seed(layerName, sr); } catch (IllegalArgumentException e) { throw new RestException(e.getMessage(), HttpStatus.BAD_REQUEST); } catch (GeoWebCacheException e) { throw new RestException(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } }
/** * Fully truncates the given layer, including any ParameterFilter * * @param layerName */ public void truncate(final String layerName) { checkNotNull(layerName, "layerName is null"); // easy, no need to issue truncate tasks TileLayer layer; try { layer = tld.getTileLayer(layerName); } catch (GeoWebCacheException e) { log.log(Level.INFO, e.getMessage(), e); return; } final Set<String> gridSubsets = layer.getGridSubsets(); for (String gridSetId : gridSubsets) { deleteCacheByGridSetId(layerName, gridSetId); } }
/** * Fully truncates the given layer, including any ParameterFilter * * @param layerName */ public void truncate(final String layerName) { checkNotNull(layerName, "layerName is null"); // easy, no need to issue truncate tasks TileLayer layer; try { layer = tld.getTileLayer(layerName); } catch (GeoWebCacheException e) { log.log(Level.INFO, e.getMessage(), e); return; } final Set<String> gridSubsets = layer.getGridSubsets(); for (String gridSetId : gridSubsets) { deleteCacheByGridSetId(layerName, gridSetId); } }
public ResponseEntity<?> handleGet(HttpServletRequest request, String layer) { TileLayer tl; try { tl = seeder.findTileLayer(layer); } catch (GeoWebCacheException e) { throw new RestException(e.getMessage(), HttpStatus.BAD_REQUEST); } return handleDoGet(tl, false); }
public void doGet(Request request, Response response) throws RestletException { // String layerName = (String) request.getAttributes().get("layer"); String layerName = null; try { layerName = URLDecoder.decode((String) request.getAttributes().get("layer"), "UTF-8"); } catch (UnsupportedEncodingException uee) { } TileLayer tl; try { tl = seeder.findTileLayer(layerName); } catch (GeoWebCacheException e) { throw new RestletException(e.getMessage(), Status.CLIENT_ERROR_BAD_REQUEST); } handleDoGet(response, tl, false); }
protected static TileLayer findTileLayer(String layerName, TileLayerDispatcher layerDispatcher) { if (layerName == null || layerName.length() == 0) { throw new RestletException("Layer not specified", Status.CLIENT_ERROR_BAD_REQUEST); } if (!layerDispatcher.layerExists(layerName)) { throw new RestletException("Unknown layer: " + layerName, Status.CLIENT_ERROR_NOT_FOUND); } TileLayer layer; try { layer = layerDispatcher.getTileLayer(layerName); } catch (GeoWebCacheException gwce) { throw new RestletException("Encountered error: " + gwce.getMessage(), Status.SERVER_ERROR_INTERNAL); } return layer; } }
protected void handleRequest(HttpServletRequest req, HttpServletResponse resp, Object obj) { MassTruncateRequest mtr = (MassTruncateRequest) obj; try { if (!mtr.doTruncate(broker, breeder)) { throw new RestException("Truncation failed", HttpStatus.INTERNAL_SERVER_ERROR); } } catch (IllegalArgumentException e) { throw new RestException(e.getMessage(), HttpStatus.BAD_REQUEST); } catch (StorageException e) { throw new RestException(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } catch (GeoWebCacheException e) { throw new RestException(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } }
private BlobStore store(String layerId) throws StorageException { LiveStore store; try { store = forLayer(layerId); } catch (GeoWebCacheException e) { throw new StorageException(e.getMessage(), e); } if (!store.config.isEnabled()) { throw new StorageException( "Attempted to use a blob store that's disabled: " + store.config.getName()); } return store.liveInstance; }
private void capabilityLayerOuter(XMLBuilder xml) throws IOException { xml.indentElement("Layer"); xml.simpleElement("Title", "GeoWebCache WMS", true); xml.simpleElement( "Abstract", "Note that not all GeoWebCache instances provide a full WMS service.", true); xml.latLonBoundingBox(-180.0, -90.0, 180.0, 90.0); Iterable<TileLayer> layerIter = tld.getLayerList(); for (TileLayer layer : layerIter) { if (!layer.isEnabled() || !layer.isAdvertised()) { continue; } try { capabilityLayerInner(xml, layer); } catch (GeoWebCacheException e) { log.error(e.getMessage()); } } xml.endElement(); }
protected void runUpdate(RequestFilter filter, TileLayer tl) throws IOException, RestletException { if(! (filter instanceof WMSRasterFilter)) { throw new RestletException("The filter " + filter.getName() + " is not a WMSRasterFilter.", Status.CLIENT_ERROR_BAD_REQUEST); } WMSRasterFilter wmsFilter = (WMSRasterFilter) filter; // Check that the SRS makes sense if (tl.getGridSubset(gridSetId) == null) { throw new RestletException("The filter " + wmsFilter.getName() + " is associated with a layer that does not support " + gridSetId, Status.CLIENT_ERROR_BAD_REQUEST); } // Run the actual update try { wmsFilter.update(tl, gridSetId, zoomStart, zoomStop); } catch (GeoWebCacheException e) { throw new RestletException("Error updating " + wmsFilter.getName() + ": " + e.getMessage(), Status.SERVER_ERROR_INTERNAL); } } }
public void runUpdate(RequestFilter filter, TileLayer tl) throws IOException, RestException { if (!(filter instanceof WMSRasterFilter)) { throw new RestException( "The filter " + filter.getName() + " is not a WMSRasterFilter.", HttpStatus.BAD_REQUEST); } WMSRasterFilter wmsFilter = (WMSRasterFilter) filter; // Check that the SRS makes sense if (tl.getGridSubset(gridSetId) == null) { throw new RestException( "The filter " + wmsFilter.getName() + " is associated with a layer that does not support " + gridSetId, HttpStatus.BAD_REQUEST); } // Run the actual update try { wmsFilter.update(tl, gridSetId, zoomStart, zoomStop); } catch (GeoWebCacheException e) { throw new RestException( "Error updating " + wmsFilter.getName() + ": " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } } }
protected void runUpdate(RequestFilter filter, TileLayer tl) throws IOException, RestletException { if(! (filter instanceof WMSRasterFilter)) { throw new RestletException("The filter " + filter.getName() + " is not a WMSRasterFilter.", Status.CLIENT_ERROR_BAD_REQUEST); } WMSRasterFilter wmsFilter = (WMSRasterFilter) filter; // Check that the SRS makes sense if (tl.getGridSubset(gridSetId) == null) { throw new RestletException("The filter " + wmsFilter.getName() + " is associated with a layer that does not support " + gridSetId, Status.CLIENT_ERROR_BAD_REQUEST); } // Run the actual update try { for (int z = zoomStart; z <= zoomStop; z++) { wmsFilter.setMatrix(tl, gridSetId, z, true); } } catch (GeoWebCacheException e) { throw new RestletException("Error updating " + wmsFilter.getName() + ": " + e.getMessage(), Status.SERVER_ERROR_INTERNAL); } } }
public void handle(Request request, Response response) { Method met = request.getMethod(); try { if (met.equals(Method.GET)) { doGet(request, response); } else if (met.equals(Method.POST)) { try { doPost(request, response); } catch (GeoWebCacheException e) { throw new RestletException(e.getMessage(), Status.CLIENT_ERROR_BAD_REQUEST); } } else { throw new RestletException("Method not allowed", Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); } } catch (RestletException re) { response.setEntity(re.getRepresentation()); response.setStatus(re.getStatus()); } }