Skip to content

Commit

Permalink
Update CatalogConfiguration to conform to new TileLayerDispatcher API
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarsballe committed Jan 2, 2018
1 parent b3c8dec commit 9e8d5a2
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 173 deletions.
56 changes: 12 additions & 44 deletions src/gwc/src/main/java/org/geoserver/gwc/GWC.java
Expand Up @@ -82,15 +82,14 @@
import org.geotools.referencing.CRS; import org.geotools.referencing.CRS;
import org.geotools.referencing.CRS.AxisOrder; import org.geotools.referencing.CRS.AxisOrder;
import org.geotools.util.logging.Logging; import org.geotools.util.logging.Logging;
import org.geowebcache.GeoWebCacheDispatcher;
import org.geowebcache.GeoWebCacheEnvironment; import org.geowebcache.GeoWebCacheEnvironment;
import org.geowebcache.GeoWebCacheException; import org.geowebcache.GeoWebCacheException;
import org.geowebcache.GeoWebCacheExtensions; import org.geowebcache.GeoWebCacheExtensions;
import org.geowebcache.config.BaseConfiguration; import org.geowebcache.config.BaseConfiguration;
import org.geowebcache.config.BlobStoreConfig; import org.geowebcache.config.BlobStoreConfig;
import org.geowebcache.config.BlobStoreConfigurationCatalog; import org.geowebcache.config.BlobStoreConfigurationCatalog;
import org.geowebcache.config.Configuration;
import org.geowebcache.config.ConfigurationException; import org.geowebcache.config.ConfigurationException;
import org.geowebcache.config.TileLayerConfiguration;
import org.geowebcache.config.XMLConfiguration; import org.geowebcache.config.XMLConfiguration;
import org.geowebcache.config.XMLGridSet; import org.geowebcache.config.XMLGridSet;
import org.geowebcache.conveyor.ConveyorTile; import org.geowebcache.conveyor.ConveyorTile;
Expand Down Expand Up @@ -310,7 +309,6 @@ public static void set(GWC instance) {


/** /**
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
* @see #initialize()
*/ */
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
GWC.set(this); GWC.set(this);
Expand Down Expand Up @@ -1345,12 +1343,7 @@ public LayerGroupInfo getLayerGroupById(String id) {
* Adds a layer to the {@link CatalogConfiguration} and saves it. * Adds a layer to the {@link CatalogConfiguration} and saves it.
*/ */
public void add(GeoServerTileLayer tileLayer) { public void add(GeoServerTileLayer tileLayer) {
BaseConfiguration config = tld.addLayer(tileLayer); tld.addLayer(tileLayer);
try {
config.save();
} catch (IOException e) {
propagate(getRootCause(e));
}
} }


/** /**
Expand Down Expand Up @@ -1521,7 +1514,7 @@ public synchronized void modifyGridSet(final String oldGridSetName, final GridSe


final int maxZoomLevel = newGridSet.getNumLevels() - 1; final int maxZoomLevel = newGridSet.getNumLevels() - 1;


Set<Configuration> saveConfigurations = new HashSet<Configuration>(); Set<TileLayerConfiguration> saveConfigurations = new HashSet<>();


// now restore the gridsubset for each layer // now restore the gridsubset for each layer
for (Map.Entry<TileLayer, GridSubset> entry : affectedLayers.entrySet()) { for (Map.Entry<TileLayer, GridSubset> entry : affectedLayers.entrySet()) {
Expand Down Expand Up @@ -1549,7 +1542,7 @@ public synchronized void modifyGridSet(final String oldGridSetName, final GridSe
layer.removeGridSubset(oldGridSetName); layer.removeGridSubset(oldGridSetName);
layer.addGridSubset(newGridSubset); layer.addGridSubset(newGridSubset);


Configuration config = tld.getConfiguration(layer); TileLayerConfiguration config = tld.getConfiguration(layer);
config.modifyLayer(layer); config.modifyLayer(layer);
saveConfigurations.add(config); saveConfigurations.add(config);
} }
Expand Down Expand Up @@ -1635,14 +1628,7 @@ public Iterable<GeoServerTileLayer> getGeoServerTileLayers() {
public void save(final TileLayer layer) { public void save(final TileLayer layer) {
checkNotNull(layer); checkNotNull(layer);
log.info("Saving GeoSeverTileLayer " + layer.getName()); log.info("Saving GeoSeverTileLayer " + layer.getName());

tld.modify(layer);
BaseConfiguration modifiedConfig = tld.modify(layer);
try {
modifiedConfig.save();
} catch (IOException e) {
Throwable rootCause = Throwables.getRootCause(e);
throw Throwables.propagate(rootCause);
}
} }


/** /**
Expand Down Expand Up @@ -1920,7 +1906,7 @@ public boolean isInternalGridSet(final String gridSetId) {
* to handle the deletion of a layer's gridsubset) * to handle the deletion of a layer's gridsubset)
* *
* @param layerName * @param layerName
* @param removedGridset * @param gridSetId
* @TODO: make async?, it may take a while to the metastore to delete all tiles (sigh) * @TODO: make async?, it may take a while to the metastore to delete all tiles (sigh)
*/ */
public void deleteCacheByGridSetId(final String layerName, final String gridSetId) { public void deleteCacheByGridSetId(final String layerName, final String gridSetId) {
Expand All @@ -1939,20 +1925,11 @@ public void deleteCacheByGridSetId(final String layerName, final String gridSetI
public void removeTileLayers(final List<String> tileLayerNames) { public void removeTileLayers(final List<String> tileLayerNames) {
checkNotNull(tileLayerNames); checkNotNull(tileLayerNames);


Set<Configuration> confsToSave = new HashSet<Configuration>();

for (String tileLayerName : tileLayerNames) { for (String tileLayerName : tileLayerNames) {
Configuration configuration = tld.removeLayer(tileLayerName);
if (configuration != null) {
confsToSave.add(configuration);
}
}

for (BaseConfiguration conf : confsToSave) {
try { try {
conf.save(); tld.removeLayer(tileLayerName);
} catch (IOException e) { } catch (IllegalArgumentException e) {
log.log(Level.WARNING, "Error saving GWC Configuration " + conf.getIdentifier(), e); log.log(Level.WARNING, "Error saving GWC Configuration " + tld.getConfiguration(tileLayerName).getIdentifier(), e);
} }
} }
} }
Expand All @@ -1962,7 +1939,7 @@ public synchronized void removeGridSets(final Set<String> gridsetIds) throws IOE


final Set<String> affectedLayers = getLayerNamesForGridSets(gridsetIds); final Set<String> affectedLayers = getLayerNamesForGridSets(gridsetIds);


final Set<Configuration> changedConfigs = new HashSet<Configuration>(); final Set<TileLayerConfiguration> changedConfigs = new HashSet<>();


for (String layerName : affectedLayers) { for (String layerName : affectedLayers) {
TileLayer tileLayer = getTileLayerByName(layerName); TileLayer tileLayer = getTileLayerByName(layerName);
Expand All @@ -1980,8 +1957,7 @@ public synchronized void removeGridSets(final Set<String> gridsetIds) throws IOE
tileLayer.setEnabled(false); tileLayer.setEnabled(false);
} }
try { try {
Configuration configuration = tld.modify(tileLayer); tld.modify(tileLayer);
changedConfigs.add(configuration);
} catch (IllegalArgumentException ignore) { } catch (IllegalArgumentException ignore) {
// layer removed? don't care // layer removed? don't care
} }
Expand All @@ -1992,15 +1968,8 @@ public synchronized void removeGridSets(final Set<String> gridsetIds) throws IOE
} }
} }


// All referencing layers updated, now can remove the gridsets
for (String gridSetId : gridsetIds) { for (String gridSetId : gridsetIds) {
Configuration configuration = tld.removeGridset(gridSetId); tld.removeGridset(gridSetId);
changedConfigs.add(configuration);
}

// now make it all persistent
for (BaseConfiguration config : changedConfigs) {
config.save();
} }
} }


Expand Down Expand Up @@ -2255,7 +2224,6 @@ public JDBCConfiguration getJDBCDiskQuotaConfig() throws IOException, org.geoweb
/** /**
* Checks the JDBC quota store can be instantiated * Checks the JDBC quota store can be instantiated
* *
* @param config
* @param jdbcConfiguration * @param jdbcConfiguration
* @throws ConfigurationException * @throws ConfigurationException
*/ */
Expand Down

0 comments on commit 9e8d5a2

Please sign in to comment.