--- En date de : Ven 6.11.15, Pascal BASTIEN <pbasnews-xwiki(a)yahoo.fr> a écrit :
De: Pascal BASTIEN <pbasnews-xwiki(a)yahoo.fr>
Objet: [xwiki-users] (About XWIKI-12570:Access right doesn't work well with
subgroups) Try to remove some version from document with groovy
À: "XWiki Users" <users(a)xwiki.org>
Date: Vendredi 6 novembre 2015, 16h19
Hi,
I try without success to remove some version from document
with groovy :-(
To refresh group cache I add & remove a member in a user
group but I don't want my group be poluted by this
operation.
Here correct code with Thomas help :-)
{{groovy}}
// My group to update
def MyGroup = xwiki.getDocument('XWiki.GF_PiloteP3')
print("Current Version : " + MyGroup.getVersion()+ " \n")
// My temp user
udoc = xwiki.getDocument('XWiki.xwikilecteur')
// Add this temp user
gObj = MyGroup.newObject('XWiki.XWikiGroups')
gObj.set('member',udoc.fullName)
MyGroup.save()
// Remove this temp user
MyGroup.removeObject(gObj)
MyGroup.save()
// get document Archive
def gArch = MyGroup.getDocumentArchive()
print("Prev version: " + gArch.getPrevVersion(gArch.getLatestVersion()) + "
\n")
print("Last version: " + gArch.getLatestVersion() + " \n")
//remove 2 previous version archive
//gArch.removeVersions(gArch.getLatestVersion(),
gArch.getPrevVersion(gArch.getLatestVersion()), xcontext.context)
// must remove 3 version because last saved add one version
gArch.removeVersions(gArch.getLatestVersion(),
gArch.getPrevVersion(gArch.getPrevVersion(gArch.getLatestVersion())), xcontext.context)
MyGroup.save()
print("Current Version : " + MyGroup.getVersion()+ " \n")
{{/groovy}}