org.keycloak.partialimport

## Class AbstractPartialImport<T>

- java.lang.Object
- - org.keycloak.partialimport.AbstractPartialImport<T>

- All Implemented Interfaces:
    PartialImport<T>
  Direct Known Subclasses:
    ClientsPartialImport, GroupsPartialImport, IdentityProvidersPartialImport, RealmRolesPartialImport, UsersPartialImport

      public abstract class AbstractPartialImport<T>
      extends Object
      implements PartialImport<T>

  Base PartialImport for most resource types.
  Author:
    Stan Silvert ssilvert@redhat.com (C) 2016 Red Hat Inc.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Set<T>` | `toOverwrite`
    `protected Set<T>` | `toSkip`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractPartialImport()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected PartialImportResult` | `added(String modelId, T resourceRep)`
    `abstract void` | `create(RealmModel realm, KeycloakSession session, T resourceRep)`
    `PartialImportResults` | `doImport(PartialImportRepresentation partialImportRep, RealmModel realm, KeycloakSession session)` Create (or re-create) all the imported resources.
    `abstract boolean` | `exists(RealmModel realm, KeycloakSession session, T resourceRep)`
    `protected ErrorResponseException` | `existsError(String message)`
    `abstract String` | `existsMessage(RealmModel realm, T resourceRep)`
    `abstract String` | `getModelId(RealmModel realm, KeycloakSession session, T resourceRep)`
    `abstract String` | `getName(T resourceRep)`
    `abstract List<T>` | `getRepList(PartialImportRepresentation partialImportRep)`
    `abstract ResourceType` | `getResourceType()`
    `protected PartialImportResult` | `overwritten(String modelId, T resourceRep)`
    `void` | `prepare(PartialImportRepresentation partialImportRep, RealmModel realm, KeycloakSession session)` Find which resources will need to be skipped or overwritten.
    `abstract void` | `remove(RealmModel realm, KeycloakSession session, T resourceRep)`
    `void` | `removeOverwrites(RealmModel realm, KeycloakSession session)` Delete resources that will be overwritten.
    `protected PartialImportResult` | `skipped(String modelId, T resourceRep)`

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

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

- - ### Field Detail

    - #### toOverwrite

          protected final Set<T> toOverwrite

    - #### toSkip

          protected final Set<T> toSkip

  - ### Constructor Detail

    - #### AbstractPartialImport

          public AbstractPartialImport()

  - ### Method Detail

    - #### getRepList

          public abstract List<T> getRepList(PartialImportRepresentation partialImportRep)

    - #### getName

          public abstract String getName(T resourceRep)

    - #### getModelId

          public abstract String getModelId(RealmModel realm,
                                            KeycloakSession session,
                                            T resourceRep)

    - #### exists

          public abstract boolean exists(RealmModel realm,
                                         KeycloakSession session,
                                         T resourceRep)

    - #### existsMessage

          public abstract String existsMessage(RealmModel realm,
                                               T resourceRep)

    - #### getResourceType

          public abstract ResourceType getResourceType()

    - #### remove

          public abstract void remove(RealmModel realm,
                                      KeycloakSession session,
                                      T resourceRep)

    - #### create

          public abstract void create(RealmModel realm,
                                      KeycloakSession session,
                                      T resourceRep)

    - #### prepare

          public void prepare(PartialImportRepresentation partialImportRep,
                              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<T>`
      Parameters:
        `partialImportRep` - 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.

    - #### existsError

          protected ErrorResponseException existsError(String message)

    - #### overwritten

          protected PartialImportResult overwritten(String modelId,
                                                    T resourceRep)

    - #### skipped

          protected PartialImportResult skipped(String modelId,
                                                T resourceRep)

    - #### added

          protected PartialImportResult added(String modelId,
                                              T resourceRep)

    - #### 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<T>`
      Parameters:
        `realm` - Realm to be imported into.
        `session` - The KeycloakSession

    - #### doImport

          public PartialImportResults doImport(PartialImportRepresentation partialImportRep,
                                               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<T>`
      Parameters:
        `partialImportRep` - 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 © 2020 JBoss by Red Hat. All rights reserved.