/** * Returns true if the layer should be hidden, false otherwise * * <ol> * <li>has a request * <li>is a GetCapabilities request * <li>is not for a layer-specific virtual service * </ol> */ boolean checkCapabilitiesRequest(ResourceInfo resource) { Request request = Dispatcher.REQUEST.get(); if (request != null) { if ("GetCapabilities".equalsIgnoreCase(request.getRequest())) { String resourceContext = resource.getNamespace().getPrefix() + "/" + resource.getName(); return !resourceContext.equalsIgnoreCase(request.getContext()); } } return false; }
@Override public Object visit(Id filter, Object data) { for (Identifier id : filter.getIdentifiers()) { if (id instanceof FeatureId) { FeatureId fid = (FeatureId) id; if (fid.getID() != null) { String[] split = fid.getID().split("\\."); if (split.length > 1) { ResourceInfo r = catalog.getResourceByName(split[0], ResourceInfo.class); if (r != null) { typeNames.add(new QName(r.getNamespace().getURI(), r.getName())); } } } } } return data; }
public <T extends ResourceInfo> List<T> getResourcesByNamespace( NamespaceInfo namespace, Class<T> clazz) { // TODO: support ANY_NAMESPACE? NamespaceInfo ns; if (namespace == null) { ns = getDefaultNamespace(); } else { ns = namespace; } List<T> matches = resources.list(clazz, r -> ns.equals(r.getNamespace())); return ModificationProxy.createList(matches, clazz); }
throw new IllegalArgumentException("Resource must be part of a store"); if (resource.getNamespace() == null) { throw new IllegalArgumentException("Resource must be part of a namespace"); NamespaceInfo namespace = resource.getNamespace(); existing = getResourceByName(namespace, resource.getName(), ResourceInfo.class); if (existing != null && !existing.getId().equals(resource.getId())) {
final NamespaceInfo ns = layer.getResource().getNamespace(); if (null == getResourceByName(ns, layer.getResource().getName(), ResourceInfo.class)) { throw new IllegalStateException(
public void add(ResourceInfo resource) { if (resource.getNamespace() == null) { // default to default namespace resource.setNamespace(getDefaultNamespace()); } if (resource.getNativeName() == null) { resource.setNativeName(resource.getName()); } ResourceInfo resolved = resolve(resource); validate(resolved, true); ResourceInfo added = facade.add(resolved); added(added); }
} else if (!name.equals(other.getName())) return false; if (namespace == null) { if (other.getNamespace() != null) return false; } else if (!namespace.equals(other.getNamespace())) return false; if (nativeBoundingBox == null) { if (other.getNativeBoundingBox() != null) return false;
@Test public void testGetLayersWithSameName() throws Exception { LayerInfo layerInfo1 = catalog.getLayerByName(new NameImpl("ws1", "lc")); ResourceInfo resource1 = layerInfo1.getResource(); NamespaceInfo namespace1 = resource1.getNamespace(); String nsPrefix1 = namespace1.getPrefix(); LayerInfo layerInfo2 = catalog.getLayerByName(new NameImpl("ws2", "lc")); ResourceInfo resource2 = layerInfo2.getResource(); NamespaceInfo namespace2 = resource2.getNamespace(); String nsPrefix2 = namespace2.getPrefix(); assertEquals("Invalid namespace prefix", "ws1", nsPrefix1); assertEquals("Invalid namespace prefix", "ws2", nsPrefix2); }
expect(r.getAbstract()).andReturn("abstract about " + name).anyTimes(); expect(r.getStore()).andReturn(s).anyTimes(); expect(r.getNamespace()).andReturn(ns).anyTimes();
.getNamespace() .equals(catalog.getNamespaceByPrefix(prefix))) { layer = catalog.getFactory().createLayer();
@Override public boolean apply(GeoServerTileLayer tileLayer) { String layerName = tileLayer.getName(); if (-1 == layerName.indexOf(':')) { return false; } LayerInfo layerInfo = catalog.getLayerByName(layerName); if (layerInfo != null) { NamespaceInfo layerNamespace = layerInfo.getResource().getNamespace(); if (namespaceFilter.equals(layerNamespace)) { return true; } } return false; } });
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; } }
public static String encode(ResourceInfo resource) { return encode(resource.getNamespace().getPrefix(), resource.getName()); }
public static String encode(ResourceInfo resource) { return encode(resource.getNamespace().getPrefix(), resource.getName()); }
@Override public boolean apply(GeoServerTileLayer tileLayer) { String layerName = tileLayer.getName(); if (-1 == layerName.indexOf(':')) { return false; } LayerInfo layerInfo = catalog.getLayerByName(layerName); if (layerInfo != null) { NamespaceInfo layerNamespace = layerInfo.getResource().getNamespace(); if (namespaceFilter.equals(layerNamespace)) { return true; } } return false; } });
final NamespaceInfo currNamespace = resourceInfo.getNamespace(); final NamespaceInfo oldNamespace; if (namespaceIndex > -1) {
/** * @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); }
when(mockResourceInfo.getNamespace()).thenReturn(newNamespace); when(mockResourceInfo.prefixedName()).thenReturn(newPrefixedName);
resource.setNamespace(generic.getResource().getNamespace()); resource.setSRS("EPSG:900913"); resource.setName(generic.getResource().getName());
resource.setNamespace(generic.getResource().getNamespace()); resource.setSRS("EPSG:900913"); resource.setName(generic.getResource().getName());