/** * Completely eliminates a {@link GeoServerTileLayer} from GWC. * * <p>This method is intended to be called whenever a {@link LayerInfo} or {@link * LayerGroupInfo} is removed from GeoServer, or it is configured not to create a cached layer * for it, in order to delete the cache for the layer. * * @param prefixedName the name of the layer to remove. * @return {@code true} if the removal of the entire cache for the layer has succeeded, {@code * false} if there wasn't a cache for that layer. */ public synchronized boolean layerRemoved(final String prefixedName) { try { return storageBroker.delete(prefixedName); } catch (StorageException e) { throw new RuntimeException(e); } }
/** * Completely eliminates a {@link GeoServerTileLayer} from GWC. * <p> * This method is intended to be called whenever a {@link LayerInfo} or {@link LayerGroupInfo} * is removed from GeoServer, or it is configured not to create a cached layer for it, in order * to delete the cache for the layer. * </p> * * @param prefixedName * the name of the layer to remove. * @return {@code true} if the removal of the entire cache for the layer has succeeded, * {@code false} if there wasn't a cache for that layer. */ public synchronized boolean layerRemoved(final String prefixedName) { try { return storageBroker.delete(prefixedName); } catch (StorageException e) { throw new RuntimeException(e); } }
public boolean doTruncate(StorageBroker sb, TileBreeder breeder) throws StorageException { boolean truncated = sb.delete(layerName); if (!truncated) { // did we hit a layer that has nothing on storage, or a layer that is not there? try { breeder.findTileLayer(layerName); } catch (GeoWebCacheException e) { throw new IllegalArgumentException("Could not find layer " + layerName); } } return true; } }
@Override protected void doActionInternal() throws GeoWebCacheException, InterruptedException { super.state = GWCTask.STATE.RUNNING; checkInterrupted(); try { storageBroker.delete(tr); } catch (Exception e) { super.state = GWCTask.STATE.DEAD; log.error("During truncate request", e); } checkInterrupted(); if (doFilterUpdate) { runFilterUpdates(); } if (super.state != GWCTask.STATE.DEAD) { super.state = GWCTask.STATE.DONE; log.debug("Completed truncate request."); } }
storageBroker.delete(layerName); } catch (StorageException se) {
public void testLayerRemoved() throws Exception { mediator.layerRemoved("someLayer"); verify(storageBroker, times(1)).delete(eq("someLayer")); doThrow(new StorageException("fake")).when(storageBroker).delete(eq("anotherLayer")); try { mediator.layerRemoved("anotherLayer"); fail("Expected RTE"); } catch (RuntimeException e) { assertTrue(e.getCause() instanceof StorageException); } }
@Test public void testTruncateLayer() throws Exception { String layerName = "test"; String requestBody = "<truncateLayer><layerName>" + layerName + "</layerName></truncateLayer>"; StorageBroker sb = createMock(StorageBroker.class); expect(sb.delete(eq(layerName))).andReturn(true); replay(sb); mtc.setStorageBroker(sb); this.mockMvc .perform( post("/rest/masstruncate") .contentType(MediaType.TEXT_XML) .content(requestBody) .contextPath("")) .andExpect(status().is2xxSuccessful()); verify(sb); }
@Test public void testTruncateNonExistingLayer() throws Exception { String layerName = "test"; String requestBody = "<truncateLayer><layerName>" + layerName + "</layerName></truncateLayer>"; StorageBroker sb = createMock(StorageBroker.class); expect(sb.delete(eq(layerName))).andReturn(false); replay(sb); TileBreeder tb = createMock(TileBreeder.class); expect(tb.findTileLayer(layerName)).andThrow(new GeoWebCacheException("Layer not found")); replay(tb); mtc.setStorageBroker(sb); mtc.setTileBreeder(tb); // first run, it will get a bad request this.mockMvc .perform( post("/rest/masstruncate") .contentType(MediaType.TEXT_XML) .content(requestBody) .contextPath("")) .andExpect(status().isBadRequest()) .andExpect(content().string(containsString("Could not find layer test"))); verify(sb); }