public synchronized void removeGridSet(String gridsetToRemove) { if (StreamSupport.stream(getLayerList().spliterator(), true) .anyMatch(g -> Objects.nonNull(g.getGridSubset(gridsetToRemove)))) { throw new IllegalStateException( "Can not remove gridset " + gridsetToRemove + " as it is used by layers"); } gridSetBroker.removeGridSet(gridsetToRemove); }
/** * Blindly removes a gridset from this gridset broker. * * <p>This method doesn't check whether there's any layer referencing the gridset nor removes it * from the {@link XMLConfiguration}. For such a thing, check {@link * TileLayerDispatcher#removeGridset(String)}, which cascades to this method. * * @param gridSetName * @return */ public synchronized GridSet remove(final String gridSetName) { return getGridSet(gridSetName) .map( g -> { removeGridSet(gridSetName); return g; }) .orElse(null); }
@RequestMapping(path = "/{gridSetName}", method = RequestMethod.DELETE) public void gridSetDelete(@PathVariable String gridSetName) { if (broker.get(gridSetName) != null) { broker.removeGridSet(gridSetName); } else { throw new RestException( String.format( "Failed to remove GridSet. A GridSet with name \"%s\" does not exist.", gridSetName), HttpStatus.NOT_FOUND); } } }
gridSetBroker.removeGridSet(gridsetToRemove); } catch (RuntimeException exceptionOnRestore) { try {
@Test public void testRemoveGridset() throws IOException { String gridsetToRemove = GWCConfigIntegrationTestData.GRIDSET_EPSG2163; // remove the only layer referencing the gridset first gridSetBroker.removeGridSet(gridsetToRemove); assertThat(gridSetBroker.getGridSetNames(), not(hasItem(gridsetToRemove))); assertThat(gridSetBroker.getGridSet(gridsetToRemove), notPresent()); } }