improved performance for method for getting listUsersByGroupAndRole
This commit is contained in:
parent
685556861d
commit
951ed583bd
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
|||
</parent>
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
<version>2.4.2-SNAPSHOT</version>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>User Management API</name>
|
||||
|
|
|
@ -45,6 +45,7 @@ import com.liferay.portal.model.Role;
|
|||
import com.liferay.portal.model.RoleConstants;
|
||||
import com.liferay.portal.model.Team;
|
||||
import com.liferay.portal.model.User;
|
||||
import com.liferay.portal.model.UserGroupRole;
|
||||
import com.liferay.portal.security.auth.PrincipalThreadLocal;
|
||||
import com.liferay.portal.security.permission.PermissionChecker;
|
||||
import com.liferay.portal.security.permission.PermissionCheckerFactoryUtil;
|
||||
|
@ -57,6 +58,7 @@ import com.liferay.portal.service.RoleLocalServiceUtil;
|
|||
import com.liferay.portal.service.RoleServiceUtil;
|
||||
import com.liferay.portal.service.ServiceContext;
|
||||
import com.liferay.portal.service.TeamLocalServiceUtil;
|
||||
import com.liferay.portal.service.UserGroupRoleLocalServiceUtil;
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
import com.liferay.portal.util.PortalUtil;
|
||||
import com.liferay.portal.webserver.WebServerServletTokenUtil;
|
||||
|
@ -753,24 +755,15 @@ public class LiferayUserManager implements UserManager {
|
|||
*/
|
||||
@Override
|
||||
public List<GCubeUser> listUsersByGroupAndRole(long groupId, long roleId) throws UserManagementSystemException, RoleRetrievalFault, GroupRetrievalFault, UserRetrievalFault {
|
||||
Map<GCubeUser, List<GCubeRole>> toIterate = listUsersAndRolesByGroup(groupId);
|
||||
List<GCubeUser> toReturn = new ArrayList<GCubeUser>();
|
||||
Role askedRole = null;
|
||||
try {
|
||||
askedRole = RoleServiceUtil.getRole(roleId);
|
||||
} catch (PortalException e) {
|
||||
throw new RoleRetrievalFault("Role not existing (I think you better check) roleId="+roleId, e);
|
||||
} catch (SystemException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
_log.debug("Asked for role: "+askedRole.getName());
|
||||
for (GCubeUser u : toIterate.keySet()) {
|
||||
for (GCubeRole role : toIterate.get(u))
|
||||
if (role.getRoleId() == roleId) {
|
||||
toReturn.add(u);
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<UserGroupRole> listTriplet = UserGroupRoleLocalServiceUtil.getUserGroupRolesByGroupAndRole(groupId, roleId);
|
||||
for (UserGroupRole userGroupRole : listTriplet) {
|
||||
toReturn.add(getUserById(userGroupRole.getUserId()));
|
||||
}
|
||||
} catch (SystemException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue