Commit 1fb09870 authored by Torben Barsbsballe's avatar Torben Barsbsballe
Browse files

[GEOS-7008] fix cascading delete for duplicate layers in layer group

parent efd7b226
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved
/* (c) 2014 - 2015 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
......@@ -126,8 +126,11 @@ public class CascadeDeleteVisitor implements CatalogVisitor {
// parallel remove of layer and styles
int index = group.getLayers().indexOf(layer);
group.getLayers().remove(index);
group.getStyles().remove(index);
while (index != -1) {
group.getLayers().remove(index);
group.getStyles().remove(index);
index = group.getLayers().indexOf(layer);
}
// either update or remove the group
if(group.getLayers().size() == 0) {
......
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved
/* (c) 2014 - 2015 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
......@@ -68,6 +68,26 @@ public class CascadeDeleteVisitorTest extends CascadeVisitorAbstractTest {
assertEquals(2, group.getLayers().size());
assertFalse(group.getLayers().contains(layer));
}
@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));
}
@Test
public void testCascadeStore() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment