added other methods for managing teams

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@128064 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-04-13 16:00:19 +00:00
parent e6657b5859
commit 3b30e72ee2
5 changed files with 157 additions and 41 deletions

View File

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="usermanagement-core">
<wb-resource deploy-path="/" source-path="/src/main/java"/>
<wb-resource deploy-path="/" source-path="/src/test/java"/>
<wb-resource deploy-path="/" source-path="/src/test/resources"/>
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
</wb-module>
</project-modules>

View File

@ -60,32 +60,6 @@ public interface RoleManager {
* @throws UserManagementSystemException
*/
boolean createRole(String roleName, String roleDescription) throws UserManagementSystemException;
/**
* The notion of a Team is somewhat similar to a Role but a Role is a portal wide entity, (Role exists in any Site)
* while a Team is restricted to a particular Site.
*
* @param groupId the site group id where the team exists
* @param teamName the name you want to assign to this team
* @param teamDescription
* @return the GCubeTeam if the team is created succesfully, null otherwise
* @throws UserManagementSystemException
*/
GCubeTeam createTeam(long groupId, String teamName, String teamDescription) throws GroupRetrievalFault, TeamRetrievalFault, UserManagementSystemException;
/**
* @param groupId the site group id where the team exists
* @param teamId the LR team Id
* @return the team instance that was removed
* @throws UserManagementSystemException
* @throws RoleRetrievalFault
*/
GCubeTeam deleteTeam(long teamId) throws UserManagementSystemException, TeamRetrievalFault ;
/**
*
* @param groupId the LR GroupId of the Site
* @return true if the teams are deleted succesfully, false otherwise
* @throws UserManagementSystemException
*/
boolean deleteTeams(long groupId) throws UserManagementSystemException;
/**
*
* @param roleId
@ -128,14 +102,7 @@ public interface RoleManager {
* @throws RoleRetrievalFault
*/
GCubeRole getRole(long roleId) throws UserManagementSystemException, RoleRetrievalFault;
/**
*
* @param teamId
* @return the GCubeTeam istance
* @throws UserManagementSystemException
* @throws RoleRetrievalFault
*/
GCubeTeam getTeam(long teamId) throws UserManagementSystemException, TeamRetrievalFault;
/**
* @param roleName
* @param groupId the LR groupId
@ -163,10 +130,6 @@ public interface RoleManager {
* @return a list of {@link GcubeRole} independent from the roleType
*/
List<GCubeRole> listAllRoles();
/**
* @return a list of {@link GCubeTeam} belonging to a give group
*/
List<GCubeTeam> listTeamsByGroup(long groupId);
/**
* @return a list of {@link GcubeRole} of type Site Role (Type=2)
*/
@ -179,6 +142,76 @@ public interface RoleManager {
* @throws UserRetrievalFault
*/
List<GCubeRole> listRolesByUserAndGroup(long userId, long groupId) throws GroupRetrievalFault,UserRetrievalFault;
/*******************************
*
* TEAM MANAGEMENTS PART
*
* The notion of a Team is somewhat similar to a Role but a Role is a portal wide entity, (Role exists in any Site)
* while a Team is restricted to a particular Site.
*
* */
/**
* @param groupId the site group id where the team exists
* @param teamName the name you want to assign to this team
* @param teamDescription
* @return the GCubeTeam if the team is created succesfully, null otherwise
* @throws UserManagementSystemException
*/
GCubeTeam createTeam(long groupId, String teamName, String teamDescription) throws GroupRetrievalFault, TeamRetrievalFault, UserManagementSystemException;
/**
*
* @param groupId
* @param teamName
* @return
* @throws GroupRetrievalFault
* @throws TeamRetrievalFault
*/
GCubeTeam getTeam(long groupId, String teamName) throws GroupRetrievalFault, TeamRetrievalFault;
/**
*
* @param teamId
* @return the GCubeTeam istance
* @throws UserManagementSystemException
* @throws RoleRetrievalFault
*/
GCubeTeam getTeam(long teamId) throws UserManagementSystemException, TeamRetrievalFault;
/**
* @param groupId the site group id where the team exists
* @param teamId the LR team Id
* @return the team instance that was removed
* @throws UserManagementSystemException
* @throws RoleRetrievalFault
*/
GCubeTeam deleteTeam(long teamId) throws UserManagementSystemException, TeamRetrievalFault ;
/**
*
* @param groupId the LR GroupId of the Site
* @return true if the teams are deleted succesfully, false otherwise
* @throws UserManagementSystemException
*/
boolean deleteTeams(long groupId) throws UserManagementSystemException;
/**
* delete a user from a list of teams
* @param userId
* @param teamIds
* @return
* @throws UserRetrievalFault
* @throws TeamRetrievalFault
*/
boolean deleteUserTeams(long userId, long[] teamIds);
/**
* delete a user from a list of teams
* @param userId
* @param teams
* @return
* @throws UserRetrievalFault
* @throws TeamRetrievalFault
*/
boolean deleteUserTeams(long userId, List<GCubeTeam> teams);
/**
* @param roleId
* @param roleName
@ -193,5 +226,9 @@ public interface RoleManager {
* @return
* @throws TeamRetrievalFault if a system exception occurred or a team does not exists
*/
boolean setUserTeams(long userId, long[] teamIds) throws TeamRetrievalFault;
boolean setUserTeams(long userId, long[] teamIds) throws TeamRetrievalFault;
/**
* @return a list of {@link GCubeTeam} belonging to a give group
*/
List<GCubeTeam> listTeamsByGroup(long groupId);
}

View File

@ -5,6 +5,7 @@ import java.util.Map;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.RoleRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.TeamRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
@ -221,6 +222,15 @@ public interface UserManager {
* @throws UserRetrievalFault
*/
List<GCubeUser> listUsersByGroupAndRole(long groupId, long roleId) throws UserManagementSystemException, RoleRetrievalFault, GroupRetrievalFault, UserRetrievalFault;
/**
*
* @parmam teamId the LR teamId
* @return the list of {@link GCubeUser} having teamId that matches
* @throws TeamRetrievalFault
* @throws UserManagementSystemException
* @throws UserRetrievalFault
*/
List<GCubeUser> listUsersByTeam(long teamId) throws UserManagementSystemException, TeamRetrievalFault, UserRetrievalFault;
/**
* this method assigns the user to the Group and perform other necessary actions (such as adding him to the HL Folder)
* @param groupId LR groupId

View File

@ -433,4 +433,51 @@ public class LiferayRoleManager implements RoleManager {
}
return true;
}
/**
* {@inheritDoc}
*/
@Override
public boolean deleteUserTeams(long userId, long[] teamIds) {
try {
TeamLocalServiceUtil.deleteUserTeams(userId, teamIds);
} catch (SystemException e) {
e.printStackTrace();
return false;
}
return true;
}
/**
* {@inheritDoc}
*/
@Override
public boolean deleteUserTeams(long userId, List<GCubeTeam> teams) {
long[] teamIds = new long[teams.size()];
int i = 0;
for (GCubeTeam r : teams) {
teamIds[i] = r.getTeamId();
i++;
}
try {
TeamLocalServiceUtil.deleteUserTeams(userId, teamIds);
} catch (SystemException e) {
e.printStackTrace();
return false;
}
return true;
}
/**
* {@inheritDoc}
*/
@Override
public GCubeTeam getTeam(long groupId, String teamName) throws GroupRetrievalFault, TeamRetrievalFault {
GCubeTeam toReturn = null;
try {
toReturn = mapLRTeam(TeamLocalServiceUtil.getTeam(groupId, teamName));
} catch (PortalException e) {
throw new TeamRetrievalFault("The teamId or groupdid does not exists", e);
} catch (SystemException e) {
e.printStackTrace();
}
return toReturn;
}
}

View File

@ -10,6 +10,7 @@ import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.RoleRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.TeamRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
@ -31,6 +32,7 @@ import com.liferay.portal.model.Group;
import com.liferay.portal.model.MembershipRequest;
import com.liferay.portal.model.Role;
import com.liferay.portal.model.RoleConstants;
import com.liferay.portal.model.Team;
import com.liferay.portal.model.User;
import com.liferay.portal.security.auth.PrincipalThreadLocal;
import com.liferay.portal.security.permission.PermissionChecker;
@ -42,6 +44,7 @@ import com.liferay.portal.service.MembershipRequestLocalServiceUtil;
import com.liferay.portal.service.RoleLocalServiceUtil;
import com.liferay.portal.service.RoleServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.TeamLocalServiceUtil;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.util.PortalUtil;
import com.liferay.portal.webserver.WebServerServletTokenUtil;
@ -523,6 +526,27 @@ public class LiferayUserManager implements UserManager {
}
return toReturn;
}
/**
* {@inheritDoc}
*/
@Override
public List<GCubeUser> listUsersByTeam(long teamId) throws UserManagementSystemException, TeamRetrievalFault, UserRetrievalFault {
List<GCubeUser> toReturn = new ArrayList<GCubeUser>();
Team askedTeam = null;
try {
askedTeam = TeamLocalServiceUtil.getTeam(teamId);
_log.debug("Asked for users of team: "+askedTeam.getName());
List<User> users = UserLocalServiceUtil.getTeamUsers(teamId);
for (User user : users) {
toReturn.add(mapLRUser(user));
}
} catch (PortalException e) {
throw new TeamRetrievalFault("Team not existing (I think you better check) teamId="+teamId, e);
} catch (SystemException e) {
e.printStackTrace();
}
return toReturn;
}
/*
* END LISTING ENTITIES
*/