Purge Document Versions via Script

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Purge Document Versions via Script

Tronicek
Is there a way to purge document revisions using Velocity or Groovy?

Someone can see actual and last revision by:
${doc.getVersion()}<br>
${doc.getPreviousDocument().getVersion()}<br>

The next is deleting the document with all revisions...
Don't try to purge with(!):
${doc.getPreviousDocument().delete()}

Thanks,
Rudolf
Reply | Threaded
Open this post in threaded view
|

Re: Purge Document Versions via Script

KevinC
I'm guessing you could use something like:

http://code.xwiki.org/xwiki/bin/view/Snippets/DeleteSpaceSnippet

to build a listing of the files versions and then create links or checkboxes or something like that to delete the ones you are interested in.

You can get the full list of versions using $doc.getRevisions() which returns a org.suigeneris.jrcs.rcs.Version[]. You could then iterate through that list and delete all versions but the last.


HTH,
.:. Kevin
Reply | Threaded
Open this post in threaded view
|

Re: Purge Document Versions via Script

Jerome Velociter
In reply to this post by Tronicek
If what you want to do is remove all old revisions from a document but
keep the current one, you can use the following :

$doc.document.resetArchive($context.context);

It's not a public API, so you will need to save the page with a users
who has the programming right granted

Hopes it helps,
Jerome

Tronicek wrote:

> Is there a way to purge document revisions using Velocity or Groovy?
>
> Someone can see actual and last revision by:
> ${doc.getVersion()}<br>
> ${doc.getPreviousDocument().getVersion()}<br>
>
> The next is deleting the document with all revisions...
> Don't try to purge with(!):
> ${doc.getPreviousDocument().delete()}
>
> Thanks,
> Rudolf

_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Purge Document Versions via Script

Sergiu Dumitriu-2
In reply to this post by Tronicek
Tronicek wrote:
> Is there a way to purge document revisions using Velocity or Groovy?
>
> Someone can see actual and last revision by:
> ${doc.getVersion()}<br>
> ${doc.getPreviousDocument().getVersion()}<br>
>
> The next is deleting the document with all revisions...
> Don't try to purge with(!):
> ${doc.getPreviousDocument().delete()}

There's:

$xwiki.getDocument('Some.Document').getDocument().resetArchive($context.context)

But this requires programming rights.

--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users