true
or false
for filter only top level groups count
+ * @return The number of group containing search therm.
+ */
+ @GET
+ @NoCache
+ @Path("/count")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ Response count(@QueryParam("search") String search, @QueryParam("top") String onlyTopGroups);
+
/**
* create or add a top level realm groupSet or create child. This will update the group and set the parent if it exists. Create it and set the parent
* if the group doesn't exist.
diff --git a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmAdapter.java b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmAdapter.java
index af7159cad6..7144c3b474 100755
--- a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmAdapter.java
+++ b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmAdapter.java
@@ -1213,8 +1213,8 @@ public class RealmAdapter implements CachedRealmModel {
}
@Override
- public Long getGroupsCount() {
- return cacheSession.getGroupsCount(this);
+ public Long getGroupsCount(Boolean onlyTopGroups) {
+ return cacheSession.getGroupsCount(this, onlyTopGroups);
}
@Override
diff --git a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmCacheSession.java b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmCacheSession.java
index 77f8981ed1..bcff0ba591 100755
--- a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmCacheSession.java
+++ b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/RealmCacheSession.java
@@ -843,8 +843,8 @@ public class RealmCacheSession implements CacheRealmProvider {
}
@Override
- public Long getGroupsCount(RealmModel realm) {
- return getDelegate().getGroupsCount(realm);
+ public Long getGroupsCount(RealmModel realm, Boolean onlyTopGroups) {
+ return getDelegate().getGroupsCount(realm, onlyTopGroups);
}
@Override
diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java b/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java
index b64a6a6624..2e15fd04af 100755
--- a/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java
+++ b/model/jpa/src/main/java/org/keycloak/models/jpa/JpaRealmProvider.java
@@ -17,6 +17,7 @@
package org.keycloak.models.jpa;
+import com.sun.org.apache.xpath.internal.operations.Bool;
import org.jboss.logging.Logger;
import org.keycloak.common.util.Time;
import org.keycloak.connections.jpa.util.JpaUtils;
@@ -339,8 +340,12 @@ public class JpaRealmProvider implements RealmProvider {
}
@Override
- public Long getGroupsCount(RealmModel realm) {
- Long count = em.createNamedQuery("getGroupCount", Long.class)
+ public Long getGroupsCount(RealmModel realm, Boolean onlyTopGroups) {
+ String query = "getGroupCount";
+ if(Objects.equals(onlyTopGroups, Boolean.TRUE)) {
+ query = "getTopLevelGroupCount";
+ }
+ Long count = em.createNamedQuery(query, Long.class)
.setParameter("realm", realm.getId())
.getSingleResult();
@@ -577,7 +582,7 @@ public class JpaRealmProvider implements RealmProvider {
@Override
public List
-
-
-
-
-
-
-
-
-
- |
- ||||||
---|---|---|---|---|---|---|
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
-
-
- |