added indexed and non indexed versions for listUsers and listUsersByGroup

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@141428 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-12-29 15:43:57 +00:00
parent 27bac2af8c
commit d28f3ccea6
2 changed files with 62 additions and 6 deletions

View File

@ -187,10 +187,17 @@ public interface UserManager {
/** /**
* *
* @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 * @return 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 * @throws UserManagementSystemException
*/ */
List<GCubeUser> listUsers() throws UserManagementSystemException; List<GCubeUser> listUsers() throws UserManagementSystemException;
/**
* @param indexed set to true to use the indexed version search false for a real time query to the DB.
* @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<GCubeUser> listUsers(boolean indexed) throws UserManagementSystemException;
/** /**
* *
* @param groupId the LR groupId * @param groupId the LR groupId
@ -200,6 +207,16 @@ public interface UserManager {
* @throws UserRetrievalFault * @throws UserRetrievalFault
*/ */
List<GCubeUser> listUsersByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault; List<GCubeUser> listUsersByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
/**
* @param groupId the LR groupId
* @param indexed set to true to use the indexed version search false for a real time query to the DB.
*
* @returna list of all portal active users belonging to the given groupid
* @throws UserManagementSystemException .
* @throws GroupRetrievalFault .
* @throws UserRetrievalFault .
*/
List<GCubeUser> listUsersByGroup(long groupId, boolean indexed) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
/** /**
* *
* @param the name of the VO or VRE (e.g. devVRE, or gcube etc.) * @param the name of the VO or VRE (e.g. devVRE, or gcube etc.)

View File

@ -532,7 +532,10 @@ public class LiferayUserManager implements UserManager {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public List<GCubeUser> listUsers() throws UserManagementSystemException { public List<GCubeUser> listUsers(boolean indexed) throws UserManagementSystemException {
if (indexed)
return listUsers();
_log.debug("Asked for listUsers non indexed");
List<GCubeUser> toReturn = new ArrayList<GCubeUser>(); List<GCubeUser> toReturn = new ArrayList<GCubeUser>();
try { try {
OrderByComparator comparator = OrderByComparatorFactoryUtil.create("User_", "screenname", true); OrderByComparator comparator = OrderByComparatorFactoryUtil.create("User_", "screenname", true);
@ -552,8 +555,47 @@ public class LiferayUserManager implements UserManager {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public List<GCubeUser> listUsers() throws UserManagementSystemException {
List<GCubeUser> toReturn = new ArrayList<GCubeUser>();
try {
List<User> lrUsers = UserLocalServiceUtil.getUsers(QueryUtil.ALL_POS, QueryUtil.ALL_POS);
for (User user : lrUsers) {
if (user.isActive())
toReturn.add(mapLRUser(user));
}
} catch (SystemException e) {
throw new UserManagementSystemException(e.getMessage(), e);
} catch (PortalException e) {
e.printStackTrace();
}
return toReturn;
}
/**
* {@inheritDoc}
*/
@Override
public List<GCubeUser> listUsersByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault { public List<GCubeUser> listUsersByGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault {
List<GCubeUser> toReturn = new ArrayList<GCubeUser>(); List<GCubeUser> toReturn = new ArrayList<GCubeUser>();
try {
for (User user : UserLocalServiceUtil.getGroupUsers(groupId)) {
if (user.isActive())
toReturn.add(mapLRUser(user));
}
} catch (PortalException e) {
e.printStackTrace();
} catch (SystemException e) {
e.printStackTrace();
}
return toReturn;
}
/**
* {@inheritDoc}
*/
@Override
public List<GCubeUser> listUsersByGroup(long groupId, boolean indexed) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault {
if (indexed)
return listUsersByGroup(groupId);
List<GCubeUser> toReturn = new ArrayList<GCubeUser>();
try { try {
OrderByComparator comparator = OrderByComparatorFactoryUtil.create("User_", "screenname", true); OrderByComparator comparator = OrderByComparatorFactoryUtil.create("User_", "screenname", true);
LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>(); LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>();
@ -596,10 +638,7 @@ public class LiferayUserManager implements UserManager {
Group g = GroupLocalServiceUtil.getGroup(groupId); Group g = GroupLocalServiceUtil.getGroup(groupId);
_log.debug("Asked for users and roles of group: "+g.getName()); _log.debug("Asked for users and roles of group: "+g.getName());
OrderByComparator comparator = OrderByComparatorFactoryUtil.create("User_", "screenname", true); List<User> usersByGroup = UserLocalServiceUtil.getGroupUsers(groupId);
LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>();
params.put("usersGroups", groupId);
List<User> usersByGroup = UserLocalServiceUtil.search(ManagementUtils.getCompany().getCompanyId(), "", 0, params, QueryUtil.ALL_POS, QueryUtil.ALL_POS, comparator);
for (User user : usersByGroup) { for (User user : usersByGroup) {
if (user.isActive()) { if (user.isActive()) {