This wiki is in read-only as it is undergoing maintenance...
Extensions Wiki » Extensions » Rollback A Document

Rollback A Document

Last modified by Vincent Massol on 2013/03/11 09:36
cogShows how to programmatically rollback a document to the last but one version
TypeSnippet
Developed by

Vincent Massol

LicenseGNU Lesser General Public License 2.1

Table of contents

Description

Requires Programming Rights to execute
{{velocity}}
#set ($rollbackDoc = $xwiki.getDocument("Sandbox.WebHome"))
##-----------------------
## Find the last but one revision
##-----------------------
#set ($criteria = $xwiki.criteriaService.revisionCriteriaFactory.createRevisionCriteria())
#set ($range = $xwiki.criteriaService.rangeFactory.createTailRange(2))
$criteria.setRange($range)
$criteria.setIncludeMinorVersions(true)
#set ($revision = $rollbackDoc.getRevisions($criteria).get(0))
##-----------------------
## Perform the rollback
##-----------------------
$xwiki.getXWiki().rollback($rollbackDoc.document, $revision, $context.context)
{{/velocity}}
Tags:
Created by Vincent Massol on 2010/12/20 12:07

Download XWiki

My Recent Modifications

Get Connected