Refine search
@Override public PublishedInfo visitNamedLayerInternal(StyledLayer namedLayer) { PublishedInfo p = catalog.getLayerGroupByName(namedLayer.getName()); if (p == null) { p = catalog.getLayerByName(namedLayer.getName()); } if (p == null) { validationErrors.add( new Exception( "No layer or layer group named '" + namedLayer.getName() + "' found in the catalog")); } return p; }
@Test public void testDanglingReferenceEqualsHashcode() { LayerInfo li = getCatalog().getLayerByName(getLayerId(SystemTestData.BUILDINGS)); // this would have failed with an exception, also check for stable hash code assertEquals(li.hashCode(), li.hashCode()); // despite the dangling reference, the layer is equal to itself assertTrue(li.equals(li)); } }
@Test public void testAddLayerToContainer() throws Exception { LayerInfo neatline = catalog.getLayerByName(getLayerId(MockData.MAP_NEATLINE)); container.getLayers().add(neatline); container.getStyles().add(null); catalog.save(container); assertThat(containerNamesForResource(MockData.MAP_NEATLINE), equalTo(set(CONTAINER_GROUP))); }
@Test public void testAddLayerGroup() throws Exception { testAddLayer(); // testAddStyle(); File f = new File(testData.getDataDirectoryRoot(), "layergroups/lg.xml"); assertFalse(f.exists()); LayerGroupInfo lg = catalog.getFactory().createLayerGroup(); lg.setName("lg"); lg.getLayers().add(catalog.getLayerByName("foo")); lg.getStyles().add(catalog.getStyleByName("foostyle")); lg.getLayers().add(catalog.getLayerByName("foo")); lg.getStyles().add(/* default style */ null); lg.getLayers().add(catalog.getLayerByName("foo")); lg.getStyles().add(catalog.getStyleByName("foostyle")); catalog.add(lg); assertTrue(f.exists()); }
void setupExtras(org.geoserver.data.test.SystemTestData testData, Catalog catalog) throws IOException { LayerInfo buildings = catalog.getLayerByName(getLayerId(BUILDINGS)); buildings.getStyles().add(catalog.getStyleByName(LAKES.getLocalPart())); catalog.save(buildings); LayerGroupInfo globalGroup = factory.createLayerGroup(); globalGroup.setName(LAKES_GROUP); globalGroup.getLayers().add(catalog.getLayerByName(getLayerId(LAKES))); globalGroup.getLayers().add(catalog.getLayerByName(getLayerId(FORESTS))); globalGroup.getLayers().add(catalog.getLayerByName(getLayerId(BRIDGES))); globalGroup.getStyles().add(null); globalGroup.getStyles().add(null); nestGroup.getLayers().add(catalog.getLayerByName(getLayerId(LAKES))); nestGroup.getLayers().add(globalGroup); nestGroup.getStyles().add(null);
@Test public void testModifyLayer() throws Exception { testAddLayer(); LayerInfo l = catalog.getLayerByName("foo"); l.setPath("/foo/bar"); catalog.save(l); File f = new File(testData.getDataDirectoryRoot(), "workspaces/acme/foostore/foo/layer.xml"); Document dom = dom(f); assertXpathEvaluatesTo("/foo/bar", "/layer/path", dom); }
} else { builder.updateCoverage(cov, coverage); catalog.save(cov); coverage = cov; LayerInfo layer = catalog.getLayerByName(new NameImpl(qName)); if (layer == null) { layer = catalog.getFactory().createLayer(); catalog.add(layer); } else { catalog.save(layer);
@Test public void testLayerGroupNullLayerOrStyleReferences() throws IOException { Catalog catalog = getCatalog(); LayerGroupInfo lg = catalog.getFactory().createLayerGroup(); LayerInfo l = catalog.getLayerByName(getLayerId(MockData.ROAD_SEGMENTS)); StyleInfo s = catalog.getStyleByName("singleStyleGroup"); lg.setWorkspace(null); lg.setName("threeTypeLayerGroup"); // layer with default style lg.getLayers().add(l); lg.getStyles().add(null); // style group lg.getLayers().add(null); lg.getStyles().add(s); lg.getLayers().add(null); lg.getStyles().add(null); catalog.add(lg); LayerGroupInfo resolved = catalog.getLayerGroupByName("threeTypeLayerGroup"); assertEquals(2, resolved.layers().size()); assertEquals(2, resolved.styles().size()); assertEquals(l, resolved.layers().get(0)); assertEquals(s.getStyle(), resolved.styles().get(1).getStyle()); }
@Test public void testAddLayerToNature() throws Exception { LayerInfo neatline = catalog.getLayerByName(getLayerId(MockData.MAP_NEATLINE)); nature.getLayers().add(neatline); nature.getStyles().add(null); catalog.save(nature); assertThat(containerNamesForResource(MockData.MAP_NEATLINE), equalTo(set(CONTAINER_GROUP))); }
expect(cat.getLayerByName(new NameImpl("ws1", "l1"))).andReturn(l1).anyTimes(); expect(cat.getLayerByName("l1")).andReturn(null).anyTimes(); expect(cat.getLayerByName(new NameImpl("ws2", "l2"))).andReturn(l2).anyTimes(); expect(cat.getLayerByName("l2")).andReturn(null).anyTimes(); expect(cat.getLayerByName(new NameImpl("ws1", "lc"))).andReturn(lc1).anyTimes(); expect(cat.getLayerByName(new NameImpl("ws2", "lc"))).andReturn(lc2).anyTimes(); expect(cat.getLayerByName("lc")).andReturn(lc1).anyTimes(); layers.add(l1); layers.add(l2); layers.add(lc1); layers.add(lc2); expect(cat.getLayers()).andReturn(layers).anyTimes();
featureType.getKeywords().add(new Keyword(name)); featureType.setEnabled(true); featureType.setProjectionPolicy( LayerInfo layer = catalog.getLayerByName(new NameImpl(uri, name)); if (ft == null) { ft = featureType; } else { new CatalogBuilder(catalog).updateFeatureType(ft, featureType); catalog.save(ft); catalog.add(layer); } else { catalog.save(layer);
@Test public void testRemoveLayer() throws Exception { testAddLayer(); File f = new File(testData.getDataDirectoryRoot(), "workspaces/acme/foostore/foo/layer.xml"); assertTrue(f.exists()); LayerInfo l = catalog.getLayerByName("foo"); catalog.remove(l); assertFalse(f.exists()); }
@Test public void testRemoveLayerFromNature() throws Exception { LayerInfo lakes = catalog.getLayerByName(getLayerId(MockData.LAKES)); nature.getLayers().remove(lakes); nature.getStyles().remove(0); catalog.save(nature); assertThat(containerNamesForResource(MockData.LAKES), empty()); assertThat(containerNamesForResource(MockData.FORESTS), equalTo(set(CONTAINER_GROUP))); assertThat( containerNamesForResource(MockData.ROAD_SEGMENTS), equalTo(set(CONTAINER_GROUP))); }
@Override protected void handleObjectPut(Object object) throws Exception { String l = getAttribute( "layer" ); LayerInfo original = catalog.getLayerByName(l); LayerInfo layer = (LayerInfo) object; //ensure this is not a name change // TODO: Uncomment this when the resource/layer split is not, now by definition // we cannot rename a layer, it's just not possible and it's not un-marshalled either // if ( layer.getName() != null && !layer.getName().equals( original.getName() ) ) { // throw new RestletException( "Can't change name of a layer", Status.CLIENT_ERROR_FORBIDDEN ); // } // force in the same resource otherwise the update will simply fail as we cannot reach the name layer.setResource(original.getResource()); new CatalogBuilder( catalog ).updateLayer( original, layer ); catalog.save( original ); LOGGER.info( "PUT layer " + l); }
@Test public void testAddLayerGroupWithWorkspace() throws Exception { File f = file( testData.getDataDirectoryRoot(), "workspaces/acme/layergroups/foolayergroup.xml"); assertFalse(f.exists()); testAddLayer(); LayerGroupInfo lg = catalog.getFactory().createLayerGroup(); lg.setName("foolayergroup"); lg.setWorkspace(catalog.getWorkspaceByName("acme")); lg.getLayers().add(catalog.getLayerByName("foo")); lg.getStyles().add(null); catalog.add(lg); assertTrue(f.exists()); Document dom = dom(f); assertXpathEvaluatesTo( catalog.getWorkspaceByName("acme").getId(), "/layerGroup/workspace/id", dom); }
@Test public void testCascadeLayerDuplicate() { Catalog catalog = getCatalog(); String name = toString(LAKES); LayerInfo layer = catalog.getLayerByName(name); assertNotNull(layer); LayerGroupInfo group = catalog.getLayerGroupByName(LAKES_GROUP); group.getLayers().add(layer); group.getStyles().add(null); catalog.save(group); CascadeDeleteVisitor visitor = new CascadeDeleteVisitor(catalog); visitor.visit(layer); group = catalog.getLayerGroupByName(LAKES_GROUP); assertEquals(2, group.getLayers().size()); assertFalse(group.getLayers().contains(layer)); }
@Override protected void onSetUp(SystemTestData testData) throws Exception { super.onSetUp(testData); Catalog catalog = getCatalog(); LayerInfo layer = catalog.getLayerByName(new NameImpl(CiteTestData.BASIC_POLYGONS)); StyleInfo style = catalog.getStyleByName(CiteTestData.DEFAULT_VECTOR_STYLE); CatalogFactory factory = catalog.getFactory(); LayerGroupInfo lg1 = factory.createLayerGroup(); lg1.setName("LayerGroup1"); lg1.getLayers().add(layer); lg1.getStyles().add(style); catalog.add(lg1); LayerGroupInfo lg2 = factory.createLayerGroup(); lg2.setName("LayerGroup2"); lg2.setWorkspace(catalog.getWorkspaceByName(CiteTestData.CITE_PREFIX)); lg2.getLayers().add(layer); lg2.getStyles().add(style); catalog.add(lg2); }
@Override protected void onSetUp(SystemTestData testData) throws Exception { // insert extra metadata ResourceInfo forestInfo = getCatalog().getLayerByName("Forests").getResource(); forestInfo.getMetadata().put("date", "09/10/2012"); forestInfo.setLatLonBoundingBox(new ReferencedEnvelope(-200, -180, -100, -90, CRS .decode("EPSG:4326"))); forestInfo.getKeywords().add(new Keyword ("CustomKeyWord-1")); forestInfo.getKeywords().add(new Keyword ("CustomKeyWord-2")); forestInfo.setDescription("Land with lots of trees on."); forestInfo.getAlias().add("Bush"); forestInfo.getAlias().add("Woods"); getCatalog().save(forestInfo); }
@Test public void testDanglingReferenceOnModificationProxy() { LayerInfo li = getCatalog().getLayerByName(getLayerId(SystemTestData.BUILDINGS)); assertNull(li.getDefaultStyle()); }
@Test public void testRemoveLayerFromContainer() throws Exception { LayerInfo roads = catalog.getLayerByName(getLayerId(MockData.ROAD_SEGMENTS)); container.getLayers().remove(roads); container.getStyles().remove(0); catalog.save(container); assertThat(containerNamesForResource(MockData.LAKES), equalTo(set(CONTAINER_GROUP))); assertThat(containerNamesForResource(MockData.FORESTS), equalTo(set(CONTAINER_GROUP))); assertThat(containerNamesForResource(MockData.ROAD_SEGMENTS), empty()); }