Added getRandomAdmin user method
This commit is contained in:
parent
951ed583bd
commit
6a40c1cd8b
|
@ -363,6 +363,14 @@ public interface UserManager {
|
|||
* @throws UserRetrievalFault
|
||||
*/
|
||||
List<GCubeUser> listUsersByGroupAndRole(long groupId, long roleId) throws UserManagementSystemException, RoleRetrievalFault, GroupRetrievalFault, UserRetrievalFault;
|
||||
/**
|
||||
*
|
||||
* @param groupId
|
||||
* @param roleId
|
||||
* @return the list of userId having group and role that matches
|
||||
*/
|
||||
long[] listUserIdsByGroupAndRole(long groupId, long roleId);
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* @parmam teamId the LR teamId
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
|||
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.GatewayRolesNames;
|
||||
import org.gcube.vomanagement.usermanagement.model.MembershipRequestStatus;
|
||||
import org.gcube.vomanagement.usermanagement.util.ManagementUtils;
|
||||
|
||||
|
@ -96,6 +97,31 @@ public class LiferayUserManager implements UserManager {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param contextGroupId
|
||||
* @param gatewayRole
|
||||
* @return the User if a user having the role exists in the Site group (Gateway, VO or VRE)
|
||||
*/
|
||||
public static User getRandomUserWithRole(long contextGroupId, GatewayRolesNames gatewayRole) {
|
||||
final long companyId = PortalUtil.getDefaultCompanyId();
|
||||
try {
|
||||
Role theRole = RoleLocalServiceUtil.getRole(companyId, gatewayRole.getRoleName()) ;
|
||||
if (theRole == null) {
|
||||
_log.warn("No user has the role with this groupId " + gatewayRole.getRoleName() + ":" + contextGroupId);
|
||||
return null;
|
||||
}
|
||||
List<UserGroupRole> list = UserGroupRoleLocalServiceUtil.getUserGroupRolesByGroupAndRole(contextGroupId, theRole.getRoleId());
|
||||
for (UserGroupRole userGroupRole : list) {
|
||||
User admin = userGroupRole.getUser();
|
||||
if (admin.isActive())
|
||||
return admin;
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
_log.error("Utils::getInfrastructureManager Exception", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static Role getRoleById(final long companyId, final String roleStrId) {
|
||||
try {
|
||||
return RoleLocalServiceUtil.getRole(companyId, roleStrId);
|
||||
|
@ -770,6 +796,25 @@ public class LiferayUserManager implements UserManager {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public long[] listUserIdsByGroupAndRole(long groupId, long roleId) {
|
||||
List<UserGroupRole> listTriplet = null;
|
||||
try {
|
||||
listTriplet = UserGroupRoleLocalServiceUtil.getUserGroupRolesByGroupAndRole(groupId, roleId);
|
||||
} catch (SystemException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
long[] toReturn = new long[listTriplet.size()];
|
||||
int i = 0;
|
||||
for (UserGroupRole userGroupRole : listTriplet) {
|
||||
toReturn[i] = userGroupRole.getUserId();
|
||||
i++;
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<GCubeUser> listUsersByTeam(long teamId) throws UserManagementSystemException, TeamRetrievalFault, UserRetrievalFault {
|
||||
List<GCubeUser> toReturn = new ArrayList<GCubeUser>();
|
||||
Team askedTeam = null;
|
||||
|
|
|
@ -820,4 +820,10 @@ public class LiferayWSUserManager implements UserManager{
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long[] listUserIdsByGroupAndRole(long groupId, long roleId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue