@Override public String prefixedName() { return delegate.prefixedName(); }
@Override public String getPrefixedName() { return delegate.prefixedName(); }
localGroup.getStyles().add(null); catalog.add(localGroup); String localName = localGroup.prefixedName(); assertEquals("sf:localGroup", localName); assertNotNull(catalog.getLayerGroupByName("localGroup")); assertEquals(1, catalog.getLayerGroups().size()); assertEquals("localGroup", catalog.getLayerGroupByName("localGroup").prefixedName()); settings.setWorkspace(workspace); gs.add(settings); assertEquals("sf:localGroup", catalog.getLayerGroupByName("localGroup").prefixedName()); assertEquals("sf:localGroup", catalog.getLayerGroups().get(0).prefixedName()); gs.remove(settings);
public static String tileLayerName(LayerGroupInfo lgi) { return lgi.prefixedName(); }
public static String tileLayerName(LayerGroupInfo lgi) { return lgi.prefixedName(); }
@Override public Object getPropertyValue(PreviewLayer item) { if (item.layerInfo != null) { return item.layerInfo.prefixedName(); } if (item.groupInfo != null) { return item.groupInfo.prefixedName(); } return null; } };
public String getName() { if (layerInfo != null) { return layerInfo.getResource().prefixedName(); } else { return groupInfo.prefixedName(); } }
/** * Same as {@link #testWmsStandaloneOpaqueGroup()} but with a nested group as the testing target */ @Test public void testWmsNestedInStandaloneOpaqueGroup() throws Exception { setupRequestThreadLocal("WMS"); // setup group LayerGroupInfo nested = buildLayerGroup(NESTED_GROUP_NAME, Mode.NAMED, null, statesLayer); LayerGroupInfo opaque = buildLayerGroup(OPAQUE_GROUP_NAME, Mode.OPAQUE_CONTAINER, null, nested, roadsLayer); layerGroups = Arrays.asList(nested, opaque); populateCatalog(); // setup security buildManager(DEFAULT_RULES); SecurityContextHolder.getContext().setAuthentication(roUser); // direct access to nested group not allowed, nor to its layers assertNull(sc.getLayerGroupByName(NESTED_GROUP_NAME)); assertNull(sc.getLayerByName(statesLayer.prefixedName())); assertNull(sc.getLayerByName(roadsLayer.prefixedName())); // however we can access the group as part of the opaque one LayerGroupInfo securedGroup = sc.getLayerGroupByName(opaque.prefixedName()); assertNotNull(securedGroup); assertEquals(2, securedGroup.getLayers().size()); assertThat(securedGroup.getLayers(), contains(nested, roadsLayer)); assertThat(securedGroup.layers(), contains(statesLayer, roadsLayer)); }
@Test public void testWmsNamedOpaqueGroup() throws Exception { setupRequestThreadLocal("WMS"); LayerGroupInfo opaque = prepareNamedAndOpaqueGroup(); // direct access to layers allowed because of the named group assertNotNull(sc.getLayerByName(statesLayer.prefixedName())); assertNotNull(sc.getLayerByName(roadsLayer.prefixedName())); // we can access the group and the layers through it LayerGroupInfo securedGroup = sc.getLayerGroupByName(opaque.prefixedName()); assertNotNull(securedGroup); assertEquals(2, securedGroup.getLayers().size()); }
@Test public void testWfsNamedOpaqueGroup() throws Exception { setupRequestThreadLocal("WFS"); LayerGroupInfo opaque = prepareNamedAndOpaqueGroup(); // direct access to layers allowed assertNotNull(sc.getLayerByName(statesLayer.prefixedName())); assertNotNull(sc.getLayerByName(roadsLayer.prefixedName())); // and we can access the group and the layers through it LayerGroupInfo securedGroup = sc.getLayerGroupByName(opaque.prefixedName()); assertNotNull(securedGroup); assertEquals(2, securedGroup.getLayers().size()); }
@Test public void testWmsStandaloneOpaqueGroup() throws Exception { setupRequestThreadLocal("WMS"); LayerGroupInfo opaque = prepareStandaloneOpaqueGroup(); // direct access to layers not allowed assertNull(sc.getLayerByName(statesLayer.prefixedName())); assertNull(sc.getLayerByName(roadsLayer.prefixedName())); // however we can access the group and the layers through it LayerGroupInfo securedGroup = sc.getLayerGroupByName(opaque.prefixedName()); assertNotNull(securedGroup); assertEquals(2, securedGroup.getLayers().size()); }
@Test public void testWfsStandaloneOpaqueGroup() throws Exception { setupRequestThreadLocal("WFS"); LayerGroupInfo opaque = prepareStandaloneOpaqueGroup(); // direct access to layers is allowed in this case assertNotNull(sc.getLayerByName(statesLayer.prefixedName())); assertNotNull(sc.getLayerByName(roadsLayer.prefixedName())); // and we can access the group and the layers through it LayerGroupInfo securedGroup = sc.getLayerGroupByName(opaque.prefixedName()); assertNotNull(securedGroup); assertEquals(2, securedGroup.getLayers().size()); }
@Test public void testWMSLayerGroupAllowsAccess() throws Exception { // prepare the stage setupRequestThreadLocal("WMS"); buildManager("namedTreeAllow.properties"); // try with read only user, only layer group A and its contents should be visible SecurityContextHolder.getContext().setAuthentication(roUser); assertNotNull(sc.getLayerGroupByName(namedTreeA.getName())); assertNotNull(sc.getLayerByName(statesLayer.prefixedName())); assertNotNull(sc.getLayerByName(roadsLayer.prefixedName())); assertNotNull(sc.getLayerByName(citiesLayer.prefixedName())); // layer group B should not be accessible assertNull(sc.getLayerGroupByName(containerTreeB.prefixedName())); assertNull(sc.getLayerByName(landmarksLayer.prefixedName())); // the single group not available either assertNull(sc.getLayerGroupByName(singleGroupC.prefixedName())); assertNull(sc.getLayerByName(basesLayer.prefixedName())); // the ws specific group is not available either assertNull(sc.getLayerGroupByName("nurc", "wsContainerD")); assertNull(sc.getLayerByName(arcGridLayer.prefixedName())); }
@Test public void testWMSLayerGroupAllowWorkspaceOverride() throws Exception { // prepare the stage setupRequestThreadLocal("WMS"); buildManager("namedTreeAllowWorkspaceOverride.properties"); // try with read only user, only layer group A and its contents should be visible SecurityContextHolder.getContext().setAuthentication(roUser); assertNotNull(sc.getLayerGroupByName(namedTreeA.getName())); assertNull(sc.getLayerByName(statesLayer.prefixedName())); assertNull(sc.getLayerByName(roadsLayer.prefixedName())); assertNotNull(sc.getLayerByName(citiesLayer.prefixedName())); // layer group B should not be accessible assertNull(sc.getLayerGroupByName(containerTreeB.prefixedName())); assertNull(sc.getLayerByName(landmarksLayer.prefixedName())); // the single group not available either assertNull(sc.getLayerGroupByName(singleGroupC.prefixedName())); assertNull(sc.getLayerByName(basesLayer.prefixedName())); // the ws specific group is not available either assertNull(sc.getLayerGroupByName("nurc", "wsContainerD")); assertNull(sc.getLayerByName(arcGridLayer.prefixedName())); }
@Test public void testWMSLayerGroupAllowLayerOverride() throws Exception { // prepare the stage setupRequestThreadLocal("WMS"); buildManager("namedTreeAllowLayerOverride.properties"); // try with read only user, only layer group A and its contents should be visible, but // not topp:states SecurityContextHolder.getContext().setAuthentication(roUser); assertNotNull(sc.getLayerGroupByName(namedTreeA.getName())); assertNull(sc.getLayerByName(statesLayer.prefixedName())); assertNotNull(sc.getLayerByName(roadsLayer.prefixedName())); assertNotNull(sc.getLayerByName(citiesLayer.prefixedName())); // layer group B should not be accessible assertNull(sc.getLayerGroupByName(containerTreeB.prefixedName())); assertNull(sc.getLayerByName(landmarksLayer.prefixedName())); // the single group not available either assertNull(sc.getLayerGroupByName(singleGroupC.prefixedName())); assertNull(sc.getLayerByName(basesLayer.prefixedName())); // the ws specific group is not available either assertNull(sc.getLayerGroupByName("nurc", "wsContainerD")); assertNull(sc.getLayerByName(arcGridLayer.prefixedName())); }
@Test public void testContainerLayerGroup() throws Exception { String layerId = getLayerId(MockData.BUILDINGS); LayerInfo layer = getCatalog().getLayerByName(layerId); LayerGroupInfo group = getCatalog().getFactory().createLayerGroup(); group.setName("testContainerLayerGroup"); group.setMode(LayerGroupInfo.Mode.CONTAINER); group.getLayers().add(layer); getCatalog().add(group); try { PreviewLayerProvider provider = new PreviewLayerProvider(); PreviewLayer pl = getPreviewLayer(provider, group.prefixedName()); assertNull(pl); } finally { getCatalog().remove(group); } }
@Test public void testWorkspacedLayerGroup() throws Exception { String layerId = getLayerId(MockData.BUILDINGS); LayerInfo layer = getCatalog().getLayerByName(layerId); WorkspaceInfo ws = getCatalog().getWorkspaceByName("cite"); LayerGroupInfo group = getCatalog().getFactory().createLayerGroup(); group.setName("testWorkspacedLayerGroup"); group.setMode(LayerGroupInfo.Mode.SINGLE); group.setWorkspace(ws); group.getLayers().add(layer); getCatalog().add(group); try { PreviewLayerProvider provider = new PreviewLayerProvider(); PreviewLayer pl = getPreviewLayer(provider, group.prefixedName()); assertNotNull(pl); assertEquals("cite:testWorkspacedLayerGroup", pl.getName()); } finally { getCatalog().remove(group); } }
@Test public void testSingleLayerGroup() throws Exception { String layerId = getLayerId(MockData.BUILDINGS); LayerInfo layer = getCatalog().getLayerByName(layerId); LayerGroupInfo group = getCatalog().getFactory().createLayerGroup(); group.setName("testSingleLayerGroup"); group.setMode(LayerGroupInfo.Mode.SINGLE); group.getLayers().add(layer); group.setTitle("This is the title"); group.setAbstract("This is the abstract"); getCatalog().add(group); try { PreviewLayerProvider provider = new PreviewLayerProvider(); PreviewLayer pl = getPreviewLayer(provider, group.prefixedName()); assertNotNull(pl); assertEquals("This is the title", pl.getTitle()); assertEquals("This is the abstract", pl.getAbstract()); } finally { getCatalog().remove(group); } }
@Test public void testNestedContainerLayerGroup() throws Exception { String layerId = getLayerId(MockData.BUILDINGS); LayerInfo layer = getCatalog().getLayerByName(layerId); LayerGroupInfo containerGroup = getCatalog().getFactory().createLayerGroup(); containerGroup.setName("testContainerLayerGroup"); containerGroup.setMode(LayerGroupInfo.Mode.SINGLE); containerGroup.getLayers().add(layer); getCatalog().add(containerGroup); LayerGroupInfo singleGroup = getCatalog().getFactory().createLayerGroup(); singleGroup.setName("testSingleLayerGroup"); singleGroup.setMode(LayerGroupInfo.Mode.SINGLE); singleGroup.getLayers().add(containerGroup); getCatalog().add(singleGroup); try { PreviewLayerProvider provider = new PreviewLayerProvider(); assertNotNull(getPreviewLayer(provider, singleGroup.prefixedName())); assertNotNull(getPreviewLayer(provider, layer.prefixedName())); } finally { getCatalog().remove(singleGroup); getCatalog().remove(containerGroup); } }
@Test public void testOpaqueContainerLayerGroup() throws Exception { String layerId = getLayerId(MockData.BUILDINGS); LayerInfo layer = getCatalog().getLayerByName(layerId); LayerGroupInfo group = getCatalog().getFactory().createLayerGroup(); group.setName("testOpaqueContainerLayerGroup"); group.setMode(LayerGroupInfo.Mode.OPAQUE_CONTAINER); group.getLayers().add(layer); group.setTitle("This is the title"); group.setAbstract("This is the abstract"); getCatalog().add(group); try { PreviewLayerProvider provider = new PreviewLayerProvider(); PreviewLayer pl = getPreviewLayer(provider, group.prefixedName()); assertNotNull(pl); assertEquals("This is the title", pl.getTitle()); assertEquals("This is the abstract", pl.getAbstract()); } finally { getCatalog().remove(group); } }