/** * @param gridSet * @throws GeoWebCacheException */ private synchronized void addOrReplaceGridSet(final XMLGridSet gridSet) throws IllegalArgumentException { final String gridsetName = gridSet.getName(); List<XMLGridSet> xmlGridSets = getGwcConfig().getGridSets(); xmlGridSets.removeIf(xgs -> gridsetName.equals(xgs.getName())); xmlGridSets.add(gridSet); }
@Override public synchronized void removeGridSet(String gridSetName) { GridSet gsRemoved = getGridSetsInternal().remove(gridSetName); XMLGridSet xgsRemoved = null; for (Iterator<XMLGridSet> it = getGwcConfig().getGridSets().iterator(); it.hasNext(); ) { XMLGridSet xgs = it.next(); if (gridSetName.equals(xgs.getName())) { it.remove(); xgsRemoved = xgs; break; } } assert Objects.isNull(gsRemoved) == Objects.isNull(xgsRemoved); if (Objects.isNull(gsRemoved)) { throw new NoSuchElementException( "Could not remeove GridSet " + gridSetName + " as it does not exist"); } try { save(); } catch (IOException ex) { getGridSetsInternal().put(gridSetName, gsRemoved); getGwcConfig().getGridSets().add(xgsRemoved); throw new ConfigurationPersistenceException( "Could not persist removal of Gridset " + gridSetName, ex); } }
private void loadGridSets() { if (getGwcConfig().getGridSets() != null) { this.gridSets = getGwcConfig() .getGridSets() .stream() .map( (xmlGridSet) -> { if (log.isDebugEnabled()) { log.debug("Reading " + xmlGridSet.getName()); } GridSet gridSet = xmlGridSet.makeGridSet(); log.info("Read GridSet " + gridSet.getName()); return gridSet; }) .collect( Collectors.toMap( GridSet::getName, Function.identity(), (GridSet x, GridSet y) -> { throw new IllegalStateException( "Gridsets with duplicate name " + x.getName()); }, HashMap::new)); } }
@Override public synchronized void addGridSet(GridSet gridSet) { validateGridSet(gridSet); GridSet old = getGridSetsInternal().get(gridSet.getName()); if (old != null) { throw new IllegalArgumentException("GridSet " + gridSet.getName() + " already exists"); } assert getGwcConfig() .getGridSets() .stream() .noneMatch(xgs -> xgs.getName().equals(gridSet.getName())); try { saveGridSet(gridSet); } catch (IOException e) { throw new ConfigurationPersistenceException(e); } getGridSetsInternal().put(gridSet.getName(), gridSet); }
@Override public synchronized void modifyGridSet(GridSet gridSet) throws NoSuchElementException, IllegalArgumentException, UnsupportedOperationException { validateGridSet(gridSet); GridSet old = getGridSetsInternal().get(gridSet.getName()); if (old == null) { throw new NoSuchElementException("GridSet " + gridSet.getName() + " does not exist"); } assert getGwcConfig() .getGridSets() .stream() .anyMatch(xgs -> xgs.getName().equals(gridSet.getName())); try { saveGridSet(gridSet); } catch (IOException e) { throw new ConfigurationPersistenceException(e); } this.getGridSetsInternal().put(gridSet.getName(), gridSet); }