org.keycloak.models.map.group

## Class MapGroupProvider

- java.lang.Object
- - org.keycloak.models.map.group.MapGroupProvider

- All Implemented Interfaces:
    GroupProvider, Provider, GroupLookupProvider

      public class MapGroupProvider
      extends Object
      implements GroupProvider

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MapGroupProvider(KeycloakSession session, MapStorage<UUID,MapGroupEntity> groupStore)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addTopLevelGroup(RealmModel realm, GroupModel subGroup)` Removes parent group for the given group in the given realm.
    `void` | `close()`
    `GroupModel` | `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.
    `GroupModel` | `getGroupById(RealmModel realm, String id)` Returns a group from the given realm with the corresponding id
    `Stream<GroupModel>` | `getGroupsByRoleStream(RealmModel realm, RoleModel role, Integer firstResult, Integer maxResults)` Returns groups with the given role in the given realm.
    `Long` | `getGroupsCount(RealmModel realm, Boolean onlyTopGroups)` Returns a number of groups/top level groups (i.e.
    `Long` | `getGroupsCountByNameContaining(RealmModel realm, String search)` Returns number of groups with the given string in name for the given realm.
    `Stream<GroupModel>` | `getGroupsStream(RealmModel realm)` Returns groups for the given realm.
    `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.
    `void` | `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.
    `void` | `preRemove(RealmModel realm, RoleModel role)` This function is called when a role is removed; this serves for removing references from groups to roles.
    `boolean` | `removeGroup(RealmModel realm, GroupModel group)` Removes the given group for the given realm.
    `Stream<GroupModel>` | `searchForGroupByNameStream(RealmModel realm, String search, Integer firstResult, Integer maxResults)` Returns groups with the given string in name for the given realm.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.keycloak.models.GroupProvider

      `createGroup, createGroup, createGroup, getGroupById, getGroups, getGroupsByRole, getGroupsCount, getGroupsStream, getGroupsStream, getTopLevelGroups, getTopLevelGroups`

    - ### Methods inherited from interface org.keycloak.storage.group.GroupLookupProvider

      `searchForGroupByName`

- - ### Constructor Detail

    - #### MapGroupProvider

          public MapGroupProvider(KeycloakSession session,
                                  MapStorage<UUID,MapGroupEntity> groupStore)

  - ### Method Detail

    - #### getGroupById

          public GroupModel getGroupById(RealmModel realm,
                                         String id)

      Description copied from interface: `GroupLookupProvider`
      Returns a group from the given realm with the corresponding id
      Specified by:
        `getGroupById` in interface `GroupLookupProvider`
      Parameters:
        `realm` - Realm.
        `id` - Id.
      Returns:
        GroupModel with the corresponding id.

    - #### getGroupsStream

          public Stream<GroupModel> getGroupsStream(RealmModel realm)

      Description copied from interface: `GroupProvider`
      Returns groups for the given realm.
      Specified by:
        `getGroupsStream` in interface `GroupProvider`
      Parameters:
        `realm` - Realm.
      Returns:
        Stream of groups in the Realm.

    - #### getGroupsStream

          public Stream<GroupModel> getGroupsStream(RealmModel realm,
                                                    Stream<String> ids,
                                                    String search,
                                                    Integer first,
                                                    Integer max)

      Description copied from interface: `GroupProvider`
      Returns a paginated stream of groups with given ids and given search value in group names.
      Specified by:
        `getGroupsStream` in interface `GroupProvider`
      Parameters:
        `realm` - Realm.
        `ids` - List 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:
        List of desired groups.

    - #### getGroupsCount

          public Long getGroupsCount(RealmModel realm,
                                     Boolean onlyTopGroups)

      Description copied from interface: `GroupProvider`
      Returns a number of groups/top level groups (i.e. groups without parent group) for the given realm.
      Specified by:
        `getGroupsCount` in interface `GroupProvider`
      Parameters:
        `realm` - Realm.
        `onlyTopGroups` - When true the function returns a count of top level groups only.
      Returns:
        Number of groups/top level groups.

    - #### getGroupsCountByNameContaining

          public Long getGroupsCountByNameContaining(RealmModel realm,
                                                     String search)

      Description copied from interface: `GroupProvider`
      Returns number of groups with the given string in name for the given realm.
      Specified by:
        `getGroupsCountByNameContaining` in interface `GroupProvider`
      Parameters:
        `realm` - Realm.
        `search` - Case insensitive string which will be searched for.
      Returns:
        Number of groups with the given string in its name.

    - #### getGroupsByRoleStream

          public Stream<GroupModel> getGroupsByRoleStream(RealmModel realm,
                                                          RoleModel role,
                                                          Integer firstResult,
                                                          Integer maxResults)

      Description copied from interface: `GroupProvider`
      Returns groups with the given role in the given realm.
      Specified by:
        `getGroupsByRoleStream` in interface `GroupProvider`
      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.

    - #### getTopLevelGroupsStream

          public Stream<GroupModel> getTopLevelGroupsStream(RealmModel realm)

      Description copied from interface: `GroupProvider`
      Returns all top level groups (i.e. groups without parent group) for the given realm.
      Specified by:
        `getTopLevelGroupsStream` in interface `GroupProvider`
      Parameters:
        `realm` - Realm.
      Returns:
        Stream of all top level groups in the realm.

    - #### getTopLevelGroupsStream

          public Stream<GroupModel> getTopLevelGroupsStream(RealmModel realm,
                                                            Integer firstResult,
                                                            Integer maxResults)

      Description copied from interface: `GroupProvider`
      Returns top level groups (i.e. groups without parent group) for the given realm.
      Specified by:
        `getTopLevelGroupsStream` in interface `GroupProvider`
      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.

    - #### searchForGroupByNameStream

          public Stream<GroupModel> searchForGroupByNameStream(RealmModel realm,
                                                               String search,
                                                               Integer firstResult,
                                                               Integer maxResults)

      Description copied from interface: `GroupLookupProvider`
      Returns groups with the given string in name for the given realm.
      Specified by:
        `searchForGroupByNameStream` in interface `GroupLookupProvider`
      Parameters:
        `realm` - Realm.
        `search` - Case sensitive searched string.
        `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 string in name.

    - #### createGroup

          public GroupModel createGroup(RealmModel realm,
                                        String id,
                                        String name,
                                        GroupModel toParent)

      Description copied from interface: `GroupProvider`
      Creates a new group with the given name, id, name and parent to the given realm.
      Specified by:
        `createGroup` in interface `GroupProvider`
      Parameters:
        `realm` - Realm.
        `id` - Id, will be generated if `null`.
        `name` - Name.
        `toParent` - Parent group, or `null` if the group is top level group
      Returns:
        Model of the created group

    - #### removeGroup

          public boolean removeGroup(RealmModel realm,
                                     GroupModel group)

      Description copied from interface: `GroupProvider`
      Removes the given group for the given realm.
      Specified by:
        `removeGroup` in interface `GroupProvider`
      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

    - #### moveGroup

          public void moveGroup(RealmModel realm,
                                GroupModel group,
                                GroupModel toParent)

      Description copied from interface: `GroupProvider`
      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).
      Specified by:
        `moveGroup` in interface `GroupProvider`
      Parameters:
        `realm` - Realm owning this group.
        `group` - Group to update.
        `toParent` - New parent group, or `null` if we are moving the group to top level group.

    - #### addTopLevelGroup

          public void addTopLevelGroup(RealmModel realm,
                                       GroupModel subGroup)

      Description copied from interface: `GroupProvider`
      Removes parent group for the given group in the given realm.
      Specified by:
        `addTopLevelGroup` in interface `GroupProvider`
      Parameters:
        `realm` - Realm.
        `subGroup` - Group.

    - #### preRemove

          public void preRemove(RealmModel realm,
                                RoleModel role)

      Description copied from interface: `GroupProvider`
      This function is called when a role is removed; this serves for removing references from groups to roles.
      Specified by:
        `preRemove` in interface `GroupProvider`
      Parameters:
        `realm` - Realm.
        `role` - Role which will be removed.

    - #### close

          public void close()

      Specified by:
        `close` in interface `Provider`

Copyright © 2020 JBoss by Red Hat. All rights reserved.