public void deleteCatalogEntry(CatalogEntry ce) {
log.debug("deleteCatalogEntry start... ce=" + ce);
Manager securityManager = ManagerFactory.getManager();
if (ce.getType() == CatalogEntry.TYPE_LEAF) {
//delete catalog entry, then delete owner group
SecurityGroup owner = ce.getOwnerGroup();
DBFactory.getInstance().deleteObject(ce);
if (owner != null) {
log.debug("deleteCatalogEntry case_1: delete owner-group=" + owner);
securityManager.deleteSecurityGroup(owner);
}
} else {
List secGroupsToBeDeleted = new ArrayList();
//FIXME pb: the transaction must also include the deletion of the security
// groups. Why not using this method as a recursion and seperating the
// deletion of the ce and the groups by collecting the groups? IMHO there
// are not less db queries. This way the code is much less clear, e.g. the method
// deleteCatalogSubtree does not really delete the subtree, it leaves the
// security groups behind. I would preferre to have one delete method that
// deletes its children first by calling itself on the children and then deletes
// itself ant its security group. The nested transaction that occures is actually
// not a problem, the DB object can handel this.
deleteCatalogSubtree(ce,secGroupsToBeDeleted);
// after deleting all entries, delete all secGroups corresponding
for (Iterator iter = secGroupsToBeDeleted.iterator(); iter.hasNext();) {
SecurityGroup grp = (SecurityGroup) iter.next();
log.debug("deleteCatalogEntry case_2: delete groups of deleteCatalogSubtree grp=" + grp);
securityManager.deleteSecurityGroup(grp);
}
}
log.debug("deleteCatalogEntry END");