// collect the objects that will be removed (besides the roots)
Catalog catalog = GeoServerApplication.get().getCatalog();
CascadeRemovalReporter visitor = new CascadeRemovalReporter(catalog);
for (Iterator<CatalogInfo> i = (Iterator<CatalogInfo>) roots.iterator(); i.hasNext();) {
CatalogInfo root = i.next();
StringResourceModel reason = canRemove(root);
if ( reason != null ) {
notRemoved.put(root, reason);
i.remove();
}
else {
root.accept(visitor);
}
}
visitor.removeAll(roots);
// add roots
WebMarkupContainer root = new WebMarkupContainer("rootObjects");
root.add(new Label("rootObjectNames", names(roots)));
root.setVisible( !roots.isEmpty() );
add(root);
// objects that could not be removed
WebMarkupContainer nr = new WebMarkupContainer("notRemovedObjects");
nr.setVisible( !notRemoved.isEmpty() );
nr.add( notRemovedList(notRemoved));
add(nr);
// removed objects root (we show it if any removed object is on the list)
WebMarkupContainer removed = new WebMarkupContainer("removedObjects");
List<CatalogInfo> cascaded = visitor.getObjects(CatalogInfo.class, DELETE);
// remove the resources, they are cascaded, but won't be show in the UI
for (Iterator it = cascaded.iterator(); it.hasNext();) {
CatalogInfo catalogInfo = (CatalogInfo) it.next();
if(catalogInfo instanceof ResourceInfo)
it.remove();
}
removed.setVisible(cascaded.size() > 0);
add(removed);