Hello,
I am trying to to create a job triggered by certain document created events that would create a number of groups and set access right on those groups for the document and its children.
I was basing the logic on some publicly available script snippets, but I am doing it in Java.
I am doing something like the following:
XWikiDocument webPreferences = xcontext.getWiki().getDocument(webPreferencesReference, xcontext);
webPreferences.setAuthorReference(xcontext.getUserReference());
webPreferences.setCreatorReference(xcontext.getAuthorReference());
BaseClass rightsClass = xcontext.getWiki().getGlobalRightsClass(xcontext);
BaseObject rightsObject = webPreferences.newXObject(rightsClass.getReference(), xcontext);
String adminRights = "admin,script";
rightsObject.setStringValue("levels", adminRights);
rightsObject.setStringValue("groups", newGroupDocRef.toString().split(":")[1]);
rightsObject.setStringValue("users", "");
rightsObject.setIntValue("allow", 1);
xcontext.getWiki().saveDocument(webPreferences, "Setting rights", xcontext);
In the above code newGroupDocRef
is a reference to the group document I crated and saved.
When I check the created WebPreferences document with the GUI using the objects editor I have the following warning:
If I then edit the object using the GUI editor and save, the deprecation warnings are gone. If I export the page as a XAR before and after the edit I see no significant change in the WebPreferences xml.
When I go to the root page (for which I am trying to set the access rights) and go to Administer page > Rights: Page & Children
I can see the group in fact has the correct access right despite the deprecation warnings.
What can I do to fix the deprecation warning?
Also, once I click Administer page
my WebPreferences page is replaced by a Page Administration page, why is that? Should I rather create a Page Administration page right away in my job instead of a simple WebPreferences?
Thank you for your help.
Kind regads,
Akos