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