public static String tileLayerName(LayerInfo li) { // REVISIT when/if layerinfo.getName gets decoupled from LayerInfo.resource.name return li.getResource().prefixedName(); }
public static String tileLayerName(LayerInfo li) { // REVISIT when/if layerinfo.getName gets decoupled from LayerInfo.resource.name return li.getResource().prefixedName(); }
public String getName() { if (layerInfo != null) { return layerInfo.getResource().prefixedName(); } else { return groupInfo.prefixedName(); } }
private Map<String, Object> getDefaultValues( ResourceInfo resource, GetMapRequest getMap, DefaultValueConfigurations configurations) throws IOException { Map<String, Map<String, Object>> defaults = DYNAMIC_DEFAULTS.get(); String resourceKey = resource.getId(); Map<String, Object> result = defaults.get(resourceKey); if (result == null) { result = buildDynamicDefaults(resource, getMap, configurations); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine( "Computed the following dynamic dimension default values for layer " + resource.prefixedName() + ":\n" + result + "\nbased on configuration:\n" + configurations); } defaults.put(resourceKey, result); } return result; }
private void handleRename( Map<String, Object> properties, final CatalogInfo source, final List<String> changedProperties, final List<Object> oldValues, final List<Object> newValues) { final int nameIndex = changedProperties.indexOf("name"); final int namespaceIndex = changedProperties.indexOf("namespace"); String oldLayerName; String newLayerName; if (source instanceof ResourceInfo) { // covers LayerInfo, CoverageInfo, and WMSLayerInfo // must cover prefix:name final ResourceInfo resourceInfo = (ResourceInfo) source; final NamespaceInfo currNamespace = resourceInfo.getNamespace(); final NamespaceInfo oldNamespace; if (namespaceIndex > -1) { oldNamespace = (NamespaceInfo) oldValues.get(namespaceIndex); } else { oldNamespace = currNamespace; } newLayerName = resourceInfo.prefixedName(); if (nameIndex > -1) { oldLayerName = (String) oldValues.get(nameIndex); } else { oldLayerName = resourceInfo.getName(); } oldLayerName = oldNamespace.getPrefix() + ":" + oldLayerName; } }
@Override public Object findTemplateSource(String path) throws IOException { String templatePath = "empty.ftl"; if (path.toLowerCase().contains("content") && (this.resource != null) && this.resource .prefixedName() .equals(featureType2.prefixedName())) { templatePath = "test_content.ftl"; } try { return new File( this.getClass() .getResource(templateFolder + templatePath) .toURI()); } catch (URISyntaxException e) { return null; } } };
newLayerName = resourceInfo.prefixedName(); if (nameIndex > -1) { oldLayerName = (String) oldValues.get(nameIndex);
/** * @param source either a {@link LayerInfo}, {@link ResourceInfo}, or a {@link LayerGroupInfo} * @return {@code null} * @throws IllegalArgumentException if source is not of a supported type */ public GeoServerTileLayer getTileLayer(CatalogInfo source) { final String name; if (source instanceof ResourceInfo) { name = ((ResourceInfo) source).prefixedName(); } else if (source instanceof LayerInfo) { name = tileLayerName(((LayerInfo) source)); } else if (source instanceof LayerGroupInfo) { name = tileLayerName(((LayerGroupInfo) source)); } else { return null; } TileLayer tileLayer; try { tileLayer = tld.getTileLayer(name); } catch (GeoWebCacheException notFound) { return null; } if (tileLayer instanceof GeoServerTileLayer) { return (GeoServerTileLayer) tileLayer; } return null; }
/** * Looks up the elevation configuration, throws an exception if not found * * @param resourceInfo * @param dimensionName */ public DimensionInfo getDimensionInfo(ResourceInfo resourceInfo, String dimensionName) { DimensionInfo info = resourceInfo.getMetadata().get(dimensionName, DimensionInfo.class); if (info == null || !info.isEnabled()) { throw new ServiceException( "Layer " + resourceInfo.prefixedName() + " does not have " + dimensionName + " support enabled"); } return info; }
private void mockCatalog() { when(catalog.getLayers()).thenReturn(Arrays.asList(layer)); when(catalog.getLayerGroups()).thenReturn(Arrays.asList(layerGroup)); when(catalog.getLayer(eq(layer.getId()))).thenReturn(layer); when(catalog.getLayerGroup(layerGroup.getId())).thenReturn(layerGroup); when(catalog.getLayerByName(eq(layer.getResource().prefixedName()))).thenReturn(layer); when(catalog.getLayerGroupByName(tileLayerName(layerGroup))).thenReturn(layerGroup); }
/** * @param source * either a {@link LayerInfo}, {@link ResourceInfo}, or a {@link LayerGroupInfo} * @return {@code null} * @throws IllegalArgumentException * if source is not of a supported type */ public GeoServerTileLayer getTileLayer(CatalogInfo source) { final String name; if (source instanceof ResourceInfo) { name = ((ResourceInfo) source).prefixedName(); } else if (source instanceof LayerInfo) { name = tileLayerName(((LayerInfo) source)); } else if (source instanceof LayerGroupInfo) { name = tileLayerName(((LayerGroupInfo) source)); } else { return null; } TileLayer tileLayer; try { tileLayer = tld.getTileLayer(name); } catch (GeoWebCacheException notFound) { return null; } if (tileLayer instanceof GeoServerTileLayer) { return (GeoServerTileLayer) tileLayer; } return null; }
public void testLayerInfoRemoved() throws Exception { CatalogRemoveEventImpl event = new CatalogRemoveEventImpl(); event.setSource(mockLayerInfo); when(mockMediator.hasTileLayer(same(mockLayerInfo))).thenReturn(true); listener.handleRemoveEvent(event); verify(mockMediator).removeTileLayers(eq(Arrays.asList(mockResourceInfo.prefixedName()))); }
protected void setUp() throws Exception { mockMediator = mock(GWC.class); mockStyle = mock(StyleInfo.class); when(mockStyle.getName()).thenReturn(STYLE_NAME); mockResourceInfo = mock(FeatureTypeInfo.class); when(mockResourceInfo.prefixedName()).thenReturn(PREFIXED_RESOURCE_NAME); mockLayerInfo = mock(LayerInfo.class); when(mockLayerInfo.getResource()).thenReturn(mockResourceInfo); mockTileLayer = mock(GeoServerTileLayer.class); mockTileLayerInfo = mock(GeoServerTileLayerInfoImpl.class); ImmutableSet<String> empty = ImmutableSet.of(); when(mockTileLayerInfo.cachedStyles()).thenReturn(empty); when(mockTileLayer.getLayerInfo()).thenReturn(mockLayerInfo); when(mockTileLayer.getInfo()).thenReturn(mockTileLayerInfo); when(mockTileLayer.getName()).thenReturn(PREFIXED_RESOURCE_NAME); when(mockMediator.getTileLayersForStyle(eq(STYLE_NAME))).thenReturn( Collections.singletonList(mockTileLayer)); listener = new CatalogStyleChangeListener(mockMediator); styleNameModifyEvent = new CatalogModifyEventImpl(); styleNameModifyEvent.setSource(mockStyle); styleNameModifyEvent.setPropertyNames(Arrays.asList("name")); styleNameModifyEvent.setOldValues(Arrays.asList(STYLE_NAME)); styleNameModifyEvent.setNewValues(Arrays.asList(STYLE_NAME_MODIFIED)); }
/** * @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { GWCConfig configDefaults = GWCConfig.getOldDefaults(); mockMediator = mock(GWC.class); when(mockMediator.getConfig()).thenReturn(configDefaults); GridSetBroker gridsets = new GridSetBroker(true, true); when(mockMediator.getGridSetBroker()).thenReturn(gridsets); mockLayerInfo = mock(LayerInfo.class); MetadataMap layerMetadata = new MetadataMap(); when(mockLayerInfo.getMetadata()).thenReturn(layerMetadata); mockLayerGroupInfo = mock(LayerGroupInfo.class); MetadataMap groupMetadata = new MetadataMap(); when(mockLayerGroupInfo.getMetadata()).thenReturn(groupMetadata); mockResourceInfo = mock(FeatureTypeInfo.class); mockNamespaceInfo = mock(NamespaceInfo.class); when(mockLayerGroupInfo.getName()).thenReturn(LAYER_GROUP_NAME); when(mockLayerGroupInfo.prefixedName()).thenReturn(LAYER_GROUP_NAME); when(mockResourceInfo.prefixedName()).thenReturn(PREFIXED_RESOURCE_NAME); when(mockResourceInfo.getName()).thenReturn(RESOURCE_NAME); when(mockResourceInfo.getNamespace()).thenReturn(mockNamespaceInfo); when(mockNamespaceInfo.getPrefix()).thenReturn(NAMESPACE_PREFIX); when(mockLayerInfo.getResource()).thenReturn(mockResourceInfo); listener = new CatalogLayerEventListener(mockMediator); }
/** * Returns the default value for time dimension. * * @param resourceInfo */ public Object getDefaultTime(ResourceInfo resourceInfo) { // check the time metadata DimensionInfo time = resourceInfo.getMetadata().get(ResourceInfo.TIME, DimensionInfo.class); if (time == null || !time.isEnabled()) { throw new ServiceException( "Layer " + resourceInfo.prefixedName() + " does not have time support enabled"); } DimensionDefaultValueSelectionStrategy strategy = this.getDefaultValueStrategy(resourceInfo, ResourceInfo.TIME, time); return strategy.getDefaultValue(resourceInfo, ResourceInfo.TIME, time, Date.class); }
/** * @param source * either a {@link LayerInfo} or a {@link LayerGroupInfo} * @return {@code true} if source has a tile layer associated, false otherwise, even if source * is not an instance of {@link LayerInfo} or {@link LayerGroupInfo} */ public boolean hasTileLayer(CatalogInfo source) { final String tileLayerId; if (source instanceof ResourceInfo) { LayerInfo layerInfo = getCatalog().getLayerByName( ((ResourceInfo) source).prefixedName()); if (layerInfo == null) { return false; } tileLayerId = layerInfo.getId(); } else if (source instanceof LayerInfo) { tileLayerId = ((LayerInfo) source).getId(); } else if (source instanceof LayerGroupInfo) { tileLayerId = ((LayerGroupInfo) source).getId(); } else { return false; } Configuration configuration; try { configuration = tld.getConfiguration(tileLayerId); } catch (IllegalArgumentException notFound) { return false; } return configuration instanceof CatalogConfiguration; }
public void testResourceInfoRenamed() throws Exception { final String oldTileLayerName = mockResourceInfo.prefixedName(); final String renamedResouceName = RESOURCE_NAME + "_Renamed"; final String renamedPrefixedResouceName = PREFIXED_RESOURCE_NAME + "_Renamed"; when(mockResourceInfo.prefixedName()).thenReturn(renamedPrefixedResouceName);
when(newNamespace.getPrefix()).thenReturn("newMock"); final String oldPrefixedName = mockResourceInfo.prefixedName(); final String newPrefixedName = newNamespace.getPrefix() + ":" + mockResourceInfo.getName(); when(mockResourceInfo.prefixedName()).thenReturn(newPrefixedName);
public void encodeGWCLink(Document container, GetMapRequest request, MapLayerInfo layer) { NetworkLink nl = container.createAndAddNetworkLink(); String prefixedName = layer.getResource().prefixedName(); nl.setName("GWC-" + prefixedName); Link link = nl.createAndSetLink(); String type = layer.getType() == MapLayerInfo.TYPE_RASTER ? "png" : "kml"; String url = ResponseUtils.buildURL(request.getBaseUrl(), "gwc/service/kml/" + prefixedName + "." + type + ".kml", null, URLType.SERVICE); link.setHref(url); link.setViewRefreshMode(ViewRefreshMode.NEVER); }
/** * @param source either a {@link LayerInfo} or a {@link LayerGroupInfo} * @return {@code true} if source has a tile layer associated, false otherwise, even if source * is not an instance of {@link LayerInfo} or {@link LayerGroupInfo} */ public boolean hasTileLayer(CatalogInfo source) { final String tileLayerName; if (source instanceof ResourceInfo) { LayerInfo layerInfo = getCatalog().getLayerByName(((ResourceInfo) source).prefixedName()); if (layerInfo == null) { return false; } tileLayerName = tileLayerName(layerInfo); } else if (source instanceof LayerInfo) { tileLayerName = tileLayerName((LayerInfo) source); } else if (source instanceof LayerGroupInfo) { tileLayerName = tileLayerName((LayerGroupInfo) source); } else { return false; } BaseConfiguration configuration; try { configuration = tld.getConfiguration(tileLayerName); } catch (IllegalArgumentException notFound) { return false; } return configuration instanceof CatalogConfiguration; }