added assignTeamUser

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@128076 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-04-14 09:40:39 +00:00
parent 8b748fe964
commit e100fd23c8
2 changed files with 33 additions and 1 deletions

View File

@ -227,6 +227,17 @@ public interface RoleManager {
* @throws TeamRetrievalFault if a system exception occurred or a team does not exists
*/
boolean setUserTeams(long userId, long[] teamIds) throws TeamRetrievalFault;
/**
* associate one team to the existing teams of user
* @param userId
* @param teamId
* @return
* @throws UserManagementSystemException
* @throws UserRetrievalFault
* @throws GroupRetrievalFault
* @throws TeamRetrievalFault
*/
boolean assignTeamToUser(long userId, long teamId) throws UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault,TeamRetrievalFault;
/**
* @return a list of {@link GCubeTeam} belonging to a give group
*/

View File

@ -474,10 +474,31 @@ public class LiferayRoleManager implements RoleManager {
try {
toReturn = mapLRTeam(TeamLocalServiceUtil.getTeam(groupId, teamName));
} catch (PortalException e) {
throw new TeamRetrievalFault("The teamId or groupdid does not exists", e);
throw new TeamRetrievalFault("The teamname or groupdid does not exists", e);
} catch (SystemException e) {
e.printStackTrace();
}
return toReturn;
}
@Override
public boolean assignTeamToUser(long userId, long teamId) throws UserManagementSystemException, UserRetrievalFault, TeamRetrievalFault {
try {
List<Team> currentTeams = TeamLocalServiceUtil.getUserTeams(userId);
Team toAdd = TeamLocalServiceUtil.getTeam(teamId);
currentTeams.add(toAdd);
long[] teamIdstoSet = new long[currentTeams.size()];
int i = 0;
for (Team t : currentTeams) {
teamIdstoSet[i] = t.getTeamId();
i++;
}
return setUserTeams(userId, teamIdstoSet);
} catch (SystemException e) {
e.printStackTrace();
} catch (PortalException e) {
throw new TeamRetrievalFault("The teamId or groupdid does not exists", e);
}
return false;
}
}