added the following methods:

List getMembershipRequests(long userId, long groupId, MembershipRequestStatus status)
GCubeUser getUserById(long userId)
GCubeMembershipRequest getMembershipRequestsById(long membershipRequestId)


git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@124873 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-03-08 14:10:06 +00:00
parent a43ce75f45
commit fc8a1738e4
4 changed files with 105 additions and 13 deletions

View File

@ -13,8 +13,6 @@ import org.gcube.vomanagement.usermanagement.model.GCubeRole;
import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.gcube.vomanagement.usermanagement.model.MembershipRequestStatus; import org.gcube.vomanagement.usermanagement.model.MembershipRequestStatus;
import com.liferay.portal.model.MembershipRequest;
/** /**
* *
@ -44,7 +42,7 @@ import com.liferay.portal.model.MembershipRequest;
* @throws UserManagementSystemException * @throws UserManagementSystemException
* @throws UserRetrievalFault * @throws UserRetrievalFault
*/ */
GCubeUser getUserByUsername(String username) throws UserManagementSystemException, UserRetrievalFault ; GCubeUser getUserByUsername(String username) throws UserManagementSystemException, UserRetrievalFault;
/** /**
* *
* @param username the email of the user you want to get * @param username the email of the user you want to get
@ -53,6 +51,14 @@ import com.liferay.portal.model.MembershipRequest;
* @throws UserRetrievalFault * @throws UserRetrievalFault
*/ */
GCubeUser getUserByEmail(String email) throws UserManagementSystemException, 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 * @param username the LR screenname
@ -88,13 +94,27 @@ import com.liferay.portal.model.MembershipRequest;
/** /**
* *
* @param groupId the LR groupId * @param groupId the LR groupId
* @return the list of {@link MembershipRequest} with their status and users given the LR GroupId (status can be requested, approved or rejected, @see {@link MembershipRequestStatus} * @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 UserManagementSystemException
* @throws GroupRetrievalFault * @throws GroupRetrievalFault
* @throws UserRetrievalFault * @throws UserRetrievalFault
*/ */
List<GCubeMembershipRequest> listMembershipRequestsByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault; List<GCubeMembershipRequest> 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<GCubeMembershipRequest> 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) * request the membership to a restricted Site, no further actions are performed (no emails are sent, nor notifications)
* @param userId the LR userid * @param userId the LR userid
* @param groupId the LR groupId the * @param groupId the LR groupId the
@ -103,7 +123,7 @@ import com.liferay.portal.model.MembershipRequest;
* @throws GroupRetrievalFault * @throws GroupRetrievalFault
* @throws UserRetrievalFault * @throws UserRetrievalFault
*/ */
GCubeMembershipRequest requestMembership(long userId, long groupId, String comment) throws UserManagementSystemException, GroupRetrievalFault, 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 * accept a membership request and optionally add the user to the group
* @param requestUserId the LR userid of the request * @param requestUserId the LR userid of the request

View File

@ -9,7 +9,9 @@ public class RoleRetrievalFault extends Exception{
private static final long serialVersionUID = 2824756378739545315L; private static final long serialVersionUID = 2824756378739545315L;
public RoleRetrievalFault(String errorMsg) {
System.out.println(errorMsg);
}
/** /**
* *
*/ */

View File

@ -1,6 +1,5 @@
package org.gcube.vomanagement.usermanagement.impl; package org.gcube.vomanagement.usermanagement.impl;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -201,8 +200,7 @@ public class LiferayUserManager implements UserManager {
reminderAnswer = "Unknown answer"; reminderAnswer = "Unknown answer";
UserLocalServiceUtil.updateReminderQuery(added.getUserId(), reminderQuestion, reminderAnswer); UserLocalServiceUtil.updateReminderQuery(added.getUserId(), reminderQuestion, reminderAnswer);
_log.debug("User " + lastName + " has agreed to ToU"); _log.debug("User " + lastName + " has agreed to ToU");
_log.debug("User " + lastName + " updatePasswordReset false"); _log.debug("User " + lastName + " updatePasswordReset & updateReminderQuery");
_log.debug("User " + lastName + " updateReminderQuery false");
return mapLRUser(added); return mapLRUser(added);
} catch (SystemException e) { } catch (SystemException e) {
e.printStackTrace(); e.printStackTrace();
@ -229,6 +227,25 @@ public class LiferayUserManager implements UserManager {
} }
return toReturn; return toReturn;
} }
/**
* {@inheritDoc}
*/
@Override
public GCubeUser getUserById(long userId) throws UserManagementSystemException, UserRetrievalFault {
User toGet = null;
GCubeUser toReturn = null;
try {
_log.debug("Trying to fetch user by LR Id = " + userId);
toGet = UserLocalServiceUtil.getUser(userId);
toReturn = mapLRUser(toGet);
} catch (PortalException e) {
throw new UserRetrievalFault("User not existing", e);
} catch (SystemException e) {
throw new UserManagementSystemException(e.getMessage(), e);
}
return toReturn;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -466,6 +483,53 @@ public class LiferayUserManager implements UserManager {
} }
return null; return null;
} }
/**
* {@inheritDoc}
*/
@Override
public GCubeMembershipRequest getMembershipRequestsById(long membershipRequestId) {
GCubeMembershipRequest toReturn = null;
try {
toReturn = mapLRMembershipRequest(MembershipRequestLocalServiceUtil.getMembershipRequest(membershipRequestId));
} catch (PortalException e) {
e.printStackTrace();
} catch (SystemException e) {
e.printStackTrace();
}
return toReturn;
}
/**
* {@inheritDoc}
*/
@Override
public List<GCubeMembershipRequest> getMembershipRequests(long userId, long groupId, MembershipRequestStatus requestStatus) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault {
try {
Group g = GroupLocalServiceUtil.getGroup(groupId);
_log.debug("Asked for pending users list of group: "+g.getName());
} catch (PortalException e1) {
throw new GroupRetrievalFault("Group not existing", e1);
} catch (SystemException e) {
e.printStackTrace();
}
List<GCubeMembershipRequest> toReturn = new ArrayList<GCubeMembershipRequest>();
try {
int statusId = 0;
if (requestStatus == MembershipRequestStatus.APPROVED) {
statusId = 1;
}
else if (requestStatus == MembershipRequestStatus.DENIED) {
statusId = 2;
}
for (MembershipRequest req : MembershipRequestLocalServiceUtil.getMembershipRequests(userId, groupId, statusId)) {
toReturn.add(mapLRMembershipRequest(req));
}
} catch (SystemException e) {
e.printStackTrace();
} catch (PortalException e) {
e.printStackTrace();
}
return toReturn;
}
/* /*
* END MEMBERSHIP REQUESTS * END MEMBERSHIP REQUESTS
*/ */
@ -526,5 +590,5 @@ public class LiferayUserManager implements UserManager {
List<GCubeUser> toProcess = listUsers(); List<GCubeUser> toProcess = listUsers();
toProcess.removeAll(listUsersByGroup(groupId)); toProcess.removeAll(listUsersByGroup(groupId));
return toProcess; return toProcess;
} }
} }

View File

@ -4,9 +4,15 @@ import java.io.Serializable;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class GCubeRole implements Serializable { public class GCubeRole implements Serializable {
long roleId; private long roleId;
String roleName; private String roleName;
String description; private String description;
public final static String VRE_MANAGER_LABEL = "VRE-Manager";
public final static String VRE_DESIGNER_LABEL = "VRE-Designer";
public final static String VO_ADMIN_LABEL = "VRE-Designer";
public final static String INFRA_MANAGER_LABEL = "Infrastructure-Manager";
public final static String DATA_MANAGER_LABEL = "Data-Manager";
public GCubeRole(){ public GCubeRole(){