minor fix to assignTeamToUser method: past users' groups are no longer retrieved before adding the new team

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@141693 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2017-01-21 14:58:09 +00:00
parent 7d215f23bf
commit 611b9a2c90
1 changed files with 4 additions and 17 deletions

View File

@ -532,28 +532,15 @@ public class LiferayRoleManager implements RoleManager {
@Override
public boolean assignTeamToUser(long userId, long teamId) throws UserManagementSystemException, UserRetrievalFault, TeamRetrievalFault {
try {
List<Team> currentTeams = TeamLocalServiceUtil.getUserTeams(userId);
// add is not supported in the returned list, so we need a workaround
List<Team> currentTeamsArrayList = new ArrayList<Team>(currentTeams);
Team toAdd = TeamLocalServiceUtil.getTeam(teamId);
currentTeamsArrayList.add(toAdd);
long[] teamIdstoSet = new long[currentTeamsArrayList.size()];
int i = 0;
for (Team t : currentTeamsArrayList) {
teamIdstoSet[i] = t.getTeamId();
i++;
}
return setUserTeams(userId, teamIdstoSet);
_log.debug("Adding user with id " + userId + " to team with id " + teamId);
TeamLocalServiceUtil.addUserTeam(userId, teamId);
_log.debug("User added to group");
} catch (SystemException e) {
e.printStackTrace();
} catch (PortalException e) {
throw new TeamRetrievalFault("The teamId or groupdid does not exists", e);
}
return false;
}
}