Hi,

I have already verified that.

The error is for removal of version name : "1.0" and the base version name is "1.2".

I've updated the example to make sure it never tries to remove the base version :

        Node root1 = session.getRootNode() ;
        Node test1 = root1.addNode("test") ;
        test1.addMixin("mix:versionable");
        test1.setProperty("test", "1");
        session.save();
        test1.checkin();

        test1.checkout();
        test1.setProperty("test", "2");
        session.save();
        test1.checkin();

        test1.checkout();
        test1.setProperty("test", "3");
        session.save();
        test1.checkin();

        String baseVersion = test1.getBaseVersion().getName();
        System.out.println("Base version name: " + baseVersion);

        VersionHistory vh = test1.getVersionHistory();
        for (VersionIterator vi = vh.getAllVersions(); vi.hasNext(); ) {
            Version currenVersion = vi.nextVersion();
            String versionName = currenVersion.getName();
if (!versionName.equals("jcr:rootVersion") && !versionName.equals(baseVersion)) { String propertyValue = currenVersion.getNode("jcr:frozenNode").getProperty("test").getString();

System.out.println("Removing version : " + versionName + " with value: " + propertyValue);
                vh.removeVersion(versionName);
            }
        }

Thanks,

Nicolas


Le 12:23 2005-11-18, vous avez écrit:
Hi Nicolas,

 I didn't try your code but I think it throws
ReferentialIntegrityException because you are trying to remove the
base version which is referenced by the versioned node.

see http://thread.gmane.org/gmane.comp.apache.jackrabbit.devel/3746

br,
edgar


On 11/18/05, Nicolas Belisle <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to remove a version of a Node, but the
> VersionHistory.removeVersion() method throws :
> "javax.jcr.ReferentialIntegrityException: Unable to remove version. At
> least once referenced.".
>
> Secton 8.2.2.10 (Removal of Versions) of the specification indicates that
> the version graph should be automatically repaired upon removal. Then,
> VersionHistory.removeVersion() should take care of references. In fact, a
> user cannot alter the references (jcr:predecessors and jcr:successors),
> since they are protected properties.
>
> Here's the example :
>
>          Node root1 = session.getRootNode() ;
>          Node test1 = root1.addNode("test") ;
>          test1.addMixin("mix:versionable");
>          test1.setProperty("test", "1");
>          session.save();
>          test1.checkin();
>
>          test1.checkout();
>          test1.setProperty("test", "2");
>          session.save();
>          test1.checkin();
>
>          test1.checkout();
>          test1.setProperty("test", "3");
>          session.save();
>          test1.checkin();
>
>          VersionHistory vh = test1.getVersionHistory();
>          for (VersionIterator vi = vh.getAllVersions(); vi.hasNext(); ) {
>              Version currenVersion = vi.nextVersion();
>              String versionName = currenVersion.getName();
>              if (!versionName.equals("jcr:rootVersion")) {
>                  String propertyValue =
> currenVersion.getNode("jcr:frozenNode").getProperty("test").getString();
>                  System.out.println("Removing version : " + versionName + "
> with value: " + propertyValue);
>                  vh.removeVersion(versionName);
>              }
>          }
>
> Something I do wrong ?
>
>
> Many thanks,
>
>
> Nicolas
>
>

Reply via email to