/** * @return all the GWC tile layers, both GeoServer's and externally defined * @see #getGeoServerTileLayers() */ public Iterable<TileLayer> getTileLayers() { return tld.getLayerList(); }
/** * Get an iterator over the layers. * * @return */ public Iterable<TileLayer> getLayers() { return this.layerDispatcher.getLayerList(); } }
/** * @return all the GWC tile layers, both GeoServer's and externally defined * @see #getGeoServerTileLayers() */ public Iterable<TileLayer> getTileLayers() { return tld.getLayerList(); }
public synchronized void removeGridSet(String gridsetToRemove) { if (StreamSupport.stream(getLayerList().spliterator(), true) .anyMatch(g -> Objects.nonNull(g.getGridSubset(gridsetToRemove)))) { throw new IllegalStateException( "Can not remove gridset " + gridsetToRemove + " as it is used by layers"); } gridSetBroker.removeGridSet(gridsetToRemove); }
private void capabilityLayerOuter(StringBuilder str) { str.append(" <Layer>\n"); str.append(" <Title>GeoWebCache WMS</Title>\n"); str.append(" <Abstract>Note that not all GeoWebCache instances provide a full WMS service.</Abstract>\n"); str.append(" <LatLonBoundingBox minx=\"-180.0\" miny=\"-90.0\" maxx=\"180.0\" maxy=\"90.0\"/>\n"); Iterable<TileLayer> layerIter = tld.getLayerList(); for (TileLayer layer : layerIter) { if (!layer.isEnabled()) { continue; } try { capabilityLayerInner(str, layer); } catch (GeoWebCacheException e) { log.error(e.getMessage()); } } str.append(" </Layer>\n"); }
private void capabilityRequestGetFeatureInfo(XMLBuilder xml) throws IOException { // Find all the info formats we support Iterable<TileLayer> layerIter = tld.getLayerList(); HashSet<String> formats = new HashSet<String>(); for (TileLayer layer : layerIter) { if (!layer.isEnabled() || !layer.isAdvertised()) { continue; } if (layer.getMimeTypes() != null) { Iterator<MimeType> mimeIter = layer.getInfoMimeTypes().iterator(); while (mimeIter.hasNext()) { MimeType mime = mimeIter.next(); formats.add(mime.getFormat()); } } else { formats.add("text/plain"); formats.add("text/html"); formats.add("application/vnd.ogc.gml"); } } capability(xml, "GetFeatureInfo", formats, urlStr); }
private void writeSiteMapIndexLoop() throws IOException { OutputStream os = tile.servletResp.getOutputStream(); String urlPrefix = tile.getUrlPrefix(); Iterable<TileLayer> iter = tLD.getLayerList(); for (TileLayer tl : iter) { if (!tl.isEnabled()) { continue; } Set<String> grids = tl.getGridSubsets(); List<MimeType> mimeTypes = tl.getMimeTypes(); if( grids != null && grids.contains(gridSetBroker.WORLD_EPSG4326.getName()) && mimeTypes != null && mimeTypes.contains(XMLMime.kml) ) { String smStr = "<sitemap><loc>"+urlPrefix+tl.getName()+"/sitemap.xml</loc></sitemap>"; os.write(smStr.getBytes()); } } }
private void capabilityRequestGetMap(XMLBuilder xml) throws IOException { // Find all the formats we support Iterable<TileLayer> layerIter = tld.getLayerList(); HashSet<String> formats = new HashSet<String>(); for (TileLayer layer : layerIter) { if (!layer.isEnabled() || !layer.isAdvertised()) { continue; } if (layer.getMimeTypes() != null) { Iterator<MimeType> mimeIter = layer.getMimeTypes().iterator(); while (mimeIter.hasNext()) { MimeType mime = mimeIter.next(); formats.add(mime.getFormat()); } } else { formats.add("image/png"); formats.add("image/jpeg"); } } capability(xml, "GetMap", formats, urlStr); }
protected TMSCustomFactoryTest( TileLayerDispatcher tld, GridSetBroker gsb, URLMangler urlMangler, List<CustomLayerImplementation> customCatalogLayers) throws Exception { super(tld, gsb, urlMangler, "tilemapservice", StandardCharsets.UTF_8); List<String> gridSetNames = Arrays.asList("EPSG:4326"); TileLayer tileLayer = mockTileLayer( tld, gsb, "customLayer2", gridSetNames, Collections.<ParameterFilter>emptyList()); when(tld.getLayerList()).thenReturn(Arrays.asList(tileLayer)); this.customCatalogLayers = customCatalogLayers; }
public MockWMSLayerSource(TileLayerDispatcher tld) { log.info( "'\n---------------------------------------------------------------------------------\n" + "Replacing all WMS layer backend helpers by a mock one, don't forget to remove this\n" + "---------------------------------------------------------------------------------"); for (TileLayer layer : tld.getLayerList()) { if (layer instanceof WMSLayer) { ((WMSLayer) layer).setSourceHelper(fakeWMSSource); } } }
@Override public void startUp() { super.startUp(); sharedQueue = new LinkedBlockingQueue<>(1000); usageStatsConsumer = new QueuedUsageStatsConsumer(quotaStore, sharedQueue, tilePageCalculator); getExecutorService().submit(usageStatsConsumer); usageStatsProducer = new QueuedUsageStatsProducer(sharedQueue); Iterable<TileLayer> allLayers = tileLayerDispatcher.getLayerList(); for (TileLayer layer : allLayers) { layer.addLayerListener(usageStatsProducer); } }
private void writeSiteMapIndexLoop() throws IOException { OutputStream os = tile.servletResp.getOutputStream(); String urlPrefix = tile.getUrlPrefix(); Iterable<TileLayer> iter = tLD.getLayerList(); for (TileLayer tl : iter) { if (!tl.isEnabled()) { continue; } Set<String> grids = tl.getGridSubsets(); List<MimeType> mimeTypes = tl.getMimeTypes(); if (grids != null && grids.contains(gridSetBroker.getWorldEpsg4326().getName()) && mimeTypes != null && mimeTypes.contains(XMLMime.kml)) { String smStr = "<sitemap><loc>" + urlPrefix + tl.getName() + "/sitemap.xml</loc></sitemap>"; os.write(smStr.getBytes()); } } }
/** * Renames an existing blob store. * * @param oldName The name of the existing blob store * @param newName The name to rename the blob store to * @throws IllegalArgumentException */ public synchronized void renameBlobStore(final String oldName, final String newName) throws NoSuchElementException, IllegalArgumentException { BlobStoreConfiguration config = getConfiguration(oldName); config.renameBlobStore(oldName, newName); // update layers for (TileLayer layer : layers.getLayerList()) { if (oldName.equals(layer.getBlobStoreId())) { layer.setBlobStoreId(newName); layers.modify(layer); } } }
@Test public void testRenameBlobStoreChangesLayer() throws GeoWebCacheException { TileLayer layer = tileLayerDispatcher.getLayerList().iterator().next(); BlobStoreInfo blobStore = blobStoreAggregator.getBlobStore(layer.getBlobStoreId()); assertNotNull(blobStore); blobStoreAggregator.renameBlobStore(blobStore.getName(), "foobarbaz"); layer = tileLayerDispatcher.getLayerList().iterator().next(); assertEquals("foobarbaz", layer.getBlobStoreId()); } }
private void mockTileLayerDispatcher() throws Exception { when(tld.getConfiguration(same(tileLayer))).thenReturn(config); when(tld.getConfiguration(same(tileLayerGroup))).thenReturn(config); when(tld.getConfiguration(eq(tileLayer.getName()))).thenReturn(config); when(tld.getConfiguration(eq(tileLayerGroup.getName()))).thenReturn(config); when(tld.getTileLayer(eq(tileLayer.getName()))).thenReturn(tileLayer); when(tld.getTileLayer(eq(tileLayerGroup.getName()))).thenReturn(tileLayerGroup); when(tld.getLayerNames()).thenReturn( ImmutableSet.of(tileLayer.getName(), tileLayerGroup.getName())); Iterable<TileLayer> tileLayers = ImmutableList.of((TileLayer) tileLayer, (TileLayer) tileLayerGroup); when(tld.getLayerList()).thenReturn(tileLayers); when(tld.layerExists(eq(tileLayer.getName()))).thenReturn(true); when(tld.layerExists(eq(tileLayerGroup.getName()))).thenReturn(true); }
private void contents(XMLBuilder xml) throws IOException { xml.indentElement("Contents"); Iterable<TileLayer> iter = tld.getLayerList(); for (TileLayer layer : iter) { if (!layer.isEnabled() || !layer.isAdvertised()) { continue; } layer(xml, layer, baseUrl); } for (GridSet gset : gsb.getGridSets()) { tileMatrixSet(xml, gset); } xml.endElement("Contents"); }
private void capabilityLayerOuter(XMLBuilder xml) throws IOException { xml.indentElement("Layer"); xml.simpleElement("Title", "GeoWebCache WMS", true); xml.simpleElement( "Abstract", "Note that not all GeoWebCache instances provide a full WMS service.", true); xml.latLonBoundingBox(-180.0, -90.0, 180.0, 90.0); Iterable<TileLayer> layerIter = tld.getLayerList(); for (TileLayer layer : layerIter) { if (!layer.isEnabled() || !layer.isAdvertised()) { continue; } try { capabilityLayerInner(xml, layer); } catch (GeoWebCacheException e) { log.error(e.getMessage()); } } xml.endElement(); }
@Test public void testGetCapabilitiesNotAffectedBySecurityFilter() throws Exception { SecurityDispatcher secDisp = mock(SecurityDispatcher.class); when(secDisp.isSecurityEnabled()).thenReturn(true); GeoWebCacheDispatcher gwcd = mock(GeoWebCacheDispatcher.class); when(gwcd.getServletPrefix()).thenReturn(null); service = new WMSService(sb, tld, mock(RuntimeStats.class), new NullURLMangler(), gwcd); service.setSecurityDispatcher(secDisp); String layerName = "mockLayer"; TestLayer tileLayer = mock(TestLayer.class); when(tld.getTileLayer(layerName)).thenReturn(tileLayer); when(tld.getLayerList()).thenReturn(Collections.singleton(tileLayer)); doThrow(new SecurityException()).when(secDisp).checkSecurity(Mockito.any()); MockHttpServletRequest req = new MockHttpServletRequest(); MockHttpServletResponse resp = new MockHttpServletResponse(); req.addParameter("service", new String[] {"WMS"}); req.addParameter("version", new String[] {"1.1.1"}); req.addParameter("request", new String[] {"GetCapabilities"}); req.setRequestURI( "/geowebcache/service/wms?service=WMS&version=1.1.1&request=" + "GetCapabilities"); ConveyorTile conv = service.getConveyor(req, resp); assertThat(conv, hasProperty("hint", equalTo("GetCapabilities".toLowerCase()))); service.handleRequest(conv); }
@Test public void testLayerList() { int count = tileLayerDispatcher.getLayerCount(); Set<String> names = tileLayerDispatcher.getLayerNames(); int i = 0; for (TileLayer layer : tileLayerDispatcher.getLayerList()) { assertTrue(names.contains(layer.getName())); i++; } assertEquals(count, i); assertEquals(count, names.size()); }
@Test public void testGetCapabilitiesNotAffectedByProxyWhitelist() throws Exception { SecurityDispatcher secDisp = mock(SecurityDispatcher.class); when(secDisp.isSecurityEnabled()).thenReturn(false); whitelistProperty.setValue("troz"); GeoWebCacheDispatcher gwcd = mock(GeoWebCacheDispatcher.class); when(gwcd.getServletPrefix()).thenReturn(null); service = new WMSService(sb, tld, mock(RuntimeStats.class), new NullURLMangler(), gwcd); service.setSecurityDispatcher(secDisp); String layerName = "mockLayer"; TestLayer tileLayer = mock(TestLayer.class); when(tld.getTileLayer(layerName)).thenReturn(tileLayer); when(tld.getLayerList()).thenReturn(Collections.singleton(tileLayer)); MockHttpServletRequest req = new MockHttpServletRequest(); MockHttpServletResponse resp = new MockHttpServletResponse(); req.addParameter("service", new String[] {"WMS"}); req.addParameter("version", new String[] {"1.1.1"}); req.addParameter("request", new String[] {"GetCapabilities"}); req.setRequestURI( "/geowebcache/service/wms?service=WMS&version=1.1.1&request=" + "GetCapabilities"); ConveyorTile conv = service.getConveyor(req, resp); assertThat(conv, hasProperty("hint", equalTo("GetCapabilities".toLowerCase()))); service.handleRequest(conv); }