added has Team and has Role methods to RolesManger

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@128599 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-05-13 13:27:57 +00:00
parent 92cb11ad2d
commit 37262ce263
2 changed files with 41 additions and 0 deletions

View File

@ -28,6 +28,22 @@ public interface RoleManager {
* @throws UserRetrievalFault
*/
boolean isAdmin(long userId) throws UserRetrievalFault;
/**
*
* @param userId userId the LR UserId, not the username
* @param groupId the LR groupId
* @param roleId the LR roleId
* @return
*/
boolean hasRole(long userId, long groupId, long roleId);
/**
*
* @param userId userId the LR UserId, not the username
* @param teamId the LR teamId
* @param roleId the LR roleId
* @return
*/
boolean hasTeam(long userId, long teamId);
/**
*
* @param userId the LR UserId

View File

@ -132,6 +132,30 @@ public class LiferayRoleManager implements RoleManager {
}
return -1;
}
@Override
public boolean hasRole(long userId, long groupId, long roleId) {
try {
List<GCubeRole> roles = listRolesByUserAndGroup(userId, groupId);
for (GCubeRole gCubeRole : roles) {
if (gCubeRole.getRoleId() == roleId)
return true;
}
} catch (GroupRetrievalFault | UserRetrievalFault e) {
e.printStackTrace();
}
return false;
}
@Override
public boolean hasTeam(long userId, long teamId) {
try {
return UserLocalServiceUtil.hasTeamUser(teamId, userId);
} catch (SystemException e) {
e.printStackTrace();
}
return false;
}
/**
* {@inheritDoc}
*/
@ -512,4 +536,5 @@ public class LiferayRoleManager implements RoleManager {
}
return false;
}
}