public NamespaceInfo getNamespaceByPrefix(String prefix) { return delegate.getNamespaceByPrefix(prefix); }
public NamespaceInfo getNamespaceByPrefix(String prefix) { return checkAccess(delegate.getNamespaceByPrefix(prefix)); }
public NamespaceInfo getNamespaceByPrefix(String prefix) { return checkAccess( user(), delegate.getNamespaceByPrefix(prefix), MixedModeBehavior.CHALLENGE); }
@Override public NamespaceInfo getDefaultNamespace() { if (LocalWorkspace.get() != null) { WorkspaceInfo ws = LocalWorkspace.get(); NamespaceInfo ns = delegate.getNamespaceByPrefix(ws.getName()); if (ns != null) { return ns; } } return super.getDefaultNamespace(); }
/** * Get the QName for a layer specified by the layername that would be used in a request. * * @param typename the layer name for the type */ protected QName resolveLayerName(String typename) { int i = typename.indexOf(":"); String prefix = typename.substring(0, i); String name = typename.substring(i + 1); NamespaceInfo ns = getCatalog().getNamespaceByPrefix(prefix); QName qname = new QName(ns.getURI(), name, ns.getPrefix()); return qname; }
/** * Get the QName for a layer specified by the layername that would be used in a request. * * @param typename the layer name for the type */ protected QName resolveLayerName(String typename) { int i = typename.indexOf(":"); String prefix = typename.substring(0, i); String name = typename.substring(i + 1); NamespaceInfo ns = getCatalog().getNamespaceByPrefix(prefix); QName qname = new QName(ns.getURI(), name, ns.getPrefix()); return qname; }
/** * Deletes a namespace. * * <p>If the namespace does not exist, this method will do nothing rather than fail. * * <p>To do a recursive delete of all the resources under the namespace the {@link * #removeWorkspace(String)} method shoul be used. * * <p>This method is intended to be called after system startup. Typically from {@link * #onSetUp(SystemTestData)} or a {@literal @}Before hook. * * @param prefix The prefix of the namespace. */ protected void removeNamespace(String prefix) { Catalog cat = getCatalog(); NamespaceInfo ns = cat.getNamespaceByPrefix(prefix); if (ns != null) { cat.remove(ns); } }
/** * Helper method that will make sure that the namespace associated to the provided workspace has * the same isolation. * * <p>If the associated namespace doesn't exists nothing will be done. * * @param workspace a catalog workspace */ private void syncNamespaceIsolation(WorkspaceInfo workspace) { // get the namespace associated to the workspace, may be NULL NamespaceInfo namespace = catalog.getNamespaceByPrefix(workspace.getName()); if (namespace != null && workspace.isIsolated() != namespace.isIsolated()) { // update the namespace isolation namespace.setIsolated(workspace.isIsolated()); catalog.save(namespace); } }
@Test public void testGetNamespaceByPrefix() { catalog.add(ns); NamespaceInfo ns2 = catalog.getNamespaceByPrefix(ns.getPrefix()); assertNotNull(ns2); assertFalse(ns == ns2); assertEquals(ns, ns2); NamespaceInfo ns3 = catalog.getNamespaceByPrefix(null); assertNotNull(ns3); assertFalse(ns == ns3); assertEquals(ns, ns3); NamespaceInfo ns4 = catalog.getNamespaceByPrefix(Catalog.DEFAULT); assertNotNull(ns4); assertFalse(ns == ns4); assertEquals(ns, ns4); }
public void visit(WorkspaceInfo workspace) { // remove owned stores for (StoreInfo s : catalog.getStoresByWorkspace(workspace, StoreInfo.class)) { s.accept(this); } // remove any linked namespaces NamespaceInfo ns = catalog.getNamespaceByPrefix(workspace.getName()); if (ns != null) { ns.accept(this); } // remove styles contained in this workspace for (StyleInfo style : catalog.getStylesByWorkspace(workspace)) { style.accept(this); } // remove layer groups contained in this workspace for (LayerGroupInfo group : catalog.getLayerGroupsByWorkspace(workspace)) { group.accept(this); } catalog.remove(workspace); }
assertEquals("defaultNamespace", l.postModified.get(0).getPropertyNames().get(0)); ns = catalog.getNamespaceByPrefix("ns2Prefix"); ns.setURI("changed"); catalog.save(ns);
@Test public void retrievingNamespacesFromCatalog() { Catalog catalog = getCatalog(); // create isolated workspace createWorkspace("test_b1", "https://www.test_b.com", true); checkNamespace( catalog.getNamespaceByPrefix("test_b1"), "test_b1", "https://www.test_b.com", true); assertThat(catalog.getNamespaceByURI("https://www.test_b.com"), nullValue()); // create non isolated workspace createWorkspace("test_b2", "https://www.test_b.com", false); // get the workspaces information object checkWorkspace(catalog.getWorkspaceByName("test_b1"), "test_b1", true); checkWorkspace(catalog.getWorkspaceByName("test_b2"), "test_b2", false); // get namespaces by prefix checkNamespace( catalog.getNamespaceByPrefix("test_b1"), "test_b1", "https://www.test_b.com", true); checkNamespace( catalog.getNamespaceByPrefix("test_b2"), "test_b2", "https://www.test_b.com", false); // get namespaces by URI checkNamespace( catalog.getNamespaceByURI("https://www.test_b.com"), "test_b2", "https://www.test_b.com", false); }
/** * Helper method that updates the isolation state of an workspace and the corresponding * namespace. */ protected void updateWorkspaceIsolationState(String prefix, boolean isolated) { Catalog catalog = getCatalog(); // set the workspace isolation state using the provided one WorkspaceInfo workspace = catalog.getWorkspaceByName(prefix); workspace.setIsolated(isolated); catalog.save(workspace); // set the namespace isolation state using the provided one NamespaceInfo namespace = catalog.getNamespaceByPrefix(prefix); namespace.setIsolated(isolated); catalog.save(namespace); }
@Test public void retrieveLayersFromIsolatedWorkspace() { Catalog catalog = getCatalog(); // create two workspaces with the same namespace, one of them is isolated createWorkspace("test_e1", "https://www.test_e.com", false); createWorkspace("test_e2", "https://www.test_e.com", true); WorkspaceInfo workspace1 = catalog.getWorkspaceByName("test_e1"); NamespaceInfo namespace1 = catalog.getNamespaceByPrefix("test_e1"); WorkspaceInfo workspace2 = catalog.getWorkspaceByName("test_e2"); NamespaceInfo namespace2 = catalog.getNamespaceByPrefix("test_e2"); // add a layer with the same name to both workspaces, layers have different content LayerInfo clonedLayer1 = cloneVectorLayerIntoWorkspace(workspace1, namespace1, "Lines", "layer_e"); LayerInfo clonedLayer2 = cloneVectorLayerIntoWorkspace(workspace2, namespace2, "Points", "layer_e"); assertThat(clonedLayer1.getId(), not(clonedLayer2.getId())); // retrieving the layer from the isolated workspace, should fail LayerInfo layer1 = catalog.getLayerByName("test_e1:layer_e"); assertThat(layer1, notNullValue()); assertThat(layer1.getId(), is(clonedLayer1.getId())); LayerInfo layer2 = catalog.getLayerByName("test_e3:layer_e"); assertThat(layer2, nullValue()); } }
@Test public void testChangeWorkspace() { Catalog cat = createMock(Catalog.class); cat.addListener((CatalogListener) anyObject()); expectLastCall(); NamespaceInfo ns = createMock(NamespaceInfo.class); ns.setPrefix("abcd"); expectLastCall(); expect(cat.getNamespaceByPrefix("gs")).andReturn(ns); cat.save(ns); expectLastCall(); WorkspaceInfo ws = createNiceMock(WorkspaceInfo.class); CatalogModifyEvent e = createNiceMock(CatalogModifyEvent.class); expect(e.getSource()).andReturn(ws).anyTimes(); expect(e.getPropertyNames()).andReturn(Arrays.asList("name")); expect(e.getOldValues()).andReturn((List) Arrays.asList("gs")); expect(e.getNewValues()).andReturn((List) Arrays.asList("abcd")); replay(e, ws, ns, cat); new NamespaceWorkspaceConsistencyListener(cat).handleModifyEvent(e); verify(ns, cat); }
Catalog catalog = getCatalog(); NamespaceInfo ns = catalog.getNamespaceByPrefix(MockData.CITE_PREFIX); String newName = "XYWZ1234"; ns.setPrefix(newName); catalog.save(ns); assertNotNull(catalog.getWorkspaceByName(newName)); assertNotNull(catalog.getNamespaceByPrefix(newName)); ns = catalog.getNamespaceByPrefix(newName); ns.setPrefix(MockData.CITE_PREFIX); catalog.save(ns);
@Test public void testChangeDefaultWorkspace() { Catalog cat = createMock(Catalog.class); cat.addListener((CatalogListener) anyObject()); expectLastCall(); NamespaceInfo def = createNiceMock(NamespaceInfo.class); expect(cat.getDefaultNamespace()).andReturn(def); NamespaceInfo ns = createNiceMock(NamespaceInfo.class); expect(cat.getNamespaceByPrefix("abcd")).andReturn(ns); cat.setDefaultNamespace(ns); expectLastCall(); WorkspaceInfo ws = createNiceMock(WorkspaceInfo.class); expect(ws.getName()).andReturn("abcd"); CatalogModifyEvent e = createNiceMock(CatalogModifyEvent.class); expect(e.getSource()).andReturn(cat).anyTimes(); expect(e.getPropertyNames()).andReturn(Arrays.asList("defaultWorkspace")); expect(e.getNewValues()).andReturn((List) Arrays.asList(ws)); replay(ns, ws, e, cat); new NamespaceWorkspaceConsistencyListener(cat).handleModifyEvent(e); verify(ns, ws, cat); }
@Test public void testModifyNamespace() { catalog.add(ns); NamespaceInfo ns2 = catalog.getNamespaceByPrefix(ns.getPrefix()); ns2.setPrefix(null); ns2.setURI(null); try { catalog.save(ns2); fail("setting prefix to null should throw exception"); } catch (Exception e) { } ns2.setPrefix("ns2Prefix"); try { catalog.save(ns2); fail("setting uri to null should throw exception"); } catch (Exception e) { } ns2.setURI("ns2URI"); NamespaceInfo ns3 = catalog.getNamespaceByPrefix(ns.getPrefix()); assertEquals(ns.getPrefix(), ns3.getPrefix()); assertEquals(ns.getURI(), ns3.getURI()); catalog.save(ns2); // ns3 = catalog.getNamespaceByPrefix(ns.getPrefix()); ns3 = catalog.getNamespaceByPrefix("ns2Prefix"); assertEquals(ns2, ns3); assertEquals("ns2Prefix", ns3.getPrefix()); assertEquals("ns2URI", ns3.getURI()); }
@Test public void testCascadeWorkspace() { Catalog catalog = getCatalog(); WorkspaceInfo ws = catalog.getWorkspaceByName(CITE_PREFIX); new CascadeDeleteVisitor(catalog).visit(ws); // check the namespace is also gone assertNull(catalog.getNamespaceByPrefix(CITE_PREFIX)); // that workspace actually holds all layers, so check we got empty assertEquals(0, catalog.count(LayerInfo.class, Filter.INCLUDE)); assertEquals(0, catalog.count(ResourceInfo.class, Filter.INCLUDE)); assertEquals(0, catalog.count(StoreInfo.class, Filter.INCLUDE)); assertEquals(0, catalog.count(LayerGroupInfo.class, Filter.INCLUDE)); // the workspace specific style is also gone assertEquals(0, catalog.getStylesByWorkspace(CITE_PREFIX).size()); assertNull(catalog.getStyleByName(WS_STYLE)); }
assertNotNull(wsRenamed); assertEquals(newName, wsRenamed.getName()); final NamespaceInfo nsRenamed = getCatalog().getNamespaceByPrefix(newName); assertNotNull(nsRenamed); assertEquals(newName, nsRenamed.getName()); assertNotNull(wsRenamed2); assertEquals(newName, wsRenamed.getName()); final NamespaceInfo nsRenamed2 = getCatalog().getNamespaceByPrefix(newName); assertNotNull(nsRenamed2); assertEquals(newName, nsRenamed2.getName());