/** * Completely and persistently eliminates, including the cached contents, the given tile layers. * * @param tileLayerNames */ public void removeTileLayers(final List<String> tileLayerNames) { checkNotNull(tileLayerNames); Set<Configuration> confsToSave = new HashSet<Configuration>(); for (String tileLayerName : tileLayerNames) { Configuration configuration = tld.removeLayer(tileLayerName); if (configuration != null) { confsToSave.add(configuration); } } for (Configuration conf : confsToSave) { try { conf.save(); } catch (IOException e) { log.log(Level.WARNING, "Error saving GWC Configuration " + conf.getIdentifier(), e); } } }
/** * Completely and persistently eliminates, including the cached contents, the given tile layers. * * @param tileLayerNames */ public void removeTileLayers(final List<String> tileLayerNames) { checkNotNull(tileLayerNames); for (String tileLayerName : tileLayerNames) { try { tld.removeLayer(tileLayerName); } catch (IllegalArgumentException e) { log.log( Level.WARNING, "Error saving GWC Configuration " + tld.getConfiguration(tileLayerName).getIdentifier(), e); } } }
for (TileLayer tl : getLayerList()) { if (Objects.nonNull(tl.getGridSubset(gridsetToRemove))) { this.removeLayer(tl.getName()); deletedLayers.add(tl);
@Test public void testRemoveLayerException() { try { tileLayerDispatcher.removeLayer(null); fail("Expected failure when trying to remove null layer"); } catch (Exception e) { } try { tileLayerDispatcher.removeLayer("nonexistantLayer"); fail("Expected failure when trying to remove nonexistant layer"); } catch (Exception e) { } }
/** * DELETE removes an existing layer * * @param req * @param resp * @throws RestletException */ private void doDelete(Request req, Response resp) throws RestletException, GeoWebCacheException { String layerName = (String) req.getAttributes().get("layer"); findTileLayer(layerName, layerDispatcher); try { Configuration configuration = layerDispatcher.removeLayer(layerName); if (configuration == null) { throw new RestletException("Configuration to remove layer not found", Status.SERVER_ERROR_INTERNAL); } configuration.save(); } catch (IOException e) { throw new RestletException(e.getMessage(), Status.SERVER_ERROR_INTERNAL, e); } }
layerDispatcher.removeLayer(layerName); } catch (IllegalArgumentException e) { throw new RestException(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR, e);
public void testRemoveTileLayers() throws Exception { try { mediator.removeTileLayers(null); } catch (NullPointerException e) { assertTrue(true); } when(tld.removeLayer(eq(tileLayer.getName()))).thenReturn(config); when(tld.removeLayer(eq(tileLayerGroup.getName()))).thenReturn(config); List<String> layerNames = Arrays.asList(tileLayer.getName(), tileLayerGroup.getName()); mediator.removeTileLayers(layerNames); verify(tld, times(1)).removeLayer(eq(tileLayer.getName())); verify(tld, times(1)).removeLayer(eq(tileLayerGroup.getName())); verify(config, times(1)).save(); }
@Test public void testRemoveLayer() { String layerToRemove = GWCConfigIntegrationTestData.LAYER_TOPP_STATES; tileLayerDispatcher.removeLayer(layerToRemove); assertFalse(tileLayerDispatcher.getLayerNames().contains(layerToRemove)); try { tileLayerDispatcher.getTileLayer(layerToRemove); fail("Expected exception when trying to get removed layer"); } catch (GeoWebCacheException e) { } }
@Test public void testRemoveGridset() throws IOException { String gridsetToRemove = GWCConfigIntegrationTestData.GRIDSET_EPSG2163; // remove the only layer referencing the gridset first tileLayerDispatcher.removeLayer(GWCConfigIntegrationTestData.LAYER_TOPP_STATES); tileLayerDispatcher.removeGridSet(gridsetToRemove); assertFalse(gridSetBroker.getNames().contains(gridsetToRemove)); assertNull(gridSetBroker.get(gridsetToRemove)); }
layerDispatcher.removeLayer("topp:states");
layerDispatcher.removeLayer("topp:states");