I figured out what was the issue It needs to be Document doc=xwikiApi.getDocument("MySpace. WebPreferences");* instead of* Document doc=xwikiApi.getDocument("MySpace.WebHome"); After this worked perfectly for assigning the rights to single. But in my scneario i need to assign different rights to different users.Like i need to assign all possible rights to admin user but only view rights to general user. For this i have below code snippet doc=xwikiApi.getDocument("MySpace.WebPreferences"); com.xpn.xwiki.api.Object rightsObject=doc.getObject("XWiki.XWikiGlobalRights", true);//XWiki.XWikiRightsXWiki.XWikiGlobalRights rightsObject.set("users", "XWiki.MySpaceAdminUser"); rightsObject.set("levels", "view,comment,edit,delete,admin"); rightsObject.set("allow", "1"); doc.save();//line1 // Till here i see on UI all rights are assigned to MySpaceAdminUser Document doc1=xwikiApi.getDocument("MySpace.WebPreferences"); com.xpn.xwiki.api.Object rightsObject1=doc1.getObject("XWiki.XWikiGlobalRights", true);//XWiki.XWikiRightsXWiki.XWikiGlobalRights rightsObject1.set("users", "XWiki.XWiki.MySpaceGeneralUser"); rightsObject1.set("levels", "view"); rightsObject1.set("allow", "1"); doc1.save();//line2 // But here i see on UI all rights are revoked from MySpaceAdminUser and view right is assigned to MySpaceGeneralUser. Not sure why line 2 is revoking the rights given at line 1 ---------- Forwarded message ---------- From: mohit gupta <[email protected]> Date: Sun, Apr 8, 2012 at 7:34 PM Subject: Fwd: [xwiki-users] Looking for these xwiki java API'S or java class containing these functionality? To: XWiki Users <[email protected]> I tried using thbelow lines also com.xpn.xwiki.api.Object rightsObject=doc.getObject("XWiki.XWikiRights", true); instead of com.xpn.xwiki.api.Object rightsObject=doc.getObject("XWiki.XWikiGlobalRights", true);[Though i want to use XWiki.XWikiGlobalRights as i want to set the rights at space level instead of page level] Also i tried rightsObject.set("levels", "view,comment,edit,delete,admin"); instead of rightsObject.set("levels", "admin"); But still i do not see any rights assigned to mu user. ---------- Forwarded message ---------- From: mohit gupta <[email protected]> Date: Sun, Apr 8, 2012 at 5:41 PM Subject: Re: [xwiki-users] Looking for these xwiki java API'S or java class containing these functionality? To: XWiki Users <[email protected]> Hi Recardo, After implementation i successfully created the space *but could not assgin the assign the rights successfully(point 2 in below mail trail)*. Here is the code snippet that created the space and assign the rights to user (MySpaceUser) on this created space. I am trying to give admin rights to user MySpaceUser on space MySpace but when i go space preferences of MySpace, i do not see admin right checkbox as checked. Not sure am i missing something here? *com.xpn.xwiki.api.XWiki xwikiApi= new com.xpn.xwiki.api.XWiki(context.getWiki(),context); Document doc=xwikiApi.getDocument("MySpace.WebHome"); doc.setContent("Created the space programmatically"); doc.save(); com.xpn.xwiki.api.Object rightsObject=doc.getObject("XWiki.XWikiGlobalRights", true); rightsObject.set("users", "XWiki.MySpaceUser"); rightsObject.set("levels", "admin"); rightsObject.set("allow", 1); doc.save(); * On Sat, Apr 7, 2012 at 3:29 AM, <[email protected]
wrote:
Hi!
________________________________________ From: [email protected] [[email protected]] On Behalf Of mohit gupta [[email protected]] Sent: 06 April 2012 19:42 To: XWiki Users Subject: [xwiki-users] Looking for these xwiki java API'S or java class containing these functionality?
The first thing I would like to understand someday is what does API apply to! I mean, has XWiki a single API? Or has it a lot of them? Perhaps it is only a matter of taste, but I do really like to know how to correctly use this concept.
Can Method and API be indistinctly used?
Hi Folks,
I am looking for three xwiki java api's that do the following functionality 1) I give the space name to api and it creates the space with default home page .
Perhaps this could be useful:
{{velocity}} #set ($mydoc = $xwiki.getDocument("Dummy.WebHome")) $mydoc.setContent("content") $mydoc.save() {{/velocity}}
2)I give userName,SpaceName and rightsName(like view,edit,delete,admin) to api and it gives these rights on given space name for the given username
Does this page through any light to your doubt?
http://extensions.xwiki.org/xwiki/bin/view/Extension/Setting+Rights
3)I give spaceName to api and it gives me whether the given space exists or not?
I don't know how XWiki checks if a space exists when entered in an URL, but perhaps this could help...
$xwiki.getSpaceDocsName('YourSpaceHere).size()
If size > 0 does mean that YourSpace exists!
I was looking for three apis in classes ---com.xpn.xwiki.xwiki.java and com.xpn.xwiki.api.xwiki.java but i could not locate these. But i am sure these api's must be existing (as user is able to do these stuff from user interface). I will be grateful if i can be directed to these apis?
Thanks in advance.
HTH!
Ricardo
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Nota: A informaci?n contida nesta mensaxe e os seus posibles documentos adxuntos ? privada e confidencial e est? dirixida ?nicamente ? seu destinatario/a. Se vostede non ? o/a destinatario/a orixinal desta mensaxe, por favor elim?nea. A distribuci?n ou copia desta mensaxe non est? autorizada.
Nota: La informaci?n contenida en este mensaje y sus posibles documentos adjuntos es privada y confidencial y est? dirigida ?nicamente a su destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, por favor elim?nelo. La distribuci?n o copia de este mensaje no est? autorizada.
See more languages: http://www.sergas.es/aviso_confidencialidad.htm _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users