On Wednesday 30 August 2006 17:08, David Nuescheler wrote:

Tried it in first place but encountered one problem - removing last version 
throws  VersionException with message "Unable to remove version. At least 
once referenced" and removing jcr:rootVersion throws "Removal of 
{http://www.jcp.org/jcr/1.0}rootVersion not allowed."
That makes at least two constant record of all removed nodes as informational 
garbage in JCR repository. (in a long run it produces lot's and lot's of 
records in persistance storage) 
I also include some code that I used as example run.

> Hi Alexander,
>
> Ok, thanks for the explanation.
>
> I think what you are looking for is:
>
> http://www.day.com/maven/jsr170/javadocs/jcr-1.0/javax/jcr/version/VersionH
>istory.html#removeVersion(java.lang.String)
>
> which allows to iterate through the version history and get rid
> of all the versions. Is that correct?
>
> regards,
> david
>
> On 8/30/06, Pospishniy Alexander <[EMAIL PROTECTED]> wrote:
> > On Wednesday 30 August 2006 16:38, David Nuescheler wrote:
> >
> > For security reasons we need to do the following actions:
> > 1. Remove node from storage and destroy ALL traces of it's existence in
> > repository. Now we see that removing a node leaves all it's versions in
> > database no matter what we do.
> > 2. We need to set all data occupied by node to null(0) values before we
> > do actual removal. It's like low level format but in  the repository
> > plane. Setting all properties of a node to null is no problem, but
> > clearing it's version is as we can't modify them in any way known to us.
> >
> > Is there any way to perform such actions in jackrabbit? Again, it's local
> > security issue and is very important to us no matter it's illogical
> > nature )
> >
> > > Hi Paranoid,
> > >
> > > I am not exactly clear on what you are trying to do.
> > >
> > > Are you trying to remove versions? Which is
> > > possible, but tends to an administrative task, which
> > > I would refrain from using in an application if possible.
> > >
> > > Are you looking for a removal of a node from one
> > > workspace and also removing the entire version
> > > history (for all the workspaces) at the same time?.
> > >
> > > If I think of the equivalent of such an operation for
> > > something like a CVS or Subversion repository,
> > > it sounds like a highly unlikely, questionable and
> > > even potentially harmful operation, that would need
> > > to be executed very carefully, right?
> > >
> > > Maybe you can explain your use case a little bit more
> > > in detail and why removing the individual versions from
> > > the version history is not satisfactory?
> > >
> > > regards,
> > > david
	    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);
            test1.checkout();


            VersionHistory vh = test1.getVersionHistory();
            for (VersionIterator vi = vh.getAllVersions(); vi.hasNext();) {
                Version currenVersion = vi.nextVersion();
                String versionName = currenVersion.getName();
                try {
                    //REMOVING THIS IF WILL PRODUCE EXEPTIONS!!!
                    if (!versionName.equals("jcr:rootVersion") && !versionName.equals("1.2")) {
                        vh.removeVersion(versionName);
                        session.save();      
                    }
                } catch (Exception e) {
                    System.out.println(e.getMessage());
                }
            }


            test1.checkout();
            test1.removeMixin("mix:versionable");
            test1.remove();
            root1.save();
            session.save();

Reply via email to