/** * Reloads the configuration and notifies GWC of any externally removed layer. */ public void reload() { final Set<String> currLayerNames = new HashSet<String>(getTileLayerNames()); try { tld.reInit(); } catch (RuntimeException e) { log.log(Level.WARNING, "Unable to reinit TileLayerDispatcher", e); throw e; } Set<String> newLayerNames = getTileLayerNames(); SetView<String> removedExternally = Sets.difference(currLayerNames, newLayerNames); for (String removedLayerName : removedExternally) { log.info("Notifying of TileLayer '" + removedLayerName + "' removed externally"); layerRemoved(removedLayerName); } }
final Set<String> currLayerNames = new HashSet<String>(getTileLayerNames()); try { tld.reInit(); throw e; Set<String> newLayerNames = getTileLayerNames(); SetView<String> removedExternally = Sets.difference(currLayerNames, newLayerNames); for (String removedLayerName : removedExternally) {
public void testGetLayersList() throws Exception { final String url = "gwc/rest/layers.xml"; MockHttpServletResponse sr = getAsServletResponse(url); assertEquals(200, sr.getErrorCode()); assertTrue(sr.getContentType(), sr.getContentType().startsWith("text/xml")); Document dom = getAsDOM(url); // print(dom); ArrayList<String> tileLayerNames = Lists.newArrayList(GWC.get().getTileLayerNames()); Collections.sort(tileLayerNames); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(ImmutableMap.of("atom", "http://www.w3.org/2005/Atom"))); for (String name : tileLayerNames) { String xpath = "//layers/layer/name[text() = '" + name + "']"; assertXpathExists(xpath, dom); xpath = "//layers/layer/atom:link[@href = 'http://localhost/geoserver/gwc/rest/layers/" + ServletUtils.URLEncode(name) + ".xml']"; assertXpathExists(xpath, dom); } }