Class LiferayWSUserManager
java.lang.Object
org.gcube.vomanagement.usermanagement.impl.ws.LiferayWSUserManager
- All Implemented Interfaces:
UserManager
Exploit Liferay JSON Web Service to perform UserManager's operations.
- Author:
- Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
-
Constructor Summary
ConstructorsConstructorDescriptionLiferayWSUserManager(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 TypeMethodDescriptionacceptMembershipRequest(long requestUserId, long groupId, boolean addUserToGroup, String replyUsername, String replyComment) accept a membership request and optionally add the user to the groupvoidassignUserToGroup(long groupId, long userId) this method assigns the user to the Group and perform other necessary actions (such as adding him to the HL Folder)createUser(boolean autoScreenName, String username, String email, String firstName, String middleName, String lastName, String jobTitle, String location_industry, String backgroundSummary, boolean male, String reminderQuestion, String reminderAnswer, boolean sendEmail, boolean forcePasswordReset, byte[] portraitBytes, int type) Create the user and let you choose if you want to send him/her a mail notification and force or not the user to change his/her password.createUser(boolean autoScreenName, String username, String email, String firstName, String middleName, String lastName, String jobTitle, String location_industry, String backgroundSummary, boolean male, String reminderQuestion, String reminderAnswer, boolean sendEmail, boolean forcePasswordReset, byte[] portraitBytes, String mySpacesn, String twittersn, String facebooksn, String skypesn, String jabbersn, String aimsn, int type) Create the user and let you choose if you want to send him/her a mail notification and force or not the user to change his/her password.createUser(boolean autoScreenName, String username, String email, String firstName, String middleName, String lastName, String jobTitle, String location_industry, String backgroundSummary, boolean male, String reminderQuestion, String reminderAnswer, boolean sendEmail, boolean forcePasswordReset, int type) Create the user and let you choose if you want to send him/her a mail notification and force or not the user to change his/her password.createUser(boolean autoScreenName, String username, String email, String firstName, String middleName, String lastName, String jobTitle, String location_industry, String backgroundSummary, boolean male, String reminderQuestion, String reminderAnswer, int type) Create the user without sending notification mail and without forcing him to change the password at first login.voiddeleteUserByEMail(String email) Delete a user given his mailvoiddismissUserFromGroup(long groupId, long userId) this method removes the user to the Group and perform other necessary actions (such as removing him from the HL Folder)getFullNameFromEmail(String email) Returns the user's full name given his emailintgetGroupUsersCount(long groupId) Returns the number of users in the group (VRE).getMembershipRequests(long userId, long groupId, MembershipRequestStatus status) getMembershipRequestsById(long membershipRequestId) byte[]getUserAvatarBytes(String screenName) Retrieve user's avatar as bytesgetUserByEmail(String email) getUserById(long userId) getUserByScreenName(String username) getUserByUsername(String username) getUserContactsByGroup(long userId, long scopeGroupId) longgetUserIdsByGroup(long groupId) Retrieve the list of user identifiers by group id.getUserOpenId(String screenName) Retrieve user's openId fieldgetUserProfessionalBackground(long userId) intReturns the number of total users.booleanisPasswordChanged(String email) Check if the user changed his/her password from the initial one.listMembershipRequestsByGroup(long groupId) listPendingMembershipRequestsByGroup(long groupId) listUnregisteredUsersByGroup(long groupId) long[]listUserIdsByGroupAndRole(long groupId, long roleId) listUsers(boolean indexed) listUsers(int start, int end) Returns a range of all the users.listUsersAndRolesByGroup(long groupId) listUsersByGlobalRole(long roleId) Retrieve a list of users having a global role (e.g., Administrator)listUsersByGroup(long groupId) listUsersByGroup(long groupId, boolean indexed) listUsersByGroup(long groupId, int start, int end) listUsersByGroupAndRole(long groupId, long roleId) listUsersByGroupName(String name) listUsersByTeam(long teamId) /**readCustomAttr(long userId, String attributeKey) rejectMembershipRequest(long userId, long groupId, String replyUsername, String replyComment) rejects a membership requestrequestMembership(long userId, long groupId, String comment) request the membership to a restricted Site, no further actions are performed (no emails are sent, nor notifications)voidsaveCustomAttr(long userId, String attributeKey, Serializable value) searchUsersByGroup(String keywords, long groupId) voidsetUserProfessionalBackground(long userId, String summary) Save the user professional backgroundbooleanupdateContactInformation(String screenName, String mySpacesn, String twittersn, String facebooksn, String skypesn, String jabbersn, String aimsn) Update screenName user's contact informationbooleanupdateJobTitle(long userId, String theJob) booleanuserExistsByEmail(String email) Check if a user with such email exists.
-
Constructor Details
-
LiferayWSUserManager
public LiferayWSUserManager(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
-
createUser
public GCubeUser createUser(boolean autoScreenName, String username, String email, String firstName, String middleName, String lastName, String jobTitle, String location_industry, String backgroundSummary, boolean male, String reminderQuestion, String reminderAnswer, int type) throws UserManagementSystemException Description copied from interface:UserManagerCreate the user without sending notification mail and without forcing him to change the password at first login.- Specified by:
createUserin interfaceUserManager- Parameters:
autoScreenName- set true if you want liferay to auto generate a screename for this user, false otherwiseusername- the username of the user you wantemail- a valid email address- Returns:
- an instance of the yet created user
- Throws:
UserManagementSystemException
-
createUser
public GCubeUser createUser(boolean autoScreenName, String username, String email, String firstName, String middleName, String lastName, String jobTitle, String location_industry, String backgroundSummary, boolean male, String reminderQuestion, String reminderAnswer, boolean sendEmail, boolean forcePasswordReset, int type) throws UserManagementSystemException Description copied from interface:UserManagerCreate the user and let you choose if you want to send him/her a mail notification and force or not the user to change his/her password.- Specified by:
createUserin interfaceUserManager- Parameters:
autoScreenName- set true if you want liferay to auto generate a screename for this user, false otherwiseusername- the username of the user you wantemail- a valid email address- Returns:
- an instance of the yet created user
- Throws:
UserManagementSystemException
-
createUser
public GCubeUser createUser(boolean autoScreenName, String username, String email, String firstName, String middleName, String lastName, String jobTitle, String location_industry, String backgroundSummary, boolean male, String reminderQuestion, String reminderAnswer, boolean sendEmail, boolean forcePasswordReset, byte[] portraitBytes, int type) throws UserManagementSystemException Description copied from interface:UserManagerCreate the user and let you choose if you want to send him/her a mail notification and force or not the user to change his/her password. You can also pass the avatar to set as bytes.- Specified by:
createUserin interfaceUserManager- Parameters:
autoScreenName- set true if you want liferay to auto generate a screename for this user, false otherwiseusername- the username of the user you wantemail- a valid email addressportraitBytes- the bytes of the avatar to use for the usertype- the type of user- Returns:
- an instance of the yet created user
- Throws:
UserManagementSystemException- if a system exception occurs
-
createUser
public GCubeUser createUser(boolean autoScreenName, String username, String email, String firstName, String middleName, String lastName, String jobTitle, String location_industry, String backgroundSummary, boolean male, String reminderQuestion, String reminderAnswer, boolean sendEmail, boolean forcePasswordReset, byte[] portraitBytes, String mySpacesn, String twittersn, String facebooksn, String skypesn, String jabbersn, String aimsn, int type) throws UserManagementSystemException Description copied from interface:UserManagerCreate the user and let you choose if you want to send him/her a mail notification and force or not the user to change his/her password. You can also pass the avatar to set as bytes. Moreover, contact information can be passed.- Specified by:
createUserin interfaceUserManagermySpacesn- please note that this field will be used for Linkedin information!!- Returns:
- Throws:
UserManagementSystemException
-
getUserByUsername
public GCubeUser getUserByUsername(String username) throws UserManagementSystemException, UserRetrievalFault - Specified by:
getUserByUsernamein interfaceUserManager- Parameters:
username- the username of the user you want to get- Returns:
- the instance of the user
- Throws:
UserManagementSystemExceptionUserRetrievalFault
-
getUserByScreenName
public GCubeUser getUserByScreenName(String username) throws UserManagementSystemException, UserRetrievalFault - Specified by:
getUserByScreenNamein interfaceUserManager- Returns:
- Throws:
UserManagementSystemExceptionUserRetrievalFault
-
getUserByEmail
public GCubeUser getUserByEmail(String email) throws UserManagementSystemException, UserRetrievalFault - Specified by:
getUserByEmailin interfaceUserManager- Parameters:
email- the email of the user you want to get- Returns:
- the instance of the user
- Throws:
UserManagementSystemException- if a system exception occursUserRetrievalFault- if the user does not exist
-
getUserById
- Specified by:
getUserByIdin interfaceUserManager- Parameters:
userId- the LR UserId- Returns:
- the instance of the user
- Throws:
UserManagementSystemExceptionUserRetrievalFault
-
getUserId
- Specified by:
getUserIdin interfaceUserManager- Parameters:
username- the LR screenname- Returns:
- the LR userId associated to this screenname
- Throws:
UserManagementSystemExceptionUserRetrievalFault
-
getUserProfessionalBackground
public String getUserProfessionalBackground(long userId) throws UserManagementSystemException, UserRetrievalFault - Specified by:
getUserProfessionalBackgroundin interfaceUserManager- Parameters:
userId- the LR UserId- Returns:
- the user professional background
- Throws:
UserManagementSystemExceptionUserRetrievalFault
-
setUserProfessionalBackground
public void setUserProfessionalBackground(long userId, String summary) throws UserManagementSystemException, UserRetrievalFault Description copied from interface:UserManagerSave the user professional background- Specified by:
setUserProfessionalBackgroundin interfaceUserManager- Throws:
UserManagementSystemException- if a system exception occursUserRetrievalFault- if the user does not exist
-
listUsers
- Specified by:
listUsersin interfaceUserManager- Returns:
- a list of all portal active users (using indexed version search) no matter if the belong or not to a VRE, if a user is deactived is not returned
- Throws:
UserManagementSystemException
-
listUsers
- Specified by:
listUsersin interfaceUserManager- Parameters:
indexed- set to true to use the indexed version search false for a real time query to the DB.- Returns:
- a list of all portal active users no matter if the belong or not to a VRE, if a user is deactived is not returned
- Throws:
UserManagementSystemException
-
listUsersByGroup
public List<GCubeUser> listUsersByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault - Specified by:
listUsersByGroupin interfaceUserManager- Parameters:
groupId- the LR groupId- Returns:
- Throws:
UserManagementSystemExceptionGroupRetrievalFaultUserRetrievalFault
-
listUsersByGroup
public List<GCubeUser> listUsersByGroup(long groupId, boolean indexed) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault - Specified by:
listUsersByGroupin interfaceUserManager- Parameters:
groupId- the LR groupIdindexed- set to true to use the indexed version search false for a real time query to the DB.- Returns:
- a list of all portal active users belonging to the given groupid
- Throws:
UserManagementSystemException- if a system exception occursGroupRetrievalFault- if the group does not existUserRetrievalFault- .
-
listUsersByGroupName
public List<GCubeUser> listUsersByGroupName(String name) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault - Specified by:
listUsersByGroupNamein interfaceUserManager- Parameters:
name- the name of the VO or VRE (e.g. devVRE, or gcube etc.)- Returns:
- a list of users
- Throws:
UserManagementSystemException- if a system exception occursGroupRetrievalFaultUserRetrievalFault
-
getUserContactsByGroup
public Set<GCubeUser> getUserContactsByGroup(long userId, long scopeGroupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault - Specified by:
getUserContactsByGroupin interfaceUserManager- Parameters:
userId- the LR userid for which you need to fetch the contactsscopeGroupId- the liferay groupid number of the current Site- Returns:
- a set containing all portal active users that the user can contact/see (depending on the scopeGroupId he/she can see the users a VRE, or the users of all the VREs he/she is subscribed)
- Throws:
UserManagementSystemException- .GroupRetrievalFault- .UserRetrievalFault- .
-
listMembershipRequestsByGroup
public List<GCubeMembershipRequest> listMembershipRequestsByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault - Specified by:
listMembershipRequestsByGroupin interfaceUserManager- Parameters:
groupId- the LR groupId- Returns:
- the list of
GCubeMembershipRequestwith their status and users given the LR GroupId (status can be requested, approved or rejected, @seeMembershipRequestStatus - Throws:
UserManagementSystemExceptionGroupRetrievalFaultUserRetrievalFault
-
listPendingMembershipRequestsByGroup
public List<GCubeMembershipRequest> listPendingMembershipRequestsByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault - Specified by:
listPendingMembershipRequestsByGroupin interfaceUserManager- Parameters:
groupId- the LR groupId- Returns:
- the list of
GCubeMembershipRequestwith status requested and users given the LR GroupId @seeMembershipRequestStatus - Throws:
UserManagementSystemExceptionGroupRetrievalFaultUserRetrievalFault
-
getMembershipRequestsById
- Specified by:
getMembershipRequestsByIdin interfaceUserManager- Parameters:
membershipRequestId- the id of the request- Returns:
- an istance of
GCubeMembershipRequest
-
getMembershipRequests
public List<GCubeMembershipRequest> getMembershipRequests(long userId, long groupId, MembershipRequestStatus status) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault - Specified by:
getMembershipRequestsin interfaceUserManager- Parameters:
userId- the LR useridgroupId- the LR groupId thestatus- an istance ofMembershipRequestStatus- Returns:
- the list of
GCubeMembershipRequestwith their status and users given the LR GroupId and userId (status can be requested, approved or rejected, @seeMembershipRequestStatus - Throws:
UserManagementSystemExceptionGroupRetrievalFaultUserRetrievalFault
-
requestMembership
public GCubeMembershipRequest requestMembership(long userId, long groupId, String comment) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault Description copied from interface:UserManagerrequest the membership to a restricted Site, no further actions are performed (no emails are sent, nor notifications)- Specified by:
requestMembershipin interfaceUserManager- Parameters:
userId- the LR useridgroupId- the LR groupId thecomment- a comment to the request must not be null- Throws:
UserManagementSystemExceptionGroupRetrievalFaultUserRetrievalFault
-
acceptMembershipRequest
public GCubeMembershipRequest acceptMembershipRequest(long requestUserId, long groupId, boolean addUserToGroup, String replyUsername, String replyComment) throws UserManagementSystemException, GroupRetrievalFault, UserManagementPortalException Description copied from interface:UserManageraccept a membership request and optionally add the user to the group- Specified by:
acceptMembershipRequestin interfaceUserManager- Parameters:
requestUserId- the LR userid of the requestgroupId- the LR groupIdaddUserToGroup- if you want it to also add the user to the groupreplyUsername- the username (screenname) of the user accepting the requestreplyComment- a comment attachd to the reply (must not be null)- Throws:
UserManagementSystemException- if a system exception occursGroupRetrievalFaultUserManagementPortalException
-
rejectMembershipRequest
public GCubeMembershipRequest rejectMembershipRequest(long userId, long groupId, String replyUsername, String replyComment) throws UserManagementSystemException, GroupRetrievalFault, UserManagementPortalException Description copied from interface:UserManagerrejects a membership request- Specified by:
rejectMembershipRequestin interfaceUserManager- Parameters:
userId- the LR userid of the requestgroupId- the LR groupIdreplyUsername- the username (screenname) of the user accepting the requestreplyComment- a comment attachd to the reply (must not be null)- Throws:
UserManagementSystemException- if a system exception occursGroupRetrievalFaultUserManagementPortalException
-
listUsersAndRolesByGroup
public Map<GCubeUser,List<GCubeRole>> listUsersAndRolesByGroup(long groupId) throws GroupRetrievalFault, UserManagementSystemException, UserRetrievalFault - Specified by:
listUsersAndRolesByGroupin interfaceUserManager- Parameters:
groupId- the LR groupId- Returns:
- the list of
GCubeUserwith their GCubeRole given the LR GroupId - Throws:
GroupRetrievalFaultUserManagementSystemExceptionUserRetrievalFault
-
listUsersByGroupAndRole
public List<GCubeUser> listUsersByGroupAndRole(long groupId, long roleId) throws UserManagementSystemException, RoleRetrievalFault, GroupRetrievalFault, UserRetrievalFault - Specified by:
listUsersByGroupAndRolein interfaceUserManager- Parameters:
groupId- the LR groupIdroleId- the LR roleId- Returns:
- the list of
GCubeUserhaving group and role that matches - Throws:
UserManagementSystemExceptionGroupRetrievalFault- if the group does not existUserRetrievalFaultRoleRetrievalFault
-
listUsersByTeam
public List<GCubeUser> listUsersByTeam(long teamId) throws UserManagementSystemException, TeamRetrievalFault, UserRetrievalFault Description copied from interface:UserManager/**- Specified by:
listUsersByTeamin interfaceUserManager- Parameters:
teamId- the LR teamId- Returns:
- the list of
GCubeUserhaving teamId that matches - Throws:
UserManagementSystemExceptionTeamRetrievalFault- if the team does not existUserRetrievalFault
-
assignUserToGroup
public void assignUserToGroup(long groupId, long userId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault, UserManagementPortalException Description copied from interface:UserManagerthis method assigns the user to the Group and perform other necessary actions (such as adding him to the HL Folder)- Specified by:
assignUserToGroupin interfaceUserManager- Parameters:
groupId- LR groupIduserId- LR userId- Throws:
UserManagementSystemExceptionGroupRetrievalFaultUserRetrievalFaultUserManagementPortalException
-
dismissUserFromGroup
public void dismissUserFromGroup(long groupId, long userId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault Description copied from interface:UserManagerthis method removes the user to the Group and perform other necessary actions (such as removing him from the HL Folder)- Specified by:
dismissUserFromGroupin interfaceUserManager- Parameters:
groupId- LR groupIduserId- LR userId- Throws:
UserManagementSystemExceptionGroupRetrievalFaultUserRetrievalFault
-
listUnregisteredUsersByGroup
public List<GCubeUser> listUnregisteredUsersByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault - Specified by:
listUnregisteredUsersByGroupin interfaceUserManager- Parameters:
groupId- LR groupId- Returns:
- all the users of the portal not belonging to the groupId
- Throws:
UserManagementSystemExceptionGroupRetrievalFaultUserRetrievalFault
-
isPasswordChanged
Description copied from interface:UserManagerCheck if the user changed his/her password from the initial one.- Specified by:
isPasswordChangedin interfaceUserManager- Parameters:
email- the email of the user to consider- Returns:
- true if the password has been changed, false if it has been not or the user doesn't exist.
-
userExistsByEmail
Description copied from interface:UserManagerCheck if a user with such email exists.- Specified by:
userExistsByEmailin interfaceUserManager- Returns:
- true on success, false otherwise
-
getFullNameFromEmail
Description copied from interface:UserManagerReturns the user's full name given his email- Specified by:
getFullNameFromEmailin interfaceUserManager- Returns:
- null on failure
-
deleteUserByEMail
public void deleteUserByEMail(String email) throws UserManagementSystemException, UserManagementPortalException, com.liferay.portal.kernel.exception.PortalException, com.liferay.portal.kernel.exception.SystemException Description copied from interface:UserManagerDelete a user given his mail- Specified by:
deleteUserByEMailin interfaceUserManager- Throws:
UserManagementSystemExceptionUserManagementPortalExceptioncom.liferay.portal.kernel.exception.PortalExceptioncom.liferay.portal.kernel.exception.SystemException
-
getUserAvatarBytes
Description copied from interface:UserManagerRetrieve user's avatar as bytes- Specified by:
getUserAvatarBytesin interfaceUserManager
-
getUserOpenId
Description copied from interface:UserManagerRetrieve user's openId field- Specified by:
getUserOpenIdin interfaceUserManager
-
updateContactInformation
public boolean updateContactInformation(String screenName, String mySpacesn, String twittersn, String facebooksn, String skypesn, String jabbersn, String aimsn) Description copied from interface:UserManagerUpdate screenName user's contact information- Specified by:
updateContactInformationin interfaceUserManagermySpacesn- used for linkedin contact info- Returns:
- true on success, false otherwise
-
updateJobTitle
- Specified by:
updateJobTitlein interfaceUserManagertheJob- the job headline- Returns:
- true if ok
-
readCustomAttr
- Specified by:
readCustomAttrin interfaceUserManagerattributeKey- the name of the attribute you want to read its value- Returns:
- the attributeKey value if existing, null otherwise
- Throws:
UserRetrievalFault
-
saveCustomAttr
public void saveCustomAttr(long userId, String attributeKey, Serializable value) throws UserRetrievalFault - Specified by:
saveCustomAttrin interfaceUserManagerattributeKey- the name of the attribute you want to savevalue- the value- Throws:
UserRetrievalFault
-
listUsersByGlobalRole
Description copied from interface:UserManagerRetrieve a list of users having a global role (e.g., Administrator)- Specified by:
listUsersByGlobalRolein interfaceUserManager- Returns:
-
getUserIdsByGroup
Description copied from interface:UserManagerRetrieve the list of user identifiers by group id.- Specified by:
getUserIdsByGroupin interfaceUserManager- Returns:
-
listUsers
Description copied from interface:UserManagerReturns a range of all the users. Useful when paginating results. Returns a maximum of end - start instances, 0 refers to the first result in the set.- Specified by:
listUsersin interfaceUserManager- Parameters:
start- start the lower bound of the range of usersend- end the upper bound of the range of users (not inclusive)- Returns:
- the range of users
- Throws:
UserManagementSystemException
-
getUsersCount
Description copied from interface:UserManagerReturns the number of total users.- Specified by:
getUsersCountin interfaceUserManager- Returns:
- the number of users
- Throws:
UserManagementSystemException
-
searchUsersByGroup
- Specified by:
searchUsersByGroupin interfaceUserManager- Parameters:
keywords- the keywords (space separated), which may occur in the user's first name, middle name, last name, username, or email address- Returns:
- all the users who match the keywords ordered by username (Ascendent order)
- Throws:
GroupRetrievalFault- if the group does not exist
-
listUsersByGroup
public List<GCubeUser> listUsersByGroup(long groupId, int start, int end) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault - Specified by:
listUsersByGroupin interfaceUserManager- Parameters:
groupId- the LR groupId- Returns:
- Throws:
UserManagementSystemExceptionGroupRetrievalFaultUserRetrievalFault
-
getGroupUsersCount
Description copied from interface:UserManagerReturns the number of users in the group (VRE).- Specified by:
getGroupUsersCountin interfaceUserManager- Returns:
- the number of users in the group (VRE).
- Throws:
GroupRetrievalFault
-
listUserIdsByGroupAndRole
public long[] listUserIdsByGroupAndRole(long groupId, long roleId) - Specified by:
listUserIdsByGroupAndRolein interfaceUserManager- Returns:
- the list of userId having group and role that matches
-