Teams role API
Hi,
There is an api to set contributor roles for team. However since it is possible to have a project without a team, how can I set programmatically roles for a contributor at the project level?
Thanks in advance for your help
There is an api to set contributor roles for team. However since it is possible to have a project without a team, how can I set programmatically roles for a contributor at the project level?
Thanks in advance for your help
IProcessAreaWorkingCopy projWc = (IProcessAreaWorkingCopy)getService().getWorkingCopyManager().createPrivateWorkingCopy(proj);
projWc.getTeam().addContributorsSettingRoleCast(new IContributor[] {contributor}, roles);
19 answers
On Fri, 26 Mar 2010 15:08:01 +0000, eclipsetalk wrote:
The "IProcessAreaWorkingCopy" interfaces should not be in public API
packages. This is a defect that we will likely resolve in Foundation 3.0.
It's recently (yesterday) come to my attention that there are examples on
jazz.net encouraging people to use these interfaces, but these examples
are wrong and I'll work on getting them removed.
Can you explain why you're interested in modifying role assignments via a
Java API?
--
Jared Burns
Jazz Process Team
Hi,
There is an api to set contributor roles for team. However since it is
possible to have a project without a team, how can I set
programmatically roles for a contributor at the project level? Thanks in
advance for your help
IProcessAreaWorkingCopy projWc =
(IProcessAreaWorkingCopy)getService().getWorkingCopyManager
().createPrivateWorkingCopy(proj);
projWc.getTeam().addContributorsSettingRoleCast(new IContributor[]
{contributor}, roles);
The "IProcessAreaWorkingCopy" interfaces should not be in public API
packages. This is a defect that we will likely resolve in Foundation 3.0.
It's recently (yesterday) come to my attention that there are examples on
jazz.net encouraging people to use these interfaces, but these examples
are wrong and I'll work on getting them removed.
Can you explain why you're interested in modifying role assignments via a
Java API?
--
Jared Burns
Jazz Process Team
Can you explain why you're interested in modifying role assignments via a Java API?
For us the reason is automation. Reducing manual intervention is an important part of keeping overhead low when maintaining hundreds of users in nine project areas across three RTC instances -- and that'll very likely grow in the near future.
Once a user is approved for a project we add them to LDAP, put the user in RTC, give them a license, add them to the project area, and finally give them a role. I have all of the pieces except the team role, and I'm having a devil of a time finding a public API to do this. The only one available is the one you say isn't valid :)
Is there an alternative?
I still haven't seen any replies from the Jazz team as for directions.
I was able to get some guidance off-line, though it uses a private API. Your enhancement request is good, but I think should have higher focus IMO. There are lots of people who want to provide their own convenient sign-on sites, and this is a major gap.
Here's my code:
RolePersistence.setPersistedRoleData(teamArea.getTeamData(), contributorHandle, RolePersistence.serialize(iroleList));
IProcessItemService pis = (IProcessItemService)getClientLibrary(IProcessItemService.class);
IProcessItem[] ret = pis.save(teamArea, monitor);
teamArea = (ITeamArea)items[0].getWorkingCopy();
RolePersistence is the internal class, so is subject to change. Since that's the only private class I'm sure it wouldn't be insurmountable to provide a public abstraction.
Thanks for sharing - yes, that's what I'm using (TeamData) to set roles at the team level but for project level there is no API, nothing, nada - Roles can only be set a the team level. I haven't found any way to set project role even via private API - If anyone knows please share.
Thank you
Ah, need to brush up on good ol' reading comprehension :) Good luck with it!
ITeamData getTeamData() is public API on IProcessArea, the supertype of IProjectArea and ITeamArea.
Yes, one can get the project roles via
clientProcess.getRoles(projectArea, monitor);
But there is no way to set project roles (only at the team level).
IProcessAreaWorkingCopy projWc = projWc.getTeam().addContributorsSettingRoleCast(new IContributor[] {contributor}, roles);
Why is the API missing for project?
Thanks
some of the functions are missing getUserById,getProjectByName ...I think you can figure out how they work.......
public IRole getProjectsRoleName(IProjectArea project,String role_name) throws TeamRepositoryException{
IRole return_role = null;
IProcessItemService service = (IProcessItemService)repo.getClientLibrary(IProcessItemService.class);
IClientProcess client_service = service.getClientProcess(project,MONITOR);
IRole[] availableRoles = client_service.getRoles(project,MONITOR);
int i = 0;
for (int k = 0; k < availableRoles.length && i < 1; k++) {
String role = availableRoles.getId();
if (role.compareTo(role_name) == 0) {
return_role = availableRoles;
i++;
}
}
return return_role;
}
public String addUserToProject(String projectName, String user, String roleName) throws TeamRepositoryException{
String msg = "Added user to project " + projectName + " with Role " + roleName;
IRole[] roles = {null};
IContributor[] contributors = {null};
// Get user
try {
contributors = getUserById(user);
} catch (TeamRepositoryException e) {
return ("ERROR:");
}
// Add contributor licenses
contributors = (IContributor)contributors.getWorkingCopy();
ILicenseAdminService licenseService = (ILicenseAdminService)((TeamRepository)repo).getServiceInterface(ILicenseAdminService.class);
IContributorLicenseType license_types[] = licenseService.getLicenseTypes();
// Assign new user as a developer, test box has no floating licenses
for(IContributorLicenseType license_type : license_types){
String id = license_type.getId();
if(id.equals(FLOATING_DEVELOPER_LICENSE_STRING)) {
licenseService.assignLicense(contributors, id);
}
}
contributors = repo.contributorManager().saveContributor(contributors, MONITOR);
// Get Project
IProjectArea project = getProjectByName(projectName);
if(project == null)
throw new TeamRepositoryException("Could not find project " + projectName);
// Get user role
roles = getProjectsRoleName(project,roleName);
if (roles == null) {
throw new TeamRepositoryException("Could not find role " + roleName);
}
IProcessItemService service = (IProcessItemService)repo.getClientLibrary(IProcessItemService.class);
IWorkingCopyManager manager = service.getWorkingCopyManager();
manager.connect(project);
ProjectAreaWorkingCopy workingCopy = (ProjectAreaWorkingCopy)manager.getWorkingCopy(project);
workingCopy.addMembers(contributors);
workingCopy.save(MONITOR);
manager.disconnect(project);
return msg;
}
public IRole getProjectsRoleName(IProjectArea project,String role_name) throws TeamRepositoryException{
IRole return_role = null;
IProcessItemService service = (IProcessItemService)repo.getClientLibrary(IProcessItemService.class);
IClientProcess client_service = service.getClientProcess(project,MONITOR);
IRole[] availableRoles = client_service.getRoles(project,MONITOR);
int i = 0;
for (int k = 0; k < availableRoles.length && i < 1; k++) {
String role = availableRoles.getId();
if (role.compareTo(role_name) == 0) {
return_role = availableRoles;
i++;
}
}
return return_role;
}
public String addUserToProject(String projectName, String user, String roleName) throws TeamRepositoryException{
String msg = "Added user to project " + projectName + " with Role " + roleName;
IRole[] roles = {null};
IContributor[] contributors = {null};
// Get user
try {
contributors = getUserById(user);
} catch (TeamRepositoryException e) {
return ("ERROR:");
}
// Add contributor licenses
contributors = (IContributor)contributors.getWorkingCopy();
ILicenseAdminService licenseService = (ILicenseAdminService)((TeamRepository)repo).getServiceInterface(ILicenseAdminService.class);
IContributorLicenseType license_types[] = licenseService.getLicenseTypes();
// Assign new user as a developer, test box has no floating licenses
for(IContributorLicenseType license_type : license_types){
String id = license_type.getId();
if(id.equals(FLOATING_DEVELOPER_LICENSE_STRING)) {
licenseService.assignLicense(contributors, id);
}
}
contributors = repo.contributorManager().saveContributor(contributors, MONITOR);
// Get Project
IProjectArea project = getProjectByName(projectName);
if(project == null)
throw new TeamRepositoryException("Could not find project " + projectName);
// Get user role
roles = getProjectsRoleName(project,roleName);
if (roles == null) {
throw new TeamRepositoryException("Could not find role " + roleName);
}
IProcessItemService service = (IProcessItemService)repo.getClientLibrary(IProcessItemService.class);
IWorkingCopyManager manager = service.getWorkingCopyManager();
manager.connect(project);
ProjectAreaWorkingCopy workingCopy = (ProjectAreaWorkingCopy)manager.getWorkingCopy(project);
workingCopy.addMembers(contributors);
workingCopy.save(MONITOR);
manager.disconnect(project);
return msg;
}
page 1of 1 pagesof 2 pages