Thanks a lot Marek.
So I understand, this is not possible to remove the root version of the 
history. I guess this is to ensure referential integrity. Because old versions 
of others node can have a frozen reference to the stack of the node we want to 
remove.
And I have another question if you don't mind. In my example we have a node 
with versions 1.1, 1.2 and 1.3. We remove the version 1.2 as you explained. I 
think the version 1.3 becomes 1.2. But, what if we restore the Version 1.2 
using VersionManager.restore(Version version, boolean removeExisting).
Thanks for your help.

Adrien

-----Original Message-----
From: [email protected] [mailto:[email protected]] 
Sent: 17 May 2012 09:17
To: [email protected]
Subject: Re: RE: Migrate JCR repositories

How to remove version history:

As we remove node which has some version history we take version history first 
then remove versioned node and then remove all version history nodes but root 
node.

        VersionManager versionManager = 
session.getWorkspace().getVersionManager();
        VersionHistory versionHistory = 
versionManager.getVersionHistory(node.getPath());
        node.remove();
        //Must call session.save to commit remove otherwise removeVersion does 
not work
        session.save();
            VersionIterator vIt = versionHistory.getAllVersions();
            while (vIt.hasNext()) {
                Version version = vIt.nextVersion();
                if (!"jcr:rootVersion".equals(version.getName())) {
                    //removeVersion writes directly to workspace, no 
session.save is necessary
                    versionHistory.removeVersion(version.getName());
                }
            }

Marek
> ------------ Původní zpráva ------------
> Od: De Georges, Adrien <[email protected]>
> Předmět: RE: Migrate JCR repositories
> Datum: 16.5.2012 11:42:56
> ----------------------------------------
> Guys,
> Does somebody know how to remove nodes from the version history.
> Thanks in advance
> 
> Adrien
> 
> -----Original Message-----
> From: De Georges, Adrien [mailto:[email protected]]
> Sent: 10 May 2012 15:55
> To: [email protected]
> Subject: Migrate JCR repositories
> 
> Hi everyone,
> 
> I wanted to develop a routine to migrate some nodes in a repository 
> (removing and modifying some properties). But I am pretty sure it is 
> not possible to modify nodes in the version history. Is there existing 
> solution to do so?
> Thanks
> 
> Adrien
> 
> 
> 
> Information in this e-mail and any attachments is confidential, and 
> may not be copied or used by anyone other than the addressee, nor 
> disclosed to any third party without our permission. There is no 
> intention to create any legally binding contract or other binding 
> commitment through the use of this electronic communication unless it 
> is issued in accordance with the Experian Limited standard terms and 
> conditions of purchase or other express written agreement between 
> Experian Limited and the recipient. Although Experian has taken 
> reasonable steps to ensure that this communication and any attachments 
> are free from computer virus, you are advised to take your own steps 
> to ensure that they are actually virus free.
> 
> Companies Act information: Registered name: Experian Limited. 
> Registered
> office: Landmark House, Experian Way, NG2 Business Park, Nottingham,
> NG80 1ZZ, United Kingdom. Place of registration: England and Wales.
> Registered number: 653331
> 
> 
> 
> 

Marek Slama
[email protected]

Reply via email to