I am trying to write a script that will bulk update about 300 users in my XWiki instance; I need to change the username and email address of all of these users.
I was able to figure out how to update the email address on the users profile and rename their profile page which does change their username. However, all the links for pages they have authored are commented on are not updated to the new profile page, and the user no long shows up in the User Index.
When renaming the page manually in XWiki I was able to figure out that the “Update Links” feature seems to fix this link issue. Is there a way to run that via script when renaming a page?
{{groovy}}
def users = [
["CURRENT_Username","NEW_Username", "NEW_EmailAddress"]
]
for(user in users){
fullName = user.get(0)
newName = user.get(1)
udoc = xwiki.getDocument("XWiki."+fullName)
uobj = udoc.getObject("XWiki.XWikiUsers", true)
uobj.set("email" , user.get(2))
print("* Updating Email of *" + udoc.fullName + "*to *" + user.get(2) +"*\n")
udoc.save()
udoc = xwiki.getDocument("XWiki."+fullName).rename("XWiki."+newName).links
}
{{/groovy}}
1 post - 1 participant