package org.gcube.vomanagement.usermanagement; import java.util.List; import java.util.Map; import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; import org.gcube.vomanagement.usermanagement.exception.RoleRetrievalFault; import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException; import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault; import org.gcube.vomanagement.usermanagement.model.GCubeMembershipRequest; import org.gcube.vomanagement.usermanagement.model.GCubeRole; import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.gcube.vomanagement.usermanagement.model.MembershipRequestStatus; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; /** * * * @author Massimiliano Assante, CNR-ISTI * */ public interface UserManager { /** * Create the user without sending notification mail and without forcing him to change the password at first login. * @param autoScreenName set true if you want liferay to auto generate a screename for this user, false otherwise * @param username the username of the user you want * @param email a valid email address * @param firstName * @param middleName * @param lastName * @param jobTitle * @param backgroundSummary * @param male * @return an instance of the yet created user * @throws UserManagementSystemException */ 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) throws UserManagementSystemException; /** * 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. * @param autoScreenName set true if you want liferay to auto generate a screename for this user, false otherwise * @param username the username of the user you want * @param email a valid email address * @param firstName * @param middleName * @param lastName * @param jobTitle * @param backgroundSummary * @param male * @return an instance of the yet created user * @throws UserManagementSystemException */ 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) throws UserManagementSystemException; /** * 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. * You can also pass the avatar to set as bytes. * @param autoScreenName set true if you want liferay to auto generate a screename for this user, false otherwise * @param username the username of the user you want * @param email a valid email address * @param firstName * @param middleName * @param lastName * @param jobTitle * @param backgroundSummary * @param male * @param portraitBytes the bytes of the avatar to use for the user * @param openId user's openId * @return an instance of the yet created user * @throws UserManagementSystemException */ 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) throws UserManagementSystemException; /** * * @param username the username of the user you want to get * @return the instance of the user * @throws UserManagementSystemException * @throws UserRetrievalFault */ GCubeUser getUserByUsername(String username) throws UserManagementSystemException, UserRetrievalFault; /** * @deprecated use getUserByUsername * @param username * @return * @throws UserManagementSystemException * @throws UserRetrievalFault */ @Deprecated GCubeUser getUserByScreenName(String username) throws UserManagementSystemException, UserRetrievalFault; /** * * @param username the email of the user you want to get * @return the instance of the user * @throws UserManagementSystemException * @throws UserRetrievalFault */ GCubeUser getUserByEmail(String email) throws UserManagementSystemException, UserRetrievalFault; /** * * @param userId the LR UserId * @return the instance of the user * @throws UserManagementSystemException * @throws UserRetrievalFault */ GCubeUser getUserById(long userId) throws UserManagementSystemException, UserRetrievalFault; /** * * @param username the LR screenname * @return the LR userId associated to this screenname * @throws UserManagementSystemException * @throws UserRetrievalFault */ long getUserId(String username) throws UserManagementSystemException, UserRetrievalFault; /** * * @param userId the LR UserId * @return the user professional background * @throws UserManagementSystemException * @throws UserRetrievalFault */ String getUserProfessionalBackground(long userId) throws UserManagementSystemException, UserRetrievalFault; /** * * @return 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 */ List listUsers() throws UserManagementSystemException; /** * * @param groupId the LR groupId * @return * @throws UserManagementSystemException * @throws GroupRetrievalFault * @throws UserRetrievalFault */ List listUsersByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault; /** * * @param the name of the VO or VRE (e.g. devVRE, or gcube etc.) * @return * @throws UserManagementSystemException * @throws GroupRetrievalFault * @throws UserRetrievalFault */ List listUsersByGroupName(String name) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault; /** * * @param groupId the LR groupId * @return the list of {@link GCubeMembershipRequest} with their status and users given the LR GroupId (status can be requested, approved or rejected, @see {@link MembershipRequestStatus} * @throws UserManagementSystemException * @throws GroupRetrievalFault * @throws UserRetrievalFault */ List listMembershipRequestsByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault; /** * * @param requestId * @return an istance of {@link GCubeMembershipRequest} */ GCubeMembershipRequest getMembershipRequestsById(long membershipRequestId); /** * * @param userId the LR userid * @param groupId the LR groupId the * @param status an istance of {@link MembershipRequestStatus} * @return the list of {@link GCubeMembershipRequest} with their status and users given the LR GroupId and userId (status can be requested, approved or rejected, @see {@link MembershipRequestStatus} */ List getMembershipRequests(long userId, long groupId, MembershipRequestStatus status) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault; /** * request the membership to a restricted Site, no further actions are performed (no emails are sent, nor notifications) * @param userId the LR userid * @param groupId the LR groupId the * @param comment a comment to the request must not be null * @throws UserManagementSystemException * @throws GroupRetrievalFault * @throws UserRetrievalFault */ GCubeMembershipRequest requestMembership(long userId, long groupId, String comment) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault; /** * accept a membership request and optionally add the user to the group * @param requestUserId the LR userid of the request * @param groupId the LR groupId * @param addUserToGroup if you want it to also add the user to the group * @param String the username (screenname) of the user accepting the request * @param replyComment a comment attachd to the reply (must not be null) * @throws UserManagementSystemException * @throws GroupRetrievalFault * @throws UserManagementPortalException */ GCubeMembershipRequest acceptMembershipRequest(long requestUserId,long groupId, boolean addUserToGroup, String replyUsername, String replyComment) throws UserManagementSystemException, GroupRetrievalFault, UserManagementPortalException; /** * rejects a membership request * @param requestUserId the LR userid of the request * @param groupId the LR groupId * @param String the username (screenname) of the user accepting the request * @param replyComment a comment attachd to the reply (must not be null) * @throws UserManagementSystemException * @throws GroupRetrievalFault * @throws UserManagementPortalException */ GCubeMembershipRequest rejectMembershipRequest(long userId, long groupId, String replyUsername, String replyComment) throws UserManagementSystemException, GroupRetrievalFault, UserManagementPortalException; /** * * @param groupId the LR groupId * @return the list of {@link GCubeUser} with their GCubeRole given the LR GroupId * @throws GroupRetrievalFault * @throws UserManagementSystemException * @throws UserRetrievalFault */ Map> listUsersAndRolesByGroup(long groupId) throws GroupRetrievalFault, UserManagementSystemException, UserRetrievalFault ; /** * * @param groupId the LR groupId * @parmam roleId the LR roleId * @return the list of {@link GCubeUser} having group and role that matches * @throws GroupRetrievalFault * @throws UserManagementSystemException * @throws UserRetrievalFault */ List listUsersByGroupAndRole(long groupId, long roleId) throws UserManagementSystemException, RoleRetrievalFault, GroupRetrievalFault, UserRetrievalFault; /** * this method assigns the user to the Group and perform other necessary actions (such as adding him to the HL Folder) * @param groupId LR groupId * @param userId LR userId * @throws UserManagementSystemException * @throws GroupRetrievalFault * @throws UserRetrievalFault * @throws UserManagementPortalException */ void assignUserToGroup(long groupId, long userId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault, UserManagementPortalException; /** * this method removes the user to the Group and perform other necessary actions (such as removing him from the HL Folder) * @param groupId LR groupId * @param userId LR userId * @throws UserManagementSystemException * @throws GroupRetrievalFault * @throws UserRetrievalFault * @throws UserManagementPortalException */ void dismissUserFromGroup(long groupId, long userId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault; /** * * @param groupId LR groupId * @return all the users of the portal not belonging to the groupId * @throws UserManagementSystemException * @throws GroupRetrievalFault * @throws UserRetrievalFault */ List listUnregisteredUsersByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault; /** * Check if the user changed his/her password from the initial one. * @param email the email of the user to consider * @return true if the password has been changed, false if it has been not or the user doesn't exist. */ boolean isPasswordChanged(String email); /** * Check if a user with such email exists. * @param email * @return true on success, false otherwise */ public boolean userExistsByEmail(String email); /** * Returns the user's full name given his email * @param email * @return null on failure */ public String getFullNameFromEmail(String email); /** * Delete a user given his mail * @param email */ public void deleteUserByEMail(String email) throws UserManagementSystemException, UserManagementPortalException, PortalException, SystemException; /** * Retrieve user's avatar as bytes */ public byte[] getUserAvatarBytes(String screenName); /** * Retrieve user's openId field */ public String getUserOpenId(String screenName); }