jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lubos and Alena Pochman" <pochm...@gmail.com>
Subject Removing root version
Date Tue, 03 Apr 2007 22:45:41 GMT
I would like to implement rollback function for the versioned node. If node
has only one version, the node itself is removed. If there is more then one
version
of the node, the root (top, head) node is removed. I tried v.remove() or
history.removeVersion(v.getName()), but both fail with exception:

javax.jcr.nodetype.ConstraintViolationException:
/jcr:system/jcr:versionStorage/23/4c/e0/234ce0e4-4a6a-435c-a4b4-7a8e3fe4f2cf/jcr:rootVersion:
cannot remove a protected node

Here is the code:

            VersionHistory history = document.getVersionHistory();
            VersionIterator ito = history.getAllVersions();
            if (ito.hasNext()) {
                Version v = ito.nextVersion(); // Top version
                if (ito.hasNext())
                    v.remove();
                else
                    document.remove();
                session.save();
            }


My question is, is it possible or do I have to use workaround like create
new version from version head-1 (create new version) and then remove the
original root version and the original head-1 version?

Thanks, Lubos

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