Calling getTopLevelGroups is slow inside GroupLDAPStorageMapper#getLDAPGroupMappingsConverted (#8430)

Closes #14820 
---------
Co-authored-by: Michal Hajas <mhajas@redhat.com>
This commit is contained in:
Bernd Bohmann
2023-09-20 17:20:43 +02:00
committed by GitHub
parent f8a9e0134a
commit bb2f59df87
20 changed files with 471 additions and 42 deletions

View File

@@ -93,6 +93,28 @@ public class MapGroupProvider implements GroupProvider {
: entityToAdapterFunc(realm).apply(entity);
}
@Override
public GroupModel getGroupByName(RealmModel realm, GroupModel parent, String name) {
if (name == null) {
return null;
}
LOG.tracef("getGroupByName(%s, %s)%s", realm, name, getShortStackTrace());
DefaultModelCriteria<GroupModel> mcb = criteria();
mcb = mcb.compare(SearchableFields.NAME, Operator.EQ, name)
.compare(SearchableFields.REALM_ID, Operator.EQ, realm.getId());
if (parent != null) {
mcb = mcb.compare(SearchableFields.PARENT_ID, Operator.EQ, parent.getId());
} else {
mcb = mcb.compare(SearchableFields.PARENT_ID, Operator.NOT_EXISTS);
}
QueryParameters<GroupModel> queryParameters = withCriteria(mcb);
String groupId = storeWithRealm(realm).read(queryParameters).findFirst().map(MapGroupEntity::getId)
.orElse(null);
return groupId == null ? null : session.groups().getGroupById(realm, groupId);
}
@Override
public Stream<GroupModel> getGroupsStream(RealmModel realm) {
return getGroupsStreamInternal(realm, null, null);