Package org.keycloak.partialimport
Class AbstractPartialImport<T>
- java.lang.Object
-
- org.keycloak.partialimport.AbstractPartialImport<T>
-
- All Implemented Interfaces:
PartialImport<T>
- Direct Known Subclasses:
ClientsPartialImport
,GroupsPartialImport
,IdentityProviderMappersPartialImport
,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.
-
-
Constructor Summary
Constructors Constructor Description AbstractPartialImport()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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)
-
-
-
Method Detail
-
getRepList
public abstract List<T> getRepList(PartialImportRepresentation partialImportRep)
-
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 interfacePartialImport<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 interfacePartialImport<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 interfacePartialImport<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.
-
-