You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2017/08/03 16:01:30 UTC
[14/50] [abbrv] airavata git commit: AIRAVATA-2405 Search only most
recent users for role
AIRAVATA-2405 Search only most recent users for role
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/45bbc256
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/45bbc256
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/45bbc256
Branch: refs/heads/master
Commit: 45bbc256e4bc480e44b1901ce1a959074e621447
Parents: a8e99e8
Author: Marcus Christie <ma...@apache.org>
Authored: Sat Jul 8 22:27:32 2017 -0500
Committer: Marcus Christie <ma...@apache.org>
Committed: Sat Jul 8 22:27:32 2017 -0500
----------------------------------------------------------------------
.../services/core/impl/TenantManagementKeycloakImpl.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/45bbc256/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
----------------------------------------------------------------------
diff --git a/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java b/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
index 20d41f5..91c0f4e 100644
--- a/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
+++ b/airavata-services/profile-service/iam-admin-services-core/src/main/java/org/apache/airavata/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
@@ -534,15 +534,18 @@ public class TenantManagementKeycloakImpl implements TenantManagementInterface {
Keycloak client = null;
try{
client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, realmAdminCreds);
- // FIXME: this only gets the first 1000 users to search through for the given role
+ // FIXME: this only searches through the most recent 100 users for the given role (assuming there are no more than 10,000 users in the gateway)
List<UserRepresentation> allUsers = client.realm(tenantId).users().search(null,
null,
null,
null,
- 0, 1000);
+ 0, 10000);
+ allUsers.sort((a, b) -> a.getCreatedTimestamp() - b.getCreatedTimestamp() > 0 ? -1 : 1);
+ // The 100 most recently created users
+ List<UserRepresentation> mostRecentUsers = allUsers.subList(0, Math.min(allUsers.size(), 100));
List<UserProfile> usersWithRole = new ArrayList<>();
- for (UserRepresentation user: allUsers) {
+ for (UserRepresentation user: mostRecentUsers) {
UserResource userResource = client.realm(tenantId).users().get(user.getId());
List<RoleRepresentation> roleRepresentations = userResource.roles().realmLevel().listAll();