You can add roles as follows.
You need to use the following services in your webscript class.
AuthorityService
PermissionService
PersonService
String lStrSpaceUserName = request.getParameter("spaceUserName");
String lStrSpaceNodeRef = request.getParameter("spaceNodeRef");
String userName = getAuthorityService().getName(AuthorityType.USER, lStrSpaceUserName);
if(personService.personExists(userName)){
nodeRefOfPermissiveSpace = new NodeRef(Repository.getStoreRef(),lStrSpaceNodeRef);
Set set = getPermissionService().getPermissions(nodeRefOfPermissiveSpace);
Iterator iter = set.iterator();
while(iter.hasNext()){
System.out.println("******PErmissions*****:"+iter.next());
}
getPermissionService().setInheritParentPermissions(nodeRefOfPermissiveSpace, true);
getPermissionService().setPermission(nodeRefOfPermissiveSpace,userName ,PermissionService.COORDINATOR, true);
}
/*in this way, I gave the Coordinator role to the userName*/
I hope this helps.
Thanks,
Sanket.