Search in sources :

Example 6 with ExportImportManager

use of org.keycloak.exportimport.ExportImportManager in project keycloak by keycloak.

the class QuarkusJpaConnectionProviderFactory method initSchema.

private void initSchema(KeycloakSession session) {
    ExportImportManager exportImportManager = new ExportImportManager(session);
    /*
         * Migrate model is executed just in case following providers are "jpa".
         * In Map Storage, there is an assumption that migrateModel is not needed.
         */
    if ((Config.getProvider("realm") == null || "jpa".equals(Config.getProvider("realm"))) && (Config.getProvider("client") == null || "jpa".equals(Config.getProvider("client"))) && (Config.getProvider("clientScope") == null || "jpa".equals(Config.getProvider("clientScope")))) {
        logger.debug("Calling migrateModel");
        migrateModel(session);
    }
    DBLockManager dbLockManager = new DBLockManager(session);
    dbLockManager.checkForcedUnlock();
    DBLockProvider dbLock = dbLockManager.getDBLock();
    dbLock.waitForLock(DBLockProvider.Namespace.KEYCLOAK_BOOT);
    try {
        createMasterRealm(exportImportManager);
    } finally {
        dbLock.releaseLock();
    }
    if (exportImportManager.isRunExport()) {
        exportImportManager.runExport();
        Quarkus.asyncExit();
    }
}
Also used : ExportImportManager(org.keycloak.exportimport.ExportImportManager) DBLockManager(org.keycloak.models.dblock.DBLockManager) DBLockProvider(org.keycloak.models.dblock.DBLockProvider)

Aggregations

ExportImportManager (org.keycloak.exportimport.ExportImportManager)6 Test (org.junit.Test)3 AbstractAuthTest (org.keycloak.testsuite.AbstractAuthTest)3 LinkedList (java.util.LinkedList)2 CredentialModel (org.keycloak.credential.CredentialModel)2 GroupModel (org.keycloak.models.GroupModel)2 KeycloakSession (org.keycloak.models.KeycloakSession)2 KeycloakSessionTask (org.keycloak.models.KeycloakSessionTask)2 RealmModel (org.keycloak.models.RealmModel)2 RoleModel (org.keycloak.models.RoleModel)2 PasswordCredentialModel (org.keycloak.models.credential.PasswordCredentialModel)2 DBLockManager (org.keycloak.models.dblock.DBLockManager)2 DBLockProvider (org.keycloak.models.dblock.DBLockProvider)2 ApplianceBootstrap (org.keycloak.services.managers.ApplianceBootstrap)2 RealmManager (org.keycloak.services.managers.RealmManager)2 SystemException (javax.transaction.SystemException)1 Transaction (javax.transaction.Transaction)1 NotFoundException (javax.ws.rs.NotFoundException)1 PostMigrationEvent (org.keycloak.models.utils.PostMigrationEvent)1 ComponentRepresentation (org.keycloak.representations.idm.ComponentRepresentation)1