How to create group and add users to group using WebService?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 06:22 AM
I am new Alfresco.I am using Web Service(WS) api for my development. Using WS api I can create space, create a user, upload file, create file and assign role to the user. But i could not able to find out any methods to create Group and add users to groups. If you have snippet of code, please share which helps to me understand very quickly.its very urgent .
Regards,
Madhu
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 06:49 AM
But these methods are available as Web Scripts in 3.2.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 10:41 AM
Regards,
Madhu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2009 09:28 AM
Try the following webscript. It should help you to add users to the group
var groupPrefix="GROUP_";var srcGrpNode=people.getGroup(groupPrefix+srcGrp);var authority = people.getPerson(user);if(authority){ people.addAuthority(srcGrpNode,authority);}
Have a look into people API section you can also find method to create the group.
http://wiki.alfresco.com/wiki/JavaScript_API_For_Alfresco_2.1#People_API
Thanks
Kayan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2009 11:11 AM
And there's also two sets of webscripts on
/api/groups
/api/rootgroups
And there is a java script "groups" object.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2009 08:39 AM
… public static final String ADMIN_USERNAME = "admin"; public static final String ADMIN_PASSWORD = "admin"; public static final String GROUP_AUTHORITY_TYPE = "GROUP"; public static final String CP01_USERNAME = "cp01"; protected static final String CONTENT_PROVIDER_GROUPNAME = "RBT_CONTENT_PROVIDER"; public static void main(String[] args) throws Exception { // Start the session AuthenticationUtils.startSession(ADMIN_USERNAME, ADMIN_PASSWORD); try { createGroups(); //createUsers(); addUsersToGroup(); } finally { // End the session AuthenticationUtils.endSession(); } } private static void createGroups() throws AccessControlFault, RemoteException { AccessControlServiceSoapBindingStub accessControlService = WebServiceFactory.getAccessControlService(); NewAuthority cpGrpAuth = new NewAuthority(GROUP_AUTHORITY_TYPE, CONTENT_PROVIDER_GROUPNAME); NewAuthority[] newAuthorities = {cpGrpAuth}; String result[] = accessControlService.createAuthorities(null, newAuthorities); } private static void addUsersToGroup() throws AccessControlFault, RemoteException { String[] cpUsers = {CP01_USERNAME}; String parentAuthority = GROUP_AUTHORITY_TYPE + "_" + CONTENT_PROVIDER_GROUPNAME; AccessControlServiceSoapBindingStub accessControlService = WebServiceFactory.getAccessControlService(); String[] result = accessControlService.addChildAuthorities(parentAuthority, cpUsers); } …

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2009 04:11 AM
i have a project and i must use Alfresco for a gestion of documental.
I use java for interface Alfresco with my project.
Now i have create a method for create authority and teh the result is ok, i have use your code for add user to group and create a new group.
I need a code for create user and delete group.
For the second i used this code:
public static boolean deleteGroups(String groupname) { boolean control=true; try{ String[] delgroup = {groupname}; /* String parentAuthority = GROUP_AUTHORITY_TYPE + "_" + groupname; AccessControlServiceSoapBindingStub accessControlService = WebServiceFactory.getAccessControlService(); NewAuthority cpGrpAuth = new NewAuthority(GROUP_AUTHORITY_TYPE,groupname); NewAuthority[] newAuthorities = {cpGrpAuth}; accessControlService.deleteAuthorities(delgroup);*/ }
but a group doesn't delete.For the first i have search a code and try to write but no result.
Please help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2009 07:33 AM
Now I must delete a group….How?
Help! :cry:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2009 01:38 PM
Once you've obtained it, then you can use the NodeService.deleteNode(NodeRef nodeRef).
Remember, this is a cascading delete as explained in the JavaDoc, so make sure that you want all child nodes to be deleted before invoking this call.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2009 07:08 AM
Can you please let me know how to assign a role to a user.I am able to create a user in alfresco but struggling with assigning him a role :cry: .Here is the source for the same:
private AuthenticationService authenticationService; private PersonService personService; ManageTaxonomyHelper helper; public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException { String userName = req.getParameter("userName"); String firstName = req.getParameter("firstName"); String lastName = req.getParameter("lastName"); String password = req.getParameter("password"); String emailId = req.getParameter("emailId"); helper = new ManageTaxonomyHelper(); this.authenticationService = helper.getAuthenticationService(); this.personService = helper.getPersonService(); if (this.authenticationService.authenticationExists(userName) == false) { this.authenticationService.createAuthentication(userName, password.toCharArray()); PropertyMap propMap = new PropertyMap(3); propMap.put(ContentModel.PROP_USERNAME, userName); propMap.put(ContentModel.PROP_FIRSTNAME, firstName); propMap.put(ContentModel.PROP_LASTNAME, lastName); propMap.put(ContentModel.PROP_EMAIL, emailId); this.personService.createPerson(propMap);//Creating a new user here. }else{ System.out.println("User already exists"); }
Thanks in advance.
