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);
}
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);
}