KEYCLOAK-3773 Testsuite failing with mongo

This commit is contained in:
mposolda 2016-10-20 17:47:34 +02:00
parent ec0f222f7e
commit c4ad84945c
4 changed files with 9 additions and 16 deletions

View file

@ -2053,7 +2053,7 @@ public class RealmAdapter implements RealmModel, JpaModel<RealmEntity> {
em.persist(c);
setConfig(model, c);
model.setId(c.getId());
KeycloakModelUtils.notifyCreated(session, this, model);
ComponentUtil.notifyCreated(session, this, model);
return model;
}

View file

@ -1966,7 +1966,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
model.setId(entity.getId());
realm.getComponentEntities().add(entity);
updateRealm();
KeycloakModelUtils.notifyCreated(session, this, model);
ComponentUtil.notifyCreated(session, this, model);
return model;
}
@ -2074,7 +2074,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
@Override
public ComponentModel getComponent(String id) {
for (ComponentEntity entity : realm.getComponentEntities()) {
if (entity.getId() == entity.getId()) {
if (id.equals(entity.getId())) {
return entityToModel(entity);
}
}

View file

@ -20,6 +20,7 @@ package org.keycloak.models.utils;
import org.keycloak.component.ComponentFactory;
import org.keycloak.component.ComponentModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
import org.keycloak.provider.Provider;
import org.keycloak.provider.ProviderConfigProperty;
import org.keycloak.provider.ProviderFactory;
@ -61,4 +62,9 @@ public class ComponentUtil {
return cf;
}
public static void notifyCreated(KeycloakSession session, RealmModel realm, ComponentModel model) {
ComponentFactory factory = getComponentFactory(session, model);
factory.onCreate(session, realm, model);
}
}

View file

@ -682,17 +682,4 @@ public final class KeycloakModelUtils {
}
}
public static void notifyCreated(KeycloakSession session, RealmModel realm, ComponentModel model) {
Class<? extends Provider> providerClass = null;
try {
providerClass = (Class<? extends Provider>)Class.forName(model.getProviderType());
} catch (ClassNotFoundException e) {
return;
}
ProviderFactory factory = session.getKeycloakSessionFactory().getProviderFactory(providerClass, model.getProviderId());
if (factory instanceof ComponentFactory && factory != null) {
((ComponentFactory)factory).onCreate(session, realm, model);
}
}
}