It's all about the answers!

Ask a question

Find project area/team area a certain archived user is a member of and remove that user via plain Java API

Don Yang (7.7k21109138) | asked Mar 23 '14, 9:03 p.m.
RTC v4.0.3. used.

The users deleted some users from LDAP and then archived the users in RTC via sync job.
Now they need to find out a way to automatically retrieve the project areas/team areas info the archived
user is member of and remove them from the PA/TA.

According to some posts such as:, we can print the project areas/team areas the user is a member of.
Ralph Schoon's blog has the codes for that as well:
I have two questions here:
1) Would the codes applied to archived users as well? i.e. can they use the same code to list the project areas and team areas for which the archived user is a member of?
2) if yes, is there any Java API they can use to remove those user(s) from the project area/team area?

Appreciate any inputs.

2 answers

permanent link
Susan Hanson (1.6k2201194) | answered Mar 23 '14, 9:14 p.m.
We do something similar.  Our code:
1) gets all users in the repository and pulls out those that are archived (using contributor.isArchived()).
2) gets all of the team areas and for each team area, gets the members (teamArea.getMembers()).
3) goes through the members to see if the member is in the list of archivedUsers.

We don't programmatically remove them but on the teamArea object, there is a removeMember(iContributorHandle) method that you should be able to use.


Don Yang commented Mar 24 '14, 1:48 a.m.

Thanks Susan for the prompt info.
Do you mean that you have to manually go through the members that see if archived users are there? That is not the intention as the user wants the automation in
using Java API to find out the project area and team area list the archived users are member of. The codes from Ralph provided in the blog looks the one to do the job:

IContributor user = teamRepository.loggedInContributor();
    // If having an ID for the user as string
    //IContributor user = teamRepository.contributorManager().fetchContributorByUserId(user)
    IProcessItemService processItemService = (IProcessItemService) teamRepository

List processAreasOfUser= processItemService.findProcessAreas(user, null, IProcessClientService.ALL_PROPERTIES , monitor);

but I am not sure if it will work for archived user or not.
I checked IContributorHandle but could not find removeMember(in v405 API doc).
I dont know whether I can use removeLoginParticipant(ITeamRepository.ILoginParticipant participant)
to remove the archived users in this case.

Susan Hanson commented Mar 24 '14, 2:40 a.m.

So, a Contributor (to my knowledge) does not know what teams they are on.  A team knows what members it has and what role each member has on that team.

So you would to start at the team and get its members and loop through the members.  Each member (Contributor) has the isArchived() flag, so you would then have to check that.  I don't believe there is a getArchivedMembers() method .. only a getMembers() method on a team.

removeMember(IContributorHandle) is a method on the ITeamArea.  As I mentioned, the team knows it's members, but a member does not know its' teams.  So it would be something like this:
for each teamArea {
   for each Member {
      member.isArchived()?  If yes, then teamArea.removeMember(memberHandle);

Don Yang commented Mar 24 '14, 6:37 a.m.

The logic sounds good. How about if it is project area's member but not in a team area?

" a Contributor (to my knowledge) does not know what teams they are on. " : from the code "Only Analyze the Process Areas of One User " (below Rapha's blog)

 it seems that it is possible to get a PA/TA list for a user, though I am asking if that includes the archived users or not.

Susan Hanson commented Mar 24 '14, 6:49 a.m.

I have a report that looks like this (Name, Team name, Role on that team .. delimited by |):
John Doe|Service Release Team|Builder
John Doe|Service Team|Builder,Team Member
John Doe|Raleigh Team|Team Member
John Doe|Development|Iteration Closer,Builder,Team Member

As you can see, John is a member of 4 different teams, and has different roles on the different teams.  It could also print out if that person is archived or not quite easily).

So take each process area (which can be the project area or a team area) and get the members, then process each member on that team to get their role(s) of that person on that team.

So yes, I can get a PA/TA list for a user, but I have to do it from the process area, not from the user.  So I can't say "user, tell me what team's you are on".  You have to as the project area/team area "tell me your members".


Don Yang commented Mar 24 '14, 6:29 p.m.

Thank you very much Susan for the further details.

permanent link
Ralph Schoon (63.1k33646) | answered Mar 24 '14, 3:18 a.m.
edited Mar 24 '14, 3:19 a.m.
I think you should find most of the code here: go to Only Analyze the Process Areas of One User as a starter. 

Don Yang commented Mar 24 '14, 6:32 a.m.

Hi, Ralph

Thank you very much and yes I am referring to the codes in your blog. Can you please advise whether the code applies to the archived users or not.

And if we want to remove the archived users from the project area/team area, what is the method to achieve that? Would removeLoginParticipant(ITeamRepository.ILoginParticipant participant)  do the job?



sam detweiler commented Mar 24 '14, 6:40 a.m.


from the javadoc.

removeMember(IContributorHandle contributorHandle)
          Removes the contributor represented by the given handle from the set of contributors constituting the members of this process area.

Archived is just an attribute on some of the objects. it doesn't affect the rest of the operations.
Project/Teamarea are decended from IProcessArea

Ralph Schoon commented Mar 24 '14, 6:49 a.m.

In this API it is always important to understand the context of what to do and where.
You want to remove a user from a project area (and potentially from a team area as well). IProcessArea is the common interface for ProjectAreas and TeamAreas.

With content assist in my code you see that there are several methods to remove users etc. like Sam points out above. That would be my approach to try too.

Ralph Schoon commented Mar 24 '14, 6:53 a.m. | edited Mar 24 '14, 6:53 a.m.

Archived users: As far as I can tell, an archived user is like any other user. It is only no longer active and has no licenses. However, an archived user might still be member of project areas - I did never play with this. The Archived User has an IContributorHandle and an IContributor object as any other user. So all operations should still apply.

Don Yang commented Mar 24 '14, 6:29 p.m.

Thanks a lot to Ralph and Sam for the explanation and detailed method.

Your answer

Register or 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.