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.

I want to launch this groovy script but unfortunaly this one crash with
gArch.removeVersions("EndVersionToDel", "StartVersionToDel", context) 

I use
http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/doc/XWikiDocumentArchive.html#removeVersions%28Version,%20Version,%20com.xpn.xwiki.XWikiContext%29
but I obtain this error:
Caused by: javax.script.ScriptException: javax.script.ScriptException: 
groovy.lang.MissingMethodException: No signature of method: 
com.xpn.xwiki.doc.XWikiDocumentArchive.removeVersions() is applicable for 
argument types: (java.lang.String, java.lang.String, 
javax.script.SimpleScriptContext) values: [EndVersionToDel, StartVersionToDel, 
javax.script.SimpleScriptContext@4ee56e53]
Possible solutions: removeVersions(org.suigeneris.jrcs.rcs.Version, 
org.suigeneris.jrcs.rcs.Version, com.xpn.xwiki.XWikiContext)

If someone can help me?
NB: groovy is complicated for me (and I don't understand what is context and 
how to get it)

Thxs
Pascal B

{{groovy}}
// My group to refresh
def MyGroup = xwiki.getDocument('XWiki.GF_PiloteP3')
// My temp user
udoc = xwiki.getDocument('XWiki.xwikilecteur')
// Add this temp user
gObj = MyGroup.newObject('XWiki.XWikiGroups')
gObj.set('member',udoc.fullName)
MyGroup.save()

// Store version to delete
def StartVersionToDel = MyGroup.getVersion()
print(MyGroup.getVersion() + "' \n")

// Remove this temp user
MyGroup.removeObject(gObj)
MyGroup.save()

// Store new version to delete
def EndVersionToDel = MyGroup.getVersion()
print(MyGroup.getVersion() + " \n")

// get document Archive
def gArch = MyGroup.getDocumentArchive()

//try to remove 2 previous version archive
gArch.removeVersions("EndVersionToDel", "StartVersionToDel", context) 

print(MyGroup.getVersion()+ " \n context: " + context + " \n")

{{/groovy}}

_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to