Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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


IProcessAreaWorkingCopy projWc = (IProcessAreaWorkingCopy)getService().getWorkingCopyManager().createPrivateWorkingCopy(proj);
projWc.getTeam().addContributorsSettingRoleCast(new IContributor[] {contributor}, roles);

0 votes



19 answers

Permanent link
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

0 votes


Permanent link
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.

0 votes


Permanent link
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?

0 votes


Permanent link
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

0 votes


Permanent link
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.

0 votes


Permanent link
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

0 votes


Permanent link
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!

0 votes


Permanent link
ITeamData getTeamData() is public API on IProcessArea, the supertype of IProjectArea and ITeamArea.

0 votes


Permanent link
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

0 votes


Permanent link
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;
}

0 votes

1–15 items
page 1of 1 pagesof 2 pages

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,948
× 235
× 7

Question asked: Mar 26 '10, 11:04 a.m.

Question was seen: 24,194 times

Last updated: Oct 10 '13, 11:12 a.m.

Confirmation Cancel Confirm