List<ResourceInfo> layers = cat.getResourcesByStore(store, ResourceInfo.class );
if( layers.isEmpty() ){
cat.remove(store);
}
else if (recurse){
CascadeDeleteVisitor delete = new CascadeDeleteVisitor(cat);
if( store instanceof DataStoreInfo){
delete.visit((DataStoreInfo)store);
}
else if( store instanceof CoverageStoreInfo){
delete.visit((CoverageStoreInfo)store);
}
else if( store instanceof WMSStoreInfo){
delete.visit((WMSStoreInfo)store);
}
else {
throw new IllegalStateException( "Unable to delete "+name+" - expected data store, coverage store or wms store" );
}
}