Programatically add members to an RTC Access Group
Accepted answer
public IContributor getUserById(String id) throws TeamRepositoryException{
return repo.contributorManager().fetchContributorByUserId(id, MONITOR);
}
IContributor[] contributors = {null};
IAccessGroupClientService service = (IAccessGroupClientService) repo.getClientLibrary(IAccessGroupClientService.class);
// Get user
try {
contributors[0] = getUserById(user);
} catch (TeamRepositoryException e) {
return ("ERROR:");
}
IAccessGroup groups[] = service.getAccessGroups(accessGroup, MONITOR);
if (groups.length == 0) {
throw new TeamRepositoryException("Could not find accessGroup " + accessGroup);
}
// Remove user to access group
IAccessGroup workGroup = (IAccessGroup) groups[0].getWorkingCopy();
workGroup.add(contributors[0]);
// to remove workGroup.remove(contributors[0]);
service.save(workGroup,MONITOR);
return repo.contributorManager().fetchContributorByUserId(id, MONITOR);
}
IContributor[] contributors = {null};
IAccessGroupClientService service = (IAccessGroupClientService) repo.getClientLibrary(IAccessGroupClientService.class);
// Get user
try {
contributors[0] = getUserById(user);
} catch (TeamRepositoryException e) {
return ("ERROR:");
}
IAccessGroup groups[] = service.getAccessGroups(accessGroup, MONITOR);
if (groups.length == 0) {
throw new TeamRepositoryException("Could not find accessGroup " + accessGroup);
}
// Remove user to access group
IAccessGroup workGroup = (IAccessGroup) groups[0].getWorkingCopy();
workGroup.add(contributors[0]);
// to remove workGroup.remove(contributors[0]);
service.save(workGroup,MONITOR);
Comments
Neal McKegney
Apr 04 '13, 12:42 p.m.