So, I have the following code for deleting a node:

VersionHistory vh = null;
        boolean versionable = false;
        String uuid = node.getUUID();

        try {
            // check if node is versionable
            if (((NodeImpl) node).isNodeType(NameConstants.MIX_VERSIONABLE))
{
                node.checkout();
                logger.debug("node is versionable...get version history");
                vh = node.getVersionHistory();
                versionable = true;

            }
        } catch (Exception e) {
            // just log the exception...don't throw it
            logger.debug("Error at getting the version history for node: "
                    .concat(uuid), e);
        }

        Node child = null;

        // before removing the node, first remove all its children and their
versions
        NodeIterator nit = node.getNodes();
        while(nit.hasNext()){
            child = nit.nextNode();
            // check if the child is rep:policy
            if (child.getPrimaryNodeType().isNodeType(NODE_TYPE_ACL)) {
                //no op. rep:policy children are deleted automatically
            } else{
                // delete the child and its subtree and their versions
                delete(session, child);
            }
        }

        node.remove();
        session.save();

        //DMETransaction.getInstance().commit(session);

        try {
            // check if node is versionable
            if (versionable) {

                logger.debug("node is versionable...delete all versions");
                // delete version history
                VersionIterator vit = vh.getAllVersions();
                // skip the root version(it cannot be deleted)
                vit.skip(1);
                Version v = null;
                while (vit.hasNext()) {
                    v = vit.nextVersion();
                    vh.removeVersion(v.getName());
                }
            }
        } catch (Exception e) {
            // just log the exception...don't throw it
            logger.error("Error at deleting versions for node:
".concat(uuid),
                    e);
        }

On Thu, Sep 3, 2009 at 11:52 AM, Alexander Klimetschek <[email protected]>wrote:

> On Thu, Sep 3, 2009 at 10:51 AM, Alexander Klimetschek<[email protected]>
> wrote:
> > AFAIK, deleting the root node is not possible.
>
> Deleting the root *version* that is ;-)
>
> Regards,
> Alex
>
> --
> Alexander Klimetschek
> [email protected]
>

Reply via email to