0

i try to create a new group, but i cant set permissions

my code is

    private static void createNewGroup() throws MalformedURLException, XmlRpcException { 

    XWikiXmlRpcClient rpc = new XWikiXmlRpcClient("http://localhost:8080/xwiki/xmlrpc/confluence"); 
    try { 

        rpc.login("Admin", "admin"); 

        // this create the group but without permissions 
        Page page = new Page();
        page.setSpace("XWiki");
        page.setParentId("XWiki.XWikiGroups");
        page.setTitle("XWikiUsersGroups");
        page.setId("XWiki.XWikiUsersGroup");
        page.setContent("{{include document=\"XWiki.XWikiGroupSheet\"/}}");
        rpc.storePage(page);

        //no puedo setearle permisos
        XWikiObject xobjgrp = new XWikiObject();
        xobjgrp.setClassName("XWiki.XWikiGroups");
        xobjgrp.setPageId("XWiki.XWikiUsersGroup");
        xobjgrp.setId(-1);
        xobjgrp.setProperty("levels", "View"); // this not work
        xobjgrp.setProperty("allow", true); //not work, too
        rpc.storeObject(xobjgrp);

    } catch (XmlRpcException e) { 
        System.out.println("invalid username/password was specified or communication problem or "); 
        System.out.println(e); 
    } finally { 
        rpc.logout(); 
    } 
    } 

I try to do it the same way that a user is created but I can not assign permissions.

http://platform.xwiki.org/xwiki/bin/view/Features/XMLRPCJavaExamples#HUser:CreateANewUser

Help!!

u.tuvoz
  • 1
  • 1
  • http://platform.xwiki.org/xwiki/bin/view/Features/XMLRPCJavaExamples#HUser:CreateANewUser is not assigning any permission, it just add the created user to the XWikiAllGroup group. – Thomas Mortagne Mar 03 '12 at 10:46

1 Answers1

0

Groups and rights are two separated things stored in separated objects. The levels and allow properties are set in a XWiki.XWikiRights (document related rights) or a XWiki.XWikiGlobalRights (space and wiki related rights).

You can look at http://extensions.xwiki.org/xwiki/bin/view/Extension/Setting+Rights for an example, it's a velocity script but it's the same logic.

Thomas Mortagne
  • 397
  • 1
  • 7