Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Bill Burke 2015-08-31 10:13:55 -04:00
commit 43fd24f02b
2 changed files with 30 additions and 19 deletions

View file

@ -45,27 +45,33 @@ public class ExportImportManager {
logger.info("Export finished successfully"); logger.info("Export finished successfully");
} else { } else {
ImportProvider importProvider = session.getProvider(ImportProvider.class, exportImportProviderId); ImportProvider importProvider = session.getProvider(ImportProvider.class, exportImportProviderId);
Strategy strategy = ExportImportConfig.getStrategy();
if (realmName == null) { if (importProvider == null) {
logger.infof("Full model import requested. Strategy: %s", strategy.toString()); logger.errorf("Invalid Import Provider %s", exportImportProviderId);
// Check if master realm was exported. If it's not, then it needs to be created before other realms are imported
if (!importProvider.isMasterRealmExported()) {
new ApplianceBootstrap().bootstrap(sessionFactory, contextPath);
}
importProvider.importModel(sessionFactory, strategy);
} else { } else {
logger.infof("Import of realm '%s' requested. Strategy: %s", realmName, strategy.toString());
Strategy strategy = ExportImportConfig.getStrategy();
if (!realmName.equals(Config.getAdminRealm())) { if (realmName == null) {
// Check if master realm exists. If it's not, then it needs to be created before other realm is imported logger.infof("Full model import requested. Strategy: %s", strategy.toString());
new ApplianceBootstrap().bootstrap(sessionFactory, contextPath);
} // Check if master realm was exported. If it's not, then it needs to be created before other realms are imported
if (!importProvider.isMasterRealmExported()) {
importProvider.importRealm(sessionFactory, realmName, strategy); new ApplianceBootstrap().bootstrap(sessionFactory, contextPath);
}
importProvider.importModel(sessionFactory, strategy);
} else {
logger.infof("Import of realm '%s' requested. Strategy: %s", realmName, strategy.toString());
if (!realmName.equals(Config.getAdminRealm())) {
// Check if master realm exists. If it's not, then it needs to be created before other realm is imported
new ApplianceBootstrap().bootstrap(sessionFactory, contextPath);
}
importProvider.importRealm(sessionFactory, realmName, strategy);
}
logger.info("Import finished successfully");
} }
logger.info("Import finished successfully");
} }
} catch (Throwable ioe) { } catch (Throwable ioe) {
logger.error("Error during export/import", ioe); logger.error("Error during export/import", ioe);

View file

@ -1,5 +1,6 @@
package org.keycloak.services; package org.keycloak.services;
import org.jboss.logging.Logger;
import org.jboss.resteasy.spi.HttpRequest; import org.jboss.resteasy.spi.HttpRequest;
import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.jboss.resteasy.spi.ResteasyProviderFactory;
import org.keycloak.models.KeycloakContext; import org.keycloak.models.KeycloakContext;
@ -16,6 +17,7 @@ import org.keycloak.provider.Provider;
import org.keycloak.provider.ProviderFactory; import org.keycloak.provider.ProviderFactory;
import javax.ws.rs.core.UriInfo; import javax.ws.rs.core.UriInfo;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
@ -37,6 +39,8 @@ public class DefaultKeycloakSession implements KeycloakSession {
private UserSessionProvider sessionProvider; private UserSessionProvider sessionProvider;
private UserFederationManager federationManager; private UserFederationManager federationManager;
private KeycloakContext context; private KeycloakContext context;
private static final Logger logger = Logger.getLogger(DefaultKeycloakSession.class);
public DefaultKeycloakSession(DefaultKeycloakSessionFactory factory) { public DefaultKeycloakSession(DefaultKeycloakSessionFactory factory) {
this.factory = factory; this.factory = factory;
@ -108,6 +112,7 @@ public class DefaultKeycloakSession implements KeycloakSession {
T provider = (T) providers.get(hash); T provider = (T) providers.get(hash);
if (provider == null) { if (provider == null) {
ProviderFactory<T> providerFactory = factory.getProviderFactory(clazz, id); ProviderFactory<T> providerFactory = factory.getProviderFactory(clazz, id);
if (providerFactory != null) { if (providerFactory != null) {
provider = providerFactory.create(this); provider = providerFactory.create(this);
providers.put(hash, provider); providers.put(hash, provider);