/** @see ServerConfiguration#setCacheBypassAllowed(Boolean) */ @Override public void setCacheBypassAllowed(Boolean cacheBypassAllowed) throws IOException { gwcConfig.setCacheBypassAllowed(cacheBypassAllowed); save(); }
/** @see ServerConfiguration#setBackendTimeout(Integer) */ @Override public void setBackendTimeout(Integer backendTimeout) throws IOException { gwcConfig.setBackendTimeout(backendTimeout); save(); }
/** * Can be used to force WMTS service implementation to be strictly compliant with the * correspondent CITE tests. * * @param wmtsCiteStrictCompliant TRUE or FALSE, activating or deactivation CITE strict * compliance mode for WMTS */ public void setWmtsCiteCompliant(Boolean wmtsCiteStrictCompliant) throws IOException { if (gwcConfig != null) { // activate or deactivate CITE strict compliance mode for WMTS implementation gwcConfig.setWmtsCiteCompliant(wmtsCiteStrictCompliant); } save(); }
/** * @see ServerConfiguration#setServiceInformation(ServiceInformation); * @param serviceInfo */ public void setServiceInformation(ServiceInformation serviceInfo) throws IOException { getGwcConfig().setServiceInformation(serviceInfo); save(); }
/** * @see ServerConfiguration#setFullWMS(Boolean) * @param isFullWMS */ @Override public void setFullWMS(Boolean isFullWMS) throws IOException { getGwcConfig().setFullWMS(isFullWMS); save(); }
/** * @see ServerConfiguration#setRuntimeStatsEnabled(Boolean) * @param isEnabled */ public void setRuntimeStatsEnabled(Boolean isEnabled) throws IOException { getGwcConfig().setRuntimeStats(isEnabled); save(); }
/** * @see ServerConfiguration#setLockProvider(LockProvider) * @param lockProvider */ @Override public void setLockProvider(LockProvider lockProvider) throws IOException { getGwcConfig().setLockProvider(lockProvider); save(); }
private void saveGridSet(GridSet gridSet) throws IOException { addOrReplaceGridSet(new XMLGridSet(gridSet)); save(); }
@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); } }
save(); } catch (IOException ioe) {
/** * @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); } }
save(); } catch (IOException ioe) {
save(); } catch (IOException ioe) {
/** * @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); } }
/** * 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); } }
mainConfig.save(); getGridSetBroker().remove(oldGridSetName); getGridSetBroker().put(newGridSet);
public void testModifyGridsetNoNeedToTruncate() throws Exception { final String oldName = "EPSG:4326"; final String newName = "MyEPSG:4326"; final GridSet oldGridset = gridSetBroker.get(oldName); final GridSet newGridset; { XMLGridSet xmlGridSet = new XMLGridSet(oldGridset); xmlGridSet.setName(newName); newGridset = xmlGridSet.makeGridSet(); } XMLConfiguration xmlConfig = mock(XMLConfiguration.class); mediator = spy(mediator); when(mediator.getXmlConfiguration()).thenReturn(xmlConfig); assertNotNull(tileLayer.getGridSubset(oldName)); assertNotNull(tileLayerGroup.getGridSubset(oldName)); when(tld.getConfiguration(same(tileLayer))).thenReturn(config); when(tld.getConfiguration(same(tileLayerGroup))).thenReturn(config); mediator.modifyGridSet(oldName, newGridset); assertNull(tileLayer.getGridSubset(oldName)); assertNull(tileLayerGroup.getGridSubset(oldName)); assertNotNull(tileLayer.getGridSubset(newName)); assertNotNull(tileLayerGroup.getGridSubset(newName)); verify(xmlConfig, times(1)).removeGridset(eq(oldName)); verify(xmlConfig, times(1)).addOrReplaceGridSet(eq(new XMLGridSet(newGridset))); verify(xmlConfig, times(1)).save(); assertNull(gridSetBroker.get(oldName)); assertEquals(newGridset, gridSetBroker.get(newName)); verify(config, times(1)).save(); }