Package org.keycloak.models
Interface GroupProvider
- 
- All Superinterfaces:
- GroupLookupProvider,- Provider
 - All Known Subinterfaces:
- CacheRealmProvider,- RealmProvider
 - All Known Implementing Classes:
- GroupStorageManager,- JpaRealmProvider,- MapGroupProvider,- MapRealmProvider,- RealmCacheSession
 
 public interface GroupProvider extends Provider, GroupLookupProvider Provider of group records- Author:
- mhajas
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddTopLevelGroup(RealmModel realm, GroupModel subGroup)Removes parent group for the given group in the given realm.default GroupModelcreateGroup(RealmModel realm, String name)Creates a new group with the given name in the given realm.default GroupModelcreateGroup(RealmModel realm, String id, String name)Creates a new group with the given id and name in the given realm.GroupModelcreateGroup(RealmModel realm, String id, String name, GroupModel toParent)Creates a new group with the given name, id, name and parent to the given realm.default GroupModelcreateGroup(RealmModel realm, String name, GroupModel toParent)Creates a new group with the given name and parent to the given realm.Stream<GroupModel>getGroupsByRoleStream(RealmModel realm, RoleModel role, Integer firstResult, Integer maxResults)Returns groups with the given role in the given realm.LonggetGroupsCount(RealmModel realm, Boolean onlyTopGroups)Returns a number of groups/top level groups (i.e.default LonggetGroupsCount(RealmModel realm, Stream<String> ids, String search)Returns a number of groups that contains the search string in the nameLonggetGroupsCountByNameContaining(RealmModel realm, String search)Returns the number of top level groups containing groups with the given string in name for the given realm.Stream<GroupModel>getGroupsStream(RealmModel realm)Returns groups for the given realm.default Stream<GroupModel>getGroupsStream(RealmModel realm, Stream<String> ids)Returns a stream of groups with given ids.default Stream<GroupModel>getGroupsStream(RealmModel realm, Stream<String> ids, Integer first, Integer max)Returns a paginated stream of groups with given ids.Stream<GroupModel>getGroupsStream(RealmModel realm, Stream<String> ids, String search, Integer first, Integer max)Returns a paginated stream of groups with given ids and given search value in group names.Stream<GroupModel>getTopLevelGroupsStream(RealmModel realm)Returns all top level groups (i.e.Stream<GroupModel>getTopLevelGroupsStream(RealmModel realm, Integer firstResult, Integer maxResults)Returns top level groups (i.e.voidmoveGroup(RealmModel realm, GroupModel group, GroupModel toParent)This method is used for moving groups in group structure, for example: making an existing child group child group of some other group, setting a top level group (i.e.booleanremoveGroup(RealmModel realm, GroupModel group)Removes the given group for the given realm.- 
Methods inherited from interface org.keycloak.storage.group.GroupLookupProvidergetGroupById, searchForGroupByNameStream, searchForGroupByNameStream, searchGroupsByAttributes
 
- 
 
- 
- 
- 
Method Detail- 
getGroupsStreamStream<GroupModel> getGroupsStream(RealmModel realm) Returns groups for the given realm.- Parameters:
- realm- Realm.
- Returns:
- Stream of groups in the Realm.
 
 - 
getGroupsStreamdefault Stream<GroupModel> getGroupsStream(RealmModel realm, Stream<String> ids) Returns a stream of groups with given ids. Effectively the same asgetGroupsStream(realm, ids, null, null, null).- Parameters:
- realm- Realm.
- ids- Stream of ids.
- Returns:
- Stream of GroupModels with the specified ids
 
 - 
getGroupsStreamStream<GroupModel> getGroupsStream(RealmModel realm, Stream<String> ids, String search, Integer first, Integer max) Returns a paginated stream of groups with given ids and given search value in group names.- Parameters:
- realm- Realm.
- ids- Stream of ids.
- search- Case insensitive string which will be searched for. Ignored if null.
- first- Index of the first result to return. Ignored if negative or- null.
- max- Maximum number of results to return. Ignored if negative or- null.
- Returns:
- Stream of desired groups. Never returns null.
 
 - 
getGroupsStreamdefault Stream<GroupModel> getGroupsStream(RealmModel realm, Stream<String> ids, Integer first, Integer max) Returns a paginated stream of groups with given ids. Effectively the same asgetGroupsStream(realm, ids, null, first, max).- Parameters:
- realm- Realm.
- ids- Stream of ids.
- first- Index of the first result to return. Ignored if negative or- null.
- max- Maximum number of results to return. Ignored if negative or- null.
- Returns:
- Stream of GroupModels with the specified ids
 
 - 
getGroupsCountdefault Long getGroupsCount(RealmModel realm, Stream<String> ids, String search) Returns a number of groups that contains the search string in the name- Parameters:
- realm- Realm.
- ids- List of ids.
- search- Case insensitive string which will be searched for. Ignored if null.
- Returns:
- Number of groups.
 
 - 
getGroupsCountLong getGroupsCount(RealmModel realm, Boolean onlyTopGroups) Returns a number of groups/top level groups (i.e. groups without parent group) for the given realm.- Parameters:
- realm- Realm.
- onlyTopGroups- When true the function returns a count of top level groups only.
- Returns:
- Number of groups/top level groups.
 
 - 
getGroupsCountByNameContainingLong getGroupsCountByNameContaining(RealmModel realm, String search) Returns the number of top level groups containing groups with the given string in name for the given realm.- Parameters:
- realm- Realm.
- search- Case insensitive string which will be searched for.
- Returns:
- Number of groups with the given string in its name.
 
 - 
getGroupsByRoleStreamStream<GroupModel> getGroupsByRoleStream(RealmModel realm, RoleModel role, Integer firstResult, Integer maxResults) Returns groups with the given role in the given realm.- Parameters:
- realm- Realm.
- role- Role.
- firstResult- First result to return. Ignored if negative or- null.
- maxResults- Maximum number of results to return. Ignored if negative or- null.
- Returns:
- Stream of groups with the given role. Never returns null.
 
 - 
getTopLevelGroupsStreamStream<GroupModel> getTopLevelGroupsStream(RealmModel realm) Returns all top level groups (i.e. groups without parent group) for the given realm.- Parameters:
- realm- Realm.
- Returns:
- Stream of all top level groups in the realm. Never returns null.
 
 - 
getTopLevelGroupsStreamStream<GroupModel> getTopLevelGroupsStream(RealmModel realm, Integer firstResult, Integer maxResults) Returns top level groups (i.e. groups without parent group) for the given realm.- Parameters:
- realm- Realm.
- firstResult- First result to return. Ignored if negative or- null.
- maxResults- Maximum number of results to return. Ignored if negative or- null.
- Returns:
- Stream of top level groups in the realm. Never returns null.
 
 - 
createGroupdefault GroupModel createGroup(RealmModel realm, String name) Creates a new group with the given name in the given realm. Effectively the same ascreateGroup(realm, null, name, null).- Parameters:
- realm- Realm.
- name- Name.
- Returns:
- Model of the created group.
- Throws:
- ModelDuplicateException- If there is already a top-level group with the given name
 
 - 
createGroupdefault GroupModel createGroup(RealmModel realm, String id, String name) Creates a new group with the given id and name in the given realm. Effectively the same ascreateGroup(realm, id, name, null)- Parameters:
- realm- Realm.
- id- Id.
- name- Name.
- Returns:
- Model of the created group
- Throws:
- ModelDuplicateException- If a group with given id already exists or there is a top-level group with the given name
 
 - 
createGroupdefault GroupModel createGroup(RealmModel realm, String name, GroupModel toParent) Creates a new group with the given name and parent to the given realm. Effectively the same ascreateGroup(realm, null, name, toParent).- Parameters:
- realm- Realm.
- name- Name.
- toParent- Parent group.
- Returns:
- Model of the created group.
- Throws:
- ModelDuplicateException- If the toParent group already has a subgroup with the given name
 
 - 
createGroupGroupModel createGroup(RealmModel realm, String id, String name, GroupModel toParent) Creates a new group with the given name, id, name and parent to the given realm.- Parameters:
- realm- Realm.
- id- Id, will be generated if- null.
- name- Name.
- toParent- Parent group, or- nullif the group is top level group
- Returns:
- Model of the created group
- Throws:
- ModelDuplicateException- If a group with the given id already exists or the toParent group has a subgroup with the given name
 
 - 
removeGroupboolean removeGroup(RealmModel realm, GroupModel group) Removes the given group for the given realm.- Parameters:
- realm- Realm.
- group- Group.
- Returns:
- true if the group was removed, false if group doesn't exist or doesn't belong to the given realm
 
 - 
moveGroupvoid moveGroup(RealmModel realm, GroupModel group, GroupModel toParent) This method is used for moving groups in group structure, for example:- making an existing child group child group of some other group,
- setting a top level group (i.e. group without parent group) child of some group,
- making a child group top level group (i.e. removing its parent group).
 - Parameters:
- realm- Realm owning this group.
- group- Group to update.
- toParent- New parent group, or- nullif we are moving the group to top level group.
- Throws:
- ModelDuplicateException- If there is already a group with group.name under the toParent group (or top-level if toParent is null)
 
 - 
addTopLevelGroupvoid addTopLevelGroup(RealmModel realm, GroupModel subGroup) Removes parent group for the given group in the given realm.- Parameters:
- realm- Realm.
- subGroup- Group.
- Throws:
- ModelDuplicateException- If there is already a top level group name with the same name
 
 
- 
 
-