recursiveAddChildren(wikiNodeDAO, node, nodesToDelete);
}
while (!nodesToDelete.isEmpty())
{
WikiNode nodeToDelete = null;
main: for (WikiNode node : nodesToDelete)
{
// We need to find a node without children contained in the same set (which should contain any children if they exist)
for (WikiNode n : nodesToDelete)
{
if (n.getParent().equals(node)) continue main;
}
nodeToDelete = node;
break;
}
if (nodeToDelete == null)
{
throw new IllegalStateException("Error while deleting child nodes - no childless node found in set.");
}
else
{
if (nodeToDelete instanceof WikiComment)
{
WikiComment comment = (WikiComment) nodeToDelete;
documentHome.setId(getCommentDocument(comment).getId());
CommentHome commentHome = (CommentHome) Component.getInstance("commentHome");
commentHome.setId(comment.getId());
commentHome.remove(comment.getId());
}
else if (nodeToDelete instanceof WikiDocument)
{
documentHome.setId(nodeToDelete.getId());
documentHome.reallyRemove();
}
else
{
log.info("Unhandled node found, could not delete: " + nodeToDelete);