diff --git a/src/main/java/org/gcube/vomanagement/usermanagement/RoleManager.java b/src/main/java/org/gcube/vomanagement/usermanagement/RoleManager.java index 51306a4..f14b9f4 100644 --- a/src/main/java/org/gcube/vomanagement/usermanagement/RoleManager.java +++ b/src/main/java/org/gcube/vomanagement/usermanagement/RoleManager.java @@ -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 diff --git a/src/main/java/org/gcube/vomanagement/usermanagement/impl/LiferayRoleManager.java b/src/main/java/org/gcube/vomanagement/usermanagement/impl/LiferayRoleManager.java index fea762e..07d019f 100644 --- a/src/main/java/org/gcube/vomanagement/usermanagement/impl/LiferayRoleManager.java +++ b/src/main/java/org/gcube/vomanagement/usermanagement/impl/LiferayRoleManager.java @@ -132,6 +132,30 @@ public class LiferayRoleManager implements RoleManager { } return -1; } + + @Override + public boolean hasRole(long userId, long groupId, long roleId) { + try { + List 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; } + }