jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian Thompson" <elephant...@gmail.com>
Subject Re: Removing root version
Date Fri, 06 Apr 2007 15:30:08 GMT
As it happens, I ran into a similar issue today.  There are cases where I
need to delete a versionable node entirely - including the entire version
history for that node.  My current code only deletes the head version,
leaving the version history intact.

Does anyone have any hints on how to completely eradicate a version history?

-Brian


On 4/5/07, Lubos and Alena Pochman <pochmans@gmail.com> wrote:
>
> I finally made it work. Here is what I do to emulate head (base) version
> rollback behavior (delete head version):
>
> 1. Get base version of the node
> 2. From base version get predecessor
> 3. Create new version of the node (checkout, checkin) from the predecessor
> 4. The head (base) version now contains the rolled back version, its
> predecessor is original head and its predecessor is the original rollback.
> 5. Remove the original head and rollback using
> VersionHistory.removeVersion
> ()
>
> Versions and predecessors needs to be checked for jcr:rootVersion!
>
> This is somewhat similar to what you would do by rolling back head version
> in source control system.
>
> On 4/4/07, Tobias Bocanegra <tobias.bocanegra@day.com> wrote:
> >
> > hi,
> > you cannot remove a version with the normal Node.remove() method. use
> > VersionHistory.removeVersion() instead. further, you cannot remove the
> > root version, since it's part of the initial version history.
> >
> > regards, toby
> >
> > On 4/4/07, Lubos and Alena Pochman <pochmans@gmail.com> wrote:
> > > Thanks Brian,
> > >
> > > yes I am checking out the document node before I get the version
> > history.
> > > It looks like you cannot remove the head (base/top) version from the
> > version
> > > list.
> > > Anybody from developers to confirm that?
> > >
> > > Lubos
> > >
> > > On 4/3/07, Brian Thompson <elephantium@gmail.com> wrote:
> > > >
> > > > Are you checking out the document node before you check on its
> version
> > > > history?  If not, that might cause the problem.
> > > >
> > > > Also, if you're removing the document node, you probably have to
> check
> > out
> > > > its parent.
> > > >
> > > > -Brian
> > > >
> > > >
> > > >
> > > > On 4/3/07, Lubos and Alena Pochman <pochmans@gmail.com> wrote:
> > > > >
> > > > > 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
> > > > >
> > > >
> > >
> >
> >
> > --
> > -----------------------------------------< tobias.bocanegra@day.com >---
> > Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
> > T +41 61 226 98 98, F +41 61 226 98 97
> > -----------------------------------------------< http://www.day.com >---
> >
>

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