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

How to get the real-time roles and team information with the latest changes in RTC server?

With Plain Java API, I am trying to use the following code to query a user's role in a team and which sub-team he/she belongs to. However, once the RTC connection is setup, even his/her role was changed or add/removed from some sub-team at the RTC server side, the code still gets the old roles and team information.

How to get the real-time roles and team information with the latest changes in RTC server?

I tried to clear TeamData by calling "teamArea.getTeamData().clear()", but it does not work.

I also tried to relogin, but it still does not work. Seems once the TeamPlatform is startup (TeamPlatform.startup();), it will cache the connection information and the TeamRepositoryService.

public List<String> queryRoles(String user, String team) throws RTCException {
    IContributor contributor = getContributor(user);
    ITeamArea teamArea = getTeamArea(team);
    // query user's role
    // init RolePersistentce object
    new RolePersistence(clientProcess.getRoles(teamArea, null));
    String roleData = RolePersistence.getPersistentRoleData(teamArea.getTeamData(), contributor);
    if (roleData != null) {
        StringTokenizer tokenizer = new StringTokenizer(roleData, "|"); //$NON-NLS-1$
        while (tokenizer.hasMoreTokens()) {
            String roleId = tokenizer.nextToken();
            roles.add(roleId);
        }
    }
    if (roles.size() > 0) {
        roles.add("Default");
    }       
    // query which sub-team the user belongs to
    for (String subTeam : TEAMS) {
          ITeamArea subTeamArea = getTeamArea(subTeam);
          if (subTeamArea.hasMember(contributor)) {
                 roles.add(subTeam);
          }
    }
    return roles;
}

private ITeamArea getTeamArea(String team) throws RTCException {
    List<TeamAreaHandle> teamAreas = projectArea.getTeamAreas();
    for (TeamAreaHandle teamAreaHandle : teamAreas) {
        ITeamArea teamArea = resolveAuditable(teamAreaHandle, ItemProfile.TEAM_AREA_DEFAULT);
        if (!teamArea.isArchived() && teamArea.getName().equals(team)) {
            return teamArea;
        }
    }
    throw new RTCException(TEAM_AREA_NOT_FOUND);
}

3

0 votes


Accepted answer

Permanent link
Please find some example code here: http://rsjazz.wordpress.com/2012/12/09/analyzing-a-aroject-areas-members-and-roles-using-the-plain-java-client-libraries/
Jian Wang selected this answer as the correct answer

2 votes

Comments

And be aware of the cashing. You can use

IItemManager.REFRESH

to force refreshing

IITemManager.REFRESH works!

Thanks Ralph Schoon! You really helped me a lot.

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,938

Question asked: Dec 07 '12, 10:55 p.m.

Question was seen: 7,395 times

Last updated: Dec 09 '12, 10:12 p.m.

Confirmation Cancel Confirm