Hi Nithya, Looks like in your example you are using Apache XMLRPC directly. In the example that I provided I have used the client side proxy for Java which is much easier and less verbose than the other method. Please run this example and let me know if it works out for you... I am quite interested in finding out if it works...thanks.
> ------------------------------ > > Message: 2 > Date: Sun, 7 Mar 2010 21:33:32 +0530 > From: "Dilipkumar Jadhav" <[email protected]> > Subject: Re: [xwiki-users] Creating user using XML RPC.... > To: <[email protected]> > Message-ID: <[email protected]> > Content-Type: text/plain; charset="us-ascii" > > Hi Nithya, > As Sergiu rightly said, an XWiki user is just another document/Page with a > XWiki.XWikiUser object associated to it. > Hope the following example helps you in creating users using XMLRPC. > Please note that I have only been able to create a user. "Setting" the > password is something I did not have much luck with. > Probably, the XMLRPC API method to set the "password" property stores the > password in plain text when in fact XWiki expects passwords which are > "hashed". > I hope someone on the mailing list could help by providing the code snippet > to update password using XMLRPC. Once, that is done, we can save this > example at > http://platform.xwiki.org/xwiki/bin/view/Features/XMLRPCJavaExamples > > ======================================================================== > > > import java.net.MalformedURLException; > import org.apache.xmlrpc.XmlRpcException; > import org.codehaus.swizzle.confluence.Page; > import org.xwiki.xmlrpc.XWikiXmlRpcClient; > import org.xwiki.xmlrpc.model.XWikiObject; > > public class CreateUser { > > public static void main(String[] args) throws MalformedURLException, > XmlRpcException { > > //URL of the xwiki instance > String url = "http://localhost:8080/xwiki/xmlrpc/confluence"; > > //Replace user & pass with desired xwiki username & password > String user = "Admin"; > String pass = "admin"; > > XWikiXmlRpcClient rpc = new XWikiXmlRpcClient(url); > try { > //Perform Login & Authentication > rpc.login(user, pass); > > //Create a Page to hold the user profile & set it's three > important attributes viz. Space, Title, Content > //Set the space="XWiki" since all XWiki users go to > "XWiki" space by default > //Set title to the username of the user. In our > case, username="testuser" > //Set content to include the XWikiUserSheet. > //Without this the user Page will come up blank and > no fields will be displayed > > Page page = new Page(); > page.setSpace("XWiki"); > page.setTitle("testuser"); > page.setId("XWiki.testuser"); > page.setContent("{{include > document=\"XWiki.XWikiUserSheet\"/}}"); > rpc.storePage(page); > > //Create a XWikiObject and set the class to > XWiki.XWikiUsers > //Set the "host" Page as XWiki.testuser. This is the > page we created in the steps above > //Set the first_name & last_name properties with > values "Test" and "User" respectively > //We can access the list of all properties for a > User class at the following link: > > //http://localhost:8080/xwiki/bin/edit/XWiki/XWikiUsers?editor=class > //Finally, save the object using rpc.storeObject > > XWikiObject xobj = new XWikiObject(); > xobj.setClassName("XWiki.XWikiUsers"); > xobj.setPageId("XWiki.testuser"); > xobj.setProperty("first_name", "Test"); > xobj.setProperty("last_name", "User"); > rpc.storeObject(xobj); > > } catch (XmlRpcException e) { > System.out.println(e); > } finally { > rpc.logout(); > } > } > } > > ======================================================================== > > > Message: 1 > Date: Wed, 3 Mar 2010 09:33:05 -0800 (PST) > From: Nithya Vembu <[email protected]> > Subject: [xwiki-users] Creating user using XML RPC.... > To: [email protected] > Message-ID: <[email protected]> > Content-Type: text/plain; charset=us-ascii > > > Hi All, > > Is there any sample available to create a user through XML RPC like the > examples in the following link for creation of page, space etc.. > > http://platform.xwiki.org/xwiki/bin/view/Features/XMLRPCJavaExamples > > Please help me out if there any solution. > > Thanks, > Nithya. > -- > View this message in context: > http://n2.nabble.com/Creating-user-using-XML-RPC-tp4669004p4669004.html > Sent from the XWiki- Users mailing list archive at Nabble.com. > > > ------------------------------ > > Message: 2 > Date: Wed, 03 Mar 2010 19:23:44 +0100 > From: Sergiu Dumitriu <[email protected]> > Subject: Re: [xwiki-users] Creating user using XML RPC.... > To: XWiki Users <[email protected]> > Message-ID: <[email protected]> > Content-Type: text/plain; charset=UTF-8; format=flowed > > On 03/03/2010 06:33 PM, Nithya Vembu wrote: >> >> Hi All, >> >> Is there any sample available to create a user through XML RPC like the >> examples in the following link for creation of page, space etc.. >> >> http://platform.xwiki.org/xwiki/bin/view/Features/XMLRPCJavaExamples >> >> Please help me out if there any solution. > > A user is just like any other document+object. Just do what's usually > done for creating a new document and adding a XWiki.XWikiUsers object. > > Don't forget to add the user to the groups you want. > > -- > Sergiu Dumitriu > http://purl.org/net/sergiu/ > > > ------------------------------ > > > > ------------------------------ > > Message: 3 > Date: Mon, 8 Mar 2010 02:09:14 -0800 (PST) > From: Nithya Vembu <[email protected]> > Subject: [xwiki-users] How to add/ register a new user in xwiki > through xmlrpc?? > To: [email protected] > Message-ID: <[email protected]> > Content-Type: text/plain; charset=us-ascii > > > Hi All, > > I am struggling in the user creation part of xwiki through xml rpc. > > This is my code snippet to create a new user in xwiki.. > > String url = > "http://sso.isupport.com/xwiki/xmlrpc/confluence"; > String user = "Admin"; > String pass = "admin"; > > Confluence confObj = new Confluence(url); > confObj.login(user, pass); > > User userObj = new User(new HashMap()); > userObj.setEmail("[email protected]"); > userObj.setFullname("shimyThomas"); > userObj.setName("shimy"); > confObj.addUser(userObj, "csscorp"); > > while running this an application i am getting the following error.. in > this specific line > > confObj.addUser(userObj, "csscorp"); > > org.codehaus.swizzle.confluence.ConfluenceException: No such handler: > confluence1.addUser > at org.codehaus.swizzle.confluence.Confluence.call(Confluence.java:808) > at org.codehaus.swizzle.confluence.Confluence.call(Confluence.java:770) > at > org.codehaus.swizzle.confluence.Confluence.addUser(Confluence.java:435) > at CreateUser.main(CreateUser.java:55) > > > Can anyone suggest me how to create a user? Kindly tell me is there any > bug in the code... > > > Thanks, > Nithya. > -- > View this message in context: > http://n2.nabble.com/How-to-add-register-a-new-user-in-xwiki-through-xmlrpc-tp4694340p4694340.html > Sent from the XWiki- Users mailing list archive at Nabble.com. > > _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
