[xwiki-devs] How to grant Delete Right for all registered users via java API?
Default value of Delete right is DENY. How programmatically change it to ALLOW? Or how to give all the registered xwiki users right to delete xwiki spaces and pages? -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-grant-Delete-Right-for-all-register... Sent from the XWiki- Dev mailing list archive at Nabble.com.
Hi,
On 16 May 2016, at 14:51, abtv <[email protected]> wrote:
Default value of Delete right is DENY. How programmatically change it to ALLOW? Or how to give all the registered xwiki users right to delete xwiki spaces and pages?
See http://extensions.xwiki.org/xwiki/bin/view/Extension/Setting+Rights Thanks -Vincent
View this message in context: http://xwiki.475771.n2.nabble.com/How-to-grant-Delete-Right-for-all-register... Sent from the XWiki- Dev mailing list archive at Nabble.com.
It's unclear how to translate it into java API. Should I use DocumentAccessBridge or something else? -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-grant-Delete-Right-for-all-register... Sent from the XWiki- Dev mailing list archive at Nabble.com.
On 16 May 2016, at 15:27, abtv <[email protected]> wrote:
It's unclear how to translate it into java API. Should I use DocumentAccessBridge or something else?
Maybe this will help a bit: http://platform.xwiki.org/xwiki/bin/view/DevGuide/APIGuide which explains how to modify xobjects. Rights are xobjects. Thanks -Vincent
View this message in context: http://xwiki.475771.n2.nabble.com/How-to-grant-Delete-Right-for-all-register... Sent from the XWiki- Dev mailing list archive at Nabble.com.
Still unclear how to do it. I've found this class https://github.com/xwiki/xwiki-platform/blob/2d0bc84e2c6ca0424b55894771ac182... which has getDocument method. But it's unclear how to retrieve an instance of this class. The second problem is that getDocument method and BaseObject.set take XWikiContext instance. I'm trying to call my code on startup, so there is no context. How to do retrieve XWiki object and XWikiContext object? I call it in ApplicationReadyEventListener. -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-grant-Delete-Right-for-all-register... Sent from the XWiki- Dev mailing list archive at Nabble.com.
Maybe there is a way to execute a string with velocity code from java code? -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-grant-Delete-Right-for-all-register... Sent from the XWiki- Dev mailing list archive at Nabble.com.
Hi, You need to get an @Inject Provider<XWikiContext> contextProvider; declared in your component on which you can then do inside a method contxtProvider.get().getWiki().getDocument(...); Hope this helps, Eduard On Mon, May 16, 2016 at 6:02 PM, abtv <[email protected]> wrote:
Maybe there is a way to execute a string with velocity code from java code?
-- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-grant-Delete-Right-for-all-register... Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
<http://xwiki.475771.n2.nabble.com/file/n7599471/xwiki_problem.jpg> I have the following problem: Exception in macro #handleDocumentTreeRequest called at 13:xwiki:XWiki.DocumentTree[line 3, column 1 What rights I need to add? I set view,comment,edit,delete,script rights. I use the following code: XWikiContext context = contextProvider.get(); if (context != null) { XWiki xwiki = context.getWiki(); DocumentReference dr = new DocumentReference("xwiki", "XWiki", "XWikiPreferences"); XWikiDocument doc = xwiki.getDocument(dr, context); BaseObject bo = doc.getObject("XWiki.XWikiGlobalRights", true, context); bo.set("groups", "XWiki.XWikiAllGroup", context); bo.set("levels", "view,comment,edit,delete,script", context); bo.set("users", "", context); bo.set("allow", 1, context); xwiki.saveDocument(doc, context); } -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-grant-Delete-Right-for-all-register... Sent from the XWiki- Dev mailing list archive at Nabble.com.
I've found that order is important "view,comment,edit,script,delete" but still have problems. -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-grant-Delete-Right-for-all-register... Sent from the XWiki- Dev mailing list archive at Nabble.com.
Hi, On Tue, May 17, 2016 at 8:11 PM, abtv <[email protected]> wrote:
<http://xwiki.475771.n2.nabble.com/file/n7599471/xwiki_problem.jpg> I have the following problem: Exception in macro #handleDocumentTreeRequest called at 13:xwiki:XWiki.DocumentTree[line 3, column 1 What rights I need to add? I set view,comment,edit,delete,script rights. I use the following code:
XWikiContext context = contextProvider.get(); if (context != null) { XWiki xwiki = context.getWiki();
DocumentReference dr = new DocumentReference("xwiki", "XWiki", "XWikiPreferences"); XWikiDocument doc = xwiki.getDocument(dr, context);
BaseObject bo = doc.getObject("XWiki.XWikiGlobalRights", true, context); bo.set("groups", "XWiki.XWikiAllGroup", context); bo.set("levels", "view,comment,edit,delete,script", context); bo.set("users", "", context); bo.set("allow", 1, context);
xwiki.saveDocument(doc, context); }
Yes, this looks good. It seems you now have the answer to your initial question. I`m not sure I understand your second question and/or how is it related to the delete right. You might want to start a new thread and explain the issue better there if it`s not related. Thanks, Eduard
-- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-grant-Delete-Right-for-all-register... Sent from the XWiki- Dev mailing list archive at Nabble.com. _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Before I called the code above all trees are expandable. When I callled bo.set("levels", "view,comment,edit,delete,script",context); (script right goes /after/ delete) all macroses were unworking (can't find a macro error). Then I changed this call to bo.set("levels", "view,comment,edit,script,delete",context); (script right goes /before/ delete) and all macroses are working except this document tree - I see spinning wheel. I think it's directly related to my code above. If I comment out the code above, document tree macro works as expected but I don't have delete right by default. -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-grant-Delete-Right-for-all-register... Sent from the XWiki- Dev mailing list archive at Nabble.com.
participants (3)
-
abtv -
Eduard Moraru -
Vincent Massol