added RemoceAllRolesFromuser method

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@126046 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-03-22 14:30:24 +00:00
parent dfa3fdfad8
commit 0ae9bd353b
2 changed files with 29 additions and 2 deletions

View File

@ -74,6 +74,17 @@ public interface RoleManager {
* @throws RoleRetrievalFault
*/
boolean removeRoleFromUser(long userId, long groupId, long roleId) throws UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault,RoleRetrievalFault;
/**
*
* @param userId
* @param groupIds
* @return
* @throws UserManagementSystemException
* @throws UserRetrievalFault
* @throws GroupRetrievalFault
*/
boolean removeAllRolesFromUser(long userId, long... groupIds) throws UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault;
/**
*
* @param roleId
@ -133,5 +144,5 @@ public interface RoleManager {
* @throws UserRetrievalFault
*/
List<GCubeRole> listRolesByUserAndGroup(long userId, long groupId) throws GroupRetrievalFault,UserRetrievalFault;
}

View File

@ -232,7 +232,7 @@ public class LiferayRoleManager implements RoleManager {
* {@inheritDoc}
*/
@Override
public boolean removeRoleFromUser(long userId, long groupId, long roleId) throws UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault, RoleRetrievalFault {
public boolean removeRoleFromUser(long userId, long groupId, long roleId) throws UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault, RoleRetrievalFault {
try {
_log.debug("Trying to remove role to " + UserLocalServiceUtil.getUser(userId).getFullName() +" in group " + groupId);
long[] roleIds = {roleId};
@ -249,6 +249,22 @@ public class LiferayRoleManager implements RoleManager {
* {@inheritDoc}
*/
@Override
public boolean removeAllRolesFromUser(long userId, long... groupIds) throws UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault {
try {
_log.debug("Trying to remove all roles to " + UserLocalServiceUtil.getUser(userId).getFullName() +" in groups " + groupIds);
UserGroupRoleLocalServiceUtil.deleteUserGroupRoles(userId, groupIds);
return true;
} catch (PortalException e) {
throw new UserRetrievalFault("User, not existing, or group/roleId could not be found", e);
} catch (SystemException e) {
e.printStackTrace();
}
return false;
}
/**
* {@inheritDoc}
*/
@Override
public List<GCubeRole> listAllRoles() {
List<GCubeRole> toReturn = new ArrayList<GCubeRole>();
try {