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 PartialImportResultadded(String modelId, T resourceRep)abstract voidcreate(RealmModel realm, KeycloakSession session, T resourceRep)PartialImportResultsdoImport(PartialImportRepresentation partialImportRep, RealmModel realm, KeycloakSession session)Create (or re-create) all the imported resources.abstract booleanexists(RealmModel realm, KeycloakSession session, T resourceRep)protected ErrorResponseExceptionexistsError(String message)abstract StringexistsMessage(RealmModel realm, T resourceRep)abstract StringgetModelId(RealmModel realm, KeycloakSession session, T resourceRep)abstract StringgetName(T resourceRep)abstract List<T>getRepList(PartialImportRepresentation partialImportRep)abstract ResourceTypegetResourceType()protected PartialImportResultoverwritten(String modelId, T resourceRep)voidprepare(PartialImportRepresentation partialImportRep, RealmModel realm, KeycloakSession session)Find which resources will need to be skipped or overwritten.abstract voidremove(RealmModel realm, KeycloakSession session, T resourceRep)voidremoveOverwrites(RealmModel realm, KeycloakSession session)Delete resources that will be overwritten.protected PartialImportResultskipped(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:PartialImportFind which resources will need to be skipped or overwritten. Also, do a preliminary check for errors.- Specified by:
preparein 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:PartialImportDelete 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:
removeOverwritesin 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:PartialImportCreate (or re-create) all the imported resources.- Specified by:
doImportin 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.
-
-