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); } |
Accepted answer
Ralph Schoon (63.4k●3●36●46)
| answered Dec 09 '12, 6:13 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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
Comments And be aware of the cashing. You can use
IItemManager.REFRESH to force refreshing
Jian Wang
commented Dec 09 '12, 10:12 p.m.
IITemManager.REFRESH works! Thanks Ralph Schoon! You really helped me a lot. |
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.