/** * Completely deletes the cache for a layer/gridset combination; differs from truncate that the * layer doesn't need to have a gridSubset associated for the given gridset at runtime (in order * to handle the deletion of a layer's gridsubset) * * @param layerName The layer name * @param gridSetId The gridset name @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) { try { storageBroker.deleteByGridSetId(layerName, gridSetId); } catch (StorageException e) { throw propagate(getRootCause(e)); } }
/** * Completely deletes the cache for a layer/gridset combination; differs from truncate that the * layer doesn't need to have a gridSubset associated for the given gridset at runtime (in order * to handle the deletion of a layer's gridsubset) * * @param layerName * @param removedGridset * @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) { try { storageBroker.deleteByGridSetId(layerName, gridSetId); } catch (StorageException e) { throw propagate(getRootCause(e)); } }
public void testDeleteCacheByGridSetId() throws Exception { when(storageBroker.deleteByGridSetId(eq("layer"), eq("gset1"))).thenThrow( new StorageException("fake")); try { mediator.deleteCacheByGridSetId("layer", "gset1"); fail(); } catch (RuntimeException e) { assertTrue(true); } mediator.deleteCacheByGridSetId("layer", "gset2"); verify(storageBroker, times(1)).deleteByGridSetId(eq("layer"), eq("gset2")); }
public void testTruncateLayerFully() throws Exception { when(tld.getTileLayer(eq(tileLayerGroup.getName()))).thenThrow( new GeoWebCacheException("fake")); mediator.truncate(tileLayerGroup.getName()); verify(storageBroker, never()).deleteByGridSetId(anyString(), anyString()); mediator.truncate(tileLayer.getName()); verify(storageBroker, times(tileLayer.getGridSubsets().size())).deleteByGridSetId( anyString(), anyString()); }
public void testModifyGridsetTruncates() 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); // make it so the gridset forces truncation xmlGridSet.setAlignTopLeft(!xmlGridSet.getAlignTopLeft()); newGridset = xmlGridSet.makeGridSet(); } XMLConfiguration xmlConfig = mock(XMLConfiguration.class); mediator = spy(mediator); when(mediator.getXmlConfiguration()).thenReturn(xmlConfig); when(tld.getConfiguration(same(tileLayer))).thenReturn(config); when(tld.getConfiguration(same(tileLayerGroup))).thenReturn(config); mediator.modifyGridSet(oldName, newGridset); verify(storageBroker, times(1)).deleteByGridSetId(eq(tileLayer.getName()), eq(oldName)); verify(storageBroker, times(1)) .deleteByGridSetId(eq(tileLayerGroup.getName()), eq(oldName)); }
public void testRemoveAllLayerGridsetsDisablesLayer() throws Exception { when(tld.getConfiguration(same(tileLayer))).thenReturn(config); when(tld.getConfiguration(same(tileLayerGroup))).thenReturn(config); when(tld.modify(same(tileLayer))).thenReturn(config); when(tld.modify(same(tileLayerGroup))).thenReturn(config); when(tld.removeGridset(eq("EPSG:4326"))).thenReturn(config); when(tld.removeGridset(eq("EPSG:900913"))).thenReturn(config); // sanity check before modification assertTrue(tileLayer.getInfo().isEnabled()); assertTrue(tileLayer.getInfo().isEnabled()); mediator.removeGridSets(ImmutableSet.of("EPSG:900913", "EPSG:4326")); verify(config, times(1)).save();// all other checks are in testRemoveGridsets verify(storageBroker, times(1)).deleteByGridSetId(eq(tileLayer.getName()), eq("EPSG:4326")); verify(storageBroker, times(1)).deleteByGridSetId(eq(tileLayerGroup.getName()), eq("EPSG:900913")); verify(storageBroker, times(1)).deleteByGridSetId(eq(tileLayer.getName()), eq("EPSG:4326")); verify(storageBroker, times(1)).deleteByGridSetId(eq(tileLayerGroup.getName()), eq("EPSG:900913")); assertTrue(tileLayer.getGridSubsets().isEmpty()); assertTrue(tileLayerGroup.getGridSubsets().isEmpty()); // layers ended up with no gridsubsets, shall have been disabled assertFalse(tileLayer.getInfo().isEnabled()); assertFalse(tileLayerGroup.getInfo().isEnabled()); }
assertEquals(ImmutableSet.of("EPSG:900913"), tileLayerGroup.getGridSubsets()); verify(storageBroker, times(1)).deleteByGridSetId(eq(tileLayer.getName()), eq("EPSG:4326")); verify(storageBroker, times(1)).deleteByGridSetId(eq(tileLayerGroup.getName()), eq("EPSG:4326")); .deleteByGridSetId(eq(tileLayer.getName()), eq("EPSG:900913")); verify(storageBroker, never()).deleteByGridSetId(eq(tileLayer.getName()), eq("My4326")); verify(storageBroker, never()).deleteByGridSetId(eq(tileLayerGroup.getName()), eq("EPSG:900913")); verify(storageBroker, never()) .deleteByGridSetId(eq(tileLayerGroup.getName()), eq("My4326"));