/** @see TileLayerConfiguration#getTileLayers() */ @Deprecated public List<TileLayer> getTileLayers() { return Collections.unmodifiableList(getGwcConfig().getLayers()); }
/** @see TileLayerConfiguration#getLayers() */ public Collection<TileLayer> getLayers() { return Collections.unmodifiableList(getGwcConfig().getLayers()); }
private void updateLayers() { Map<String, TileLayer> buff = new HashMap<String, TileLayer>(); for (TileLayer layer : getGwcConfig().getLayers()) { buff.put(layer.getName(), layer); } this.layers = buff; }
/** * @return {@code true} if the layer was removed, {@code false} if no such layer exists * @see TileLayerConfiguration#removeLayer(java.lang.String) */ public synchronized void removeLayer(final String layerName) throws NoSuchElementException, IllegalArgumentException { final TileLayer tileLayer = findLayer(layerName); if (tileLayer == null) { throw new NoSuchElementException("Layer " + layerName + " does not exist"); } boolean removed = getGwcConfig().getLayers().remove(tileLayer); if (removed) { updateLayers(); } else { throw new NoSuchElementException("Layer " + tileLayer.getName() + " does not exist"); } try { save(); } catch (IOException e) { // If save fails, try to revert the removal to maintain a consistent state. if (getGwcConfig().getLayers().add(tileLayer)) { updateLayers(); } throw new IllegalArgumentException("Unable to remove layer " + tileLayer, e); } }
/** * Method responsible for modifying an existing layer. * * @param tl the new layer to overwrite the existing layer * @throws NoSuchElementException * @see TileLayerConfiguration#modifyLayer(org.geowebcache.layer.TileLayer) */ public synchronized void modifyLayer(TileLayer tl) throws NoSuchElementException { TileLayer previous = findLayer(tl.getName()); if (!canSaveIfNotTransient(tl)) { throw new IllegalArgumentException( "Can't add layers of type " + tl.getClass().getName()); } getGwcConfig().getLayers().remove(previous); initialize(tl); getGwcConfig().getLayers().add(tl); updateLayers(); try { save(); } catch (IOException e) { // If save fails, try to revert the change to maintain a consistent state. getGwcConfig().getLayers().remove(tl); initialize(previous); getGwcConfig().getLayers().add(previous); updateLayers(); throw new IllegalArgumentException("Unable to modify layer " + tl.getName(), e); } }
/** * @param tl the layer to add to this configuration * @return * @throws IllegalArgumentException if a layer named the same than {@code tl} already exists * @see TileLayerConfiguration#addLayer(org.geowebcache.layer.TileLayer) */ public synchronized void addLayer(TileLayer tl) throws IllegalArgumentException { if (tl == null) { throw new NullPointerException(); } if (!canSaveIfNotTransient(tl)) { throw new IllegalArgumentException( "Can't add layers of type " + tl.getClass().getName()); } if (getLayer(tl.getName()).isPresent()) { throw new IllegalArgumentException("Layer '" + tl.getName() + "' already exists"); } initialize(tl); getGwcConfig().getLayers().add(tl); updateLayers(); try { save(); } catch (IOException e) { // If save fails, try to revert the change to maintain a consistent state. if (getGwcConfig().getLayers().remove(tl)) { updateLayers(); } throw new ConfigurationPersistenceException("Unable to add layer " + tl.getName(), e); } }
public void afterPropertiesSet() throws GeoWebCacheException { if (gridSetBroker == null) { throw new IllegalStateException("GridSetBroker has not been set"); } if (resourceProvider.hasInput()) { this.setGwcConfig(loadConfiguration()); } log.info("Initializing GridSets from " + getIdentifier()); getGridSetsInternal(); log.info("Initializing layers from " + getIdentifier()); // Loop over the layers and set appropriate values for (TileLayer layer : getGwcConfig().getLayers()) { if (layer == null) { throw new IllegalStateException(getIdentifier() + " contains a null layer"); } initialize(layer); } updateLayers(); }