Class LiferayWSRoleManager
java.lang.Object
org.gcube.vomanagement.usermanagement.impl.ws.LiferayWSRoleManager
- All Implemented Interfaces:
RoleManager
-
Constructor Summary
ConstructorsConstructorDescriptionLiferayWSRoleManager(String user, String password, String host, String schema, int port) In order to contact the json ws of Liferay, user and password are needed. -
Method Summary
Modifier and TypeMethodDescriptionbooleanassignRolesToUser(long userId, long groupId, long[] roleId) booleanassignRoleToUser(long userId, long groupId, long roleId) booleanassignTeamToUser(long userId, long teamId) associate one team to the existing teams of userbooleancreateRole(String roleName, String roleDescription) createTeam(long creatorUserId, long groupId, String teamName, String teamDescription) createTeam(long groupId, String teamName, String teamDescription) it will crate the Team as Administrator, use the other method to pass the userIdbooleandeleteRole(long roleId) deleteTeam(long teamId) booleandeleteTeams(long groupId) booleandeleteUserTeams(long userId, long[] teamIds) delete a user from a list of teamsbooleandeleteUserTeams(long userId, List<GCubeTeam> teams) delete a user from a list of teamsgetRole(long roleId) long* @param roleNamelonggetRoleIdByName(String roleName) * @param roleNamegetTeam(long teamId) booleanhasRole(long userId, long groupId, long roleId) booleanhasTeam(long userId, long teamId) booleanisAdmin(long userId) listRolesByUserAndGroup(long userId, long groupId) listTeamsByGroup(long groupId) listTeamsByUserAndGroup(long userId, long groupId) protected static GCubeRolebooleanremoveAllRolesFromUser(long userId, long... groupIds) booleanremoveRoleFromUser(long userId, long groupId, long roleId) booleansetUserTeams(long userId, long[] teamIds) associate or not associate teams to a userupdateRole(long roleId, String roleName, String roleDescription) updateTeam(long teamId, String teamName, String teamDescription)
-
Constructor Details
-
LiferayWSRoleManager
public LiferayWSRoleManager(String user, String password, String host, String schema, int port) throws Exception In order to contact the json ws of Liferay, user and password are needed. The host in which the current JVM machine runs needs to be authorized.- Parameters:
user-password-host- the host to contactport- the port numberschema- the schema (http/https) https is suggested!- Throws:
Exception
-
-
Method Details
-
mapLRRole
protected static GCubeRole mapLRRole(String jsonRole) throws com.liferay.portal.kernel.exception.PortalException, com.liferay.portal.kernel.exception.SystemException, org.json.simple.parser.ParseException - Throws:
com.liferay.portal.kernel.exception.PortalExceptioncom.liferay.portal.kernel.exception.SystemExceptionorg.json.simple.parser.ParseException
-
isAdmin
- Specified by:
isAdminin interfaceRoleManager- Parameters:
userId- the LR UserId, not the username- Returns:
- true if the user is a portal administrator, false otherwise
- Throws:
UserRetrievalFault
-
hasRole
public boolean hasRole(long userId, long groupId, long roleId) - Specified by:
hasRolein interfaceRoleManager- Parameters:
userId- userId the LR UserId, not the usernamegroupId- the LR groupIdroleId- the LR roleId- Returns:
- true if the user has the role, false otherwise
-
hasTeam
public boolean hasTeam(long userId, long teamId) - Specified by:
hasTeamin interfaceRoleManager- Parameters:
userId- userId the LR UserId, not the usernameteamId- the LR teamId- Returns:
-
assignRoleToUser
public boolean assignRoleToUser(long userId, long groupId, long roleId) throws UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault, RoleRetrievalFault - Specified by:
assignRoleToUserin interfaceRoleManager- Parameters:
userId- the LR UserIdgroupId- the LR groupIdroleId- the LR roleId- Returns:
- Throws:
UserManagementSystemExceptionUserRetrievalFaultGroupRetrievalFaultRoleRetrievalFault
-
assignRolesToUser
public boolean assignRolesToUser(long userId, long groupId, long[] roleId) throws UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault, RoleRetrievalFault - Specified by:
assignRolesToUserin interfaceRoleManager- Parameters:
userId- the LR UserIdgroupId- the LR groupIdroleId- the LR roleId- Returns:
- Throws:
UserManagementSystemExceptionUserRetrievalFaultGroupRetrievalFaultRoleRetrievalFault
-
createRole
public boolean createRole(String roleName, String roleDescription) throws UserManagementSystemException - Specified by:
createRolein interfaceRoleManager- Returns:
- true if the role is created succesfully
- Throws:
UserManagementSystemException
-
deleteRole
- Specified by:
deleteRolein interfaceRoleManager- Returns:
- true if the role is deleted succesfully, false otherwise
- Throws:
UserManagementSystemExceptionRoleRetrievalFault
-
removeRoleFromUser
public boolean removeRoleFromUser(long userId, long groupId, long roleId) throws UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault, RoleRetrievalFault - Specified by:
removeRoleFromUserin interfaceRoleManager- Returns:
- Throws:
UserManagementSystemExceptionUserRetrievalFaultGroupRetrievalFaultRoleRetrievalFault
-
removeAllRolesFromUser
public boolean removeAllRolesFromUser(long userId, long... groupIds) throws UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault - Specified by:
removeAllRolesFromUserin interfaceRoleManager- Returns:
- Throws:
UserManagementSystemExceptionUserRetrievalFaultGroupRetrievalFault
-
updateRole
public GCubeRole updateRole(long roleId, String roleName, String roleDescription) throws RoleRetrievalFault - Specified by:
updateRolein interfaceRoleManager- Returns:
- Throws:
RoleRetrievalFault
-
getRole
- Specified by:
getRolein interfaceRoleManager- Returns:
- Throws:
UserManagementSystemExceptionRoleRetrievalFault
-
getRole
public GCubeRole getRole(String roleName, long groupId) throws RoleRetrievalFault, GroupRetrievalFault - Specified by:
getRolein interfaceRoleManagergroupId- the LR groupId- Returns:
- an instance of
GCubeRoleif the roleName exists, null otherwise - Throws:
RoleRetrievalFault- if the roleName does not existGroupRetrievalFault- if the groupId does not exist
-
getRoleId
Description copied from interface:RoleManager* @param roleName- Specified by:
getRoleIdin interfaceRoleManagergroupId- the LR groupId- Returns:
- the LR RoleId if the roleName exists
- Throws:
RoleRetrievalFault- if the roleName does not existGroupRetrievalFault- if the groupId does not exist
-
getRoleIdByName
Description copied from interface:RoleManager* @param roleName- Specified by:
getRoleIdByNamein interfaceRoleManager- Returns:
- the LR RoleId if the roleName exists
- Throws:
RoleRetrievalFault- if the roleName does not exist
-
listAllRoles
- Specified by:
listAllRolesin interfaceRoleManager- Returns:
- a list of
GCubeRoleindependent from the roleType
-
listAllGroupRoles
- Specified by:
listAllGroupRolesin interfaceRoleManager- Returns:
- a list of
GCubeRoleof type Site Role (Type=2)
-
listRolesByUserAndGroup
public List<GCubeRole> listRolesByUserAndGroup(long userId, long groupId) throws GroupRetrievalFault, UserRetrievalFault - Specified by:
listRolesByUserAndGroupin interfaceRoleManager- Returns:
- a list of
GCubeRoleof type Site Role (Type=2) - Throws:
GroupRetrievalFault- if the group does not existUserRetrievalFault- if the user does not exist
-
createTeam
public GCubeTeam createTeam(long creatorUserId, long groupId, String teamName, String teamDescription) throws GroupRetrievalFault, TeamRetrievalFault, UserManagementSystemException - Specified by:
createTeamin interfaceRoleManager- Parameters:
creatorUserId- the username of who is creating the teamgroupId- the site group id where the team existsteamName- the name you want to assign to this team- Returns:
- the GCubeTeam if the team is created succesfully, null otherwise
- Throws:
UserManagementSystemExceptionGroupRetrievalFaultTeamRetrievalFault
-
createTeam
public GCubeTeam createTeam(long groupId, String teamName, String teamDescription) throws GroupRetrievalFault, TeamRetrievalFault, UserManagementSystemException Description copied from interface:RoleManagerit will crate the Team as Administrator, use the other method to pass the userId- Specified by:
createTeamin interfaceRoleManager- Parameters:
groupId- the site group id where the team existsteamName- the name you want to assign to this team- Returns:
- the GCubeTeam if the team is created succesfully, null otherwise
- Throws:
UserManagementSystemExceptionGroupRetrievalFaultTeamRetrievalFault
-
getTeam
public GCubeTeam getTeam(long groupId, String teamName) throws GroupRetrievalFault, TeamRetrievalFault - Specified by:
getTeamin interfaceRoleManager- Returns:
- Throws:
GroupRetrievalFaultTeamRetrievalFault
-
getTeam
- Specified by:
getTeamin interfaceRoleManager- Returns:
- the GCubeTeam istance
- Throws:
UserManagementSystemExceptionTeamRetrievalFault- if the team does not exist
-
deleteTeam
- Specified by:
deleteTeamin interfaceRoleManager- Parameters:
teamId- the LR team Id- Returns:
- the team instance that was removed
- Throws:
UserManagementSystemExceptionTeamRetrievalFault- if the team does not exist
-
deleteTeams
- Specified by:
deleteTeamsin interfaceRoleManager- Parameters:
groupId- the LR GroupId of the Site- Returns:
- true if the teams are deleted succesfully, false otherwise
- Throws:
UserManagementSystemException
-
deleteUserTeams
public boolean deleteUserTeams(long userId, long[] teamIds) Description copied from interface:RoleManagerdelete a user from a list of teams- Specified by:
deleteUserTeamsin interfaceRoleManager- Returns:
-
deleteUserTeams
Description copied from interface:RoleManagerdelete a user from a list of teams- Specified by:
deleteUserTeamsin interfaceRoleManager- Returns:
-
updateTeam
public GCubeTeam updateTeam(long teamId, String teamName, String teamDescription) throws TeamRetrievalFault - Specified by:
updateTeamin interfaceRoleManager- Parameters:
teamId- the team idteamName- the team nameteamDescription- the team description- Returns:
- the updated team
- Throws:
TeamRetrievalFault
-
setUserTeams
Description copied from interface:RoleManagerassociate or not associate teams to a user- Specified by:
setUserTeamsin interfaceRoleManager- Returns:
- Throws:
TeamRetrievalFault- if a system exception occurred or a team does not exists
-
assignTeamToUser
public boolean assignTeamToUser(long userId, long teamId) throws UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault, TeamRetrievalFault Description copied from interface:RoleManagerassociate one team to the existing teams of user- Specified by:
assignTeamToUserin interfaceRoleManager- Returns:
- Throws:
UserManagementSystemExceptionUserRetrievalFaultGroupRetrievalFaultTeamRetrievalFault
-
listTeamsByGroup
- Specified by:
listTeamsByGroupin interfaceRoleManager- Returns:
- a list of
GCubeTeambelonging to a give group - Throws:
GroupRetrievalFault
-
listTeamsByUserAndGroup
public List<GCubeTeam> listTeamsByUserAndGroup(long userId, long groupId) throws UserRetrievalFault, GroupRetrievalFault - Specified by:
listTeamsByUserAndGroupin interfaceRoleManager- Parameters:
userId- the LR userId of the SitegroupId- the LR GroupId of the Site- Returns:
- a list of
GCubeTeambelonging to a user in a given group - Throws:
UserRetrievalFaultGroupRetrievalFault
-