diff --git a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmCacheManager.java b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmCacheManager.java index ed5db84720..44308c3693 100755 --- a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmCacheManager.java +++ b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmCacheManager.java @@ -22,6 +22,7 @@ import org.jboss.logging.Logger; import org.keycloak.models.cache.infinispan.events.InvalidationEvent; import org.keycloak.models.cache.infinispan.entities.Revisioned; import org.keycloak.models.cache.infinispan.events.RealmCacheInvalidationEvent; +import org.keycloak.models.cache.infinispan.stream.GroupListPredicate; import org.keycloak.models.cache.infinispan.stream.HasRolePredicate; import org.keycloak.models.cache.infinispan.stream.InClientPredicate; import org.keycloak.models.cache.infinispan.stream.InRealmPredicate; @@ -72,8 +73,7 @@ public class RealmCacheManager extends CacheManager { } public void groupQueriesInvalidations(String realmId, Set invalidations) { - invalidations.add(RealmCacheSession.getGroupsQueryCacheKey(realmId)); - invalidations.add(RealmCacheSession.getTopGroupsQueryCacheKey(realmId)); // Just easier to always invalidate top-level too. It's not big performance penalty + addInvalidations(GroupListPredicate.create().realm(realmId), invalidations); } public void clientAdded(String realmId, String clientUUID, String clientId, Set invalidations) { diff --git a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/stream/GroupListPredicate.java b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/stream/GroupListPredicate.java new file mode 100755 index 0000000000..26562a5a81 --- /dev/null +++ b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/stream/GroupListPredicate.java @@ -0,0 +1,36 @@ +package org.keycloak.models.cache.infinispan.stream; + +import org.keycloak.models.cache.infinispan.entities.GroupListQuery; +import org.keycloak.models.cache.infinispan.entities.Revisioned; + +import java.io.Serializable; +import java.util.Map; +import java.util.function.Predicate; + +/** + * @author Bill Burke + * @version $Revision: 1 $ + */ +public class GroupListPredicate implements Predicate>, Serializable { + private String realm; + + public static GroupListPredicate create() { + return new GroupListPredicate(); + } + + public GroupListPredicate realm(String realm) { + this.realm = realm; + return this; + } + + @Override + public boolean test(Map.Entry entry) { + Object value = entry.getValue(); + if (value == null) return false; + if (value instanceof GroupListQuery) { + GroupListQuery groupList = (GroupListQuery)value; + if (groupList.getRealm().equals(realm)) return true; + } + return false; + } +} diff --git a/themes/src/main/resources/theme/base/admin/resources/js/app.js b/themes/src/main/resources/theme/base/admin/resources/js/app.js index 01ce2a5f4c..936b26bc08 100755 --- a/themes/src/main/resources/theme/base/admin/resources/js/app.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/app.js @@ -799,12 +799,6 @@ module.config([ '$routeProvider', function($routeProvider) { resolve : { realm : function(RealmLoader) { return RealmLoader(); - }, - groups : function(GroupListLoader) { - return GroupListLoader(); - }, - groupsCount : function(GroupCountLoader) { - return GroupCountLoader(); } }, controller : 'GroupListCtrl' diff --git a/themes/src/main/resources/theme/base/admin/resources/js/controllers/groups.js b/themes/src/main/resources/theme/base/admin/resources/js/controllers/groups.js index bc3691f9df..0a5652ca38 100755 --- a/themes/src/main/resources/theme/base/admin/resources/js/controllers/groups.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/controllers/groups.js @@ -1,25 +1,28 @@ -module.controller('GroupListCtrl', function($scope, $route, $q, realm, groups, groupsCount, Groups, GroupsCount, Group, GroupChildren, Notifications, $location, Dialog) { +module.controller('GroupListCtrl', function($scope, $route, $q, realm, Groups, GroupsCount, Group, GroupChildren, Notifications, $location, Dialog) { $scope.realm = realm; $scope.groupList = [ { "id" : "realm", "name": "Groups", - "subGroups" : groups + "subGroups" : [] } ]; + $scope.searchTerms = ''; $scope.currentPage = 1; $scope.currentPageInput = $scope.currentPage; - $scope.pageSize = groups.length; - $scope.numberOfPages = Math.ceil(groupsCount.count/$scope.pageSize); - + $scope.pageSize = 20; $scope.tree = []; var refreshGroups = function (search) { + console.log('refreshGroups'); + + var first = ($scope.currentPage * $scope.pageSize) - $scope.pageSize; + console.log('first:' + first); var queryParams = { realm : realm.id, - first : ($scope.currentPage * $scope.pageSize) - $scope.pageSize, + first : first, max : $scope.pageSize }; var countParams = { @@ -38,8 +41,9 @@ module.controller('GroupListCtrl', function($scope, $route, $q, realm, groups, g }, function() { promiseGetGroups.reject('Unable to fetch ' + queryParams); }); - var promiseGetGroupsChain = promiseGetGroups.promise.then(function(entry) { - groups = entry; + var promiseGetGroupsChain = promiseGetGroups.promise.then(function(groups) { + console.log('*** group call groups size: ' + groups.length); + console.log('*** group call groups size: ' + groups.length); $scope.groupList = [ { "id" : "realm", @@ -55,11 +59,11 @@ module.controller('GroupListCtrl', function($scope, $route, $q, realm, groups, g }, function() { promiseCount.reject('Unable to fetch ' + countParams); }); - var promiseCountChain = promiseCount.promise.then(function(entry) { - groupsCount = entry; + var promiseCountChain = promiseCount.promise.then(function(groupsCount) { $scope.numberOfPages = Math.ceil(groupsCount.count/$scope.pageSize); - }); + }); }; + refreshGroups(); $scope.$watch('currentPage', function(newValue, oldValue) { if(newValue !== oldValue) { diff --git a/themes/src/main/resources/theme/base/admin/resources/js/loaders.js b/themes/src/main/resources/theme/base/admin/resources/js/loaders.js index fb49c64f10..47bbc024b1 100755 --- a/themes/src/main/resources/theme/base/admin/resources/js/loaders.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/loaders.js @@ -490,9 +490,7 @@ module.factory('AuthenticationConfigLoader', function(Loader, AuthenticationConf module.factory('GroupListLoader', function(Loader, Groups, $route, $q) { return Loader.query(Groups, function() { return { - realm : $route.current.params.realm, - first : 0, - max : 20 + realm : $route.current.params.realm } }); });