It's all about the answers!

Ask a question

Teams role API


EclipseTalk . (32735759) | asked Mar 26 '10, 11:04 a.m.
retagged Jan 04 '13, 7:05 a.m. by Morten Madsen (3052742)
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);

19 answers



permanent link
Jared Burns (4.5k29) | answered Mar 26 '10, 11:04 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
On Fri, 26 Mar 2010 15:08:01 +0000, eclipsetalk wrote:

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

permanent link
EclipseTalk . (32735759) | answered Mar 29 '10, 8:17 a.m.
Thanks for the reply.
I need to be able to set/get roles at the project level and/or team level via APIs for service methods.
Roles can be accessed at the team level through ITeamArea but I need something similar to access roles at the project level.
Thanks for your help.

permanent link
Sterling Bates (2311612) | answered Apr 06 '10, 1:05 a.m.
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?

permanent link
EclipseTalk . (32735759) | answered Apr 08 '10, 2:42 p.m.
I still haven't seen any replies from the Jazz team as for directions.
fyi - I've entered an enhancement:
https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWorkItem&id=111573

Thanks

permanent link
Sterling Bates (2311612) | answered Apr 10 '10, 2:56 a.m.
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.

permanent link
EclipseTalk . (32735759) | answered Apr 10 '10, 1:19 p.m.
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

permanent link
Sterling Bates (2311612) | answered Apr 10 '10, 1:27 p.m.
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!

permanent link
Nick Edgar (6.5k711) | answered Apr 12 '10, 9:39 a.m.
JAZZ DEVELOPER
ITeamData getTeamData() is public API on IProcessArea, the supertype of IProjectArea and ITeamArea.

permanent link
EclipseTalk . (32735759) | answered Apr 12 '10, 10:02 a.m.
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

permanent link
K M (38324349) | answered Apr 21 '10, 3:50 p.m.
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;
}

Your answer


Register or to post your answer.