jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mitziuro <mitzi...@gmail.com>
Subject Re: Delete problem
Date Thu, 03 Sep 2009 18:20:01 GMT
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))
                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
        NodeIterator nit = node.getNodes();
            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);


        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)
                Version v = null;
                while (vit.hasNext()) {
                    v = vit.nextVersion();
        } catch (Exception e) {
            // just log the exception...don't throw it
            logger.error("Error at deleting versions for node:

and after that i'm commiting the transaction started before:

DMETransaction.getInstance().commit((Session) args[0]) with the code

public void commit(Session s) {
        logger.debug("-----< comit transaction >-------");
        Xid xid = null;
        try {
            XASession session = (XASession) s;

            // get XAResource
            XAResource xares = session.getXAResource();
            xid = xids.get(s.toString());

            //commit transaction
            xares.end(xid, XAResource.TMSUCCESS);
            xares.commit(xid, false);

            //remove xid that unique identifies this transaction
        } catch(Exception e) {
            logger.error("", e);

and i've got this:

feea1825-175a-4579-a894-efb217b1a779: the node cannot be removed because it
is still being referenced.

Is there a way to include the version delete process in the same transaction
with the node ?

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message