Class RolesPartialImport

java.lang.Object
org.keycloak.partialimport.RolesPartialImport
All Implemented Interfaces:
PartialImport<org.keycloak.representations.idm.RolesRepresentation>

public class RolesPartialImport extends Object implements PartialImport<org.keycloak.representations.idm.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 Details

    • RolesPartialImport

      public RolesPartialImport()
  • Method Details

    • prepare

      public void prepare(org.keycloak.representations.idm.PartialImportRepresentation rep, RealmModel realm, KeycloakSession session)
      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<org.keycloak.representations.idm.RolesRepresentation>
      Parameters:
      rep - Everything in the PartialImport request.
      realm - Realm to be imported into.
      session - The KeycloakSession.
    • 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<org.keycloak.representations.idm.RolesRepresentation>
      Parameters:
      realm - Realm to be imported into.
      session - The KeycloakSession
    • doImport

      public PartialImportResults doImport(org.keycloak.representations.idm.PartialImportRepresentation rep, RealmModel realm, KeycloakSession session)
      Description copied from interface: PartialImport
      Create (or re-create) all the imported resources.
      Specified by:
      doImport in interface PartialImport<org.keycloak.representations.idm.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.