org.keycloak.partialimport

## Class RolesPartialImport

- java.lang.Object
- - org.keycloak.partialimport.RolesPartialImport

- All Implemented Interfaces:
    PartialImport<RolesRepresentation>

      public class RolesPartialImport
      extends Object
      implements PartialImport<RolesRepresentation>

  This class handles both realm roles and client roles. It delegates to RealmRolesPartialImport and ClientRolesPartialImport, which are no longer used directly by the PartialImportManager. The strategy is to utilize RepresentationToModel.importRoles(). That way, the complex code for bulk creation of roles is kept in one place. To do this, the logic for skip needs to remove the roles that are going to be skipped so that importRoles() doesn't know about them. The logic for overwrite needs to delete the overwritten roles before importRoles() is called.
  Author:
    Stan Silvert ssilvert@redhat.com (C) 2016 Red Hat Inc.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RolesPartialImport()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `PartialImportResults` | `doImport(PartialImportRepresentation rep, RealmModel realm, KeycloakSession session)` Create (or re-create) all the imported resources.
    `void` | `prepare(PartialImportRepresentation rep, RealmModel realm, KeycloakSession session)` Find which resources will need to be skipped or overwritten.
    `void` | `removeOverwrites(RealmModel realm, KeycloakSession session)` Delete resources that will be overwritten.

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

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

- - ### Constructor Detail

    - #### RolesPartialImport

          public RolesPartialImport()

  - ### Method Detail

    - #### prepare

          public void prepare(PartialImportRepresentation rep,
                              RealmModel realm,
                              KeycloakSession session)
                       throws ErrorResponseException

      Description copied from interface: `PartialImport`
      Find which resources will need to be skipped or overwritten. Also, do a preliminary check for errors.
      Specified by:
        `prepare` in interface `PartialImport<RolesRepresentation>`
      Parameters:
        `rep` - Everything in the PartialImport request.
        `realm` - Realm to be imported into.
        `session` - The KeycloakSession.
      Throws:
        `ErrorResponseException` - If the PartialImport can not be performed, throw this exception.

    - #### removeOverwrites

          public void removeOverwrites(RealmModel realm,
                                       KeycloakSession session)

      Description copied from interface: `PartialImport`
      Delete resources that will be overwritten. This is done separately so that it can be called for all resource types before calling all the doImports. It was found that doing delete/add per resource causes errors because of cascading deletes.
      Specified by:
        `removeOverwrites` in interface `PartialImport<RolesRepresentation>`
      Parameters:
        `realm` - Realm to be imported into.
        `session` - The KeycloakSession

    - #### doImport

          public PartialImportResults doImport(PartialImportRepresentation rep,
                                               RealmModel realm,
                                               KeycloakSession session)
                                        throws ErrorResponseException

      Description copied from interface: `PartialImport`
      Create (or re-create) all the imported resources.
      Specified by:
        `doImport` in interface `PartialImport<RolesRepresentation>`
      Parameters:
        `rep` - Everything in the PartialImport request.
        `realm` - Realm to be imported into.
        `session` - The KeycloakSession.
      Returns:
        The final results of the PartialImport request.
      Throws:
        `ErrorResponseException` - if an error was detected trying to doImport a resource.

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