Search in sources :

Example 1 with MapComponentEntity

use of org.keycloak.models.map.realm.entity.MapComponentEntity in project keycloak by keycloak.

the class MapRealmAdapter method importComponentModel.

@Override
public ComponentModel importComponentModel(ComponentModel model) {
    try {
        ComponentFactory componentFactory = ComponentUtil.getComponentFactory(session, model);
        if (componentFactory == null && System.getProperty(COMPONENT_PROVIDER_EXISTS_DISABLED) == null) {
            throw new IllegalArgumentException("Invalid component type");
        }
        componentFactory.validateConfiguration(session, this, model);
    } catch (IllegalArgumentException | ComponentValidationException e) {
        if (System.getProperty(COMPONENT_PROVIDER_EXISTS_DISABLED) == null) {
            throw e;
        }
    }
    if (entity.getComponent(model.getId()).isPresent()) {
        throw new ModelDuplicateException("A Component with given id already exists");
    }
    MapComponentEntity component = MapComponentEntity.fromModel(model);
    if (model.getParentId() == null) {
        component.setParentId(getId());
    }
    entity.addComponent(component);
    return MapComponentEntity.toModel(component);
}
Also used : ComponentValidationException(org.keycloak.component.ComponentValidationException) MapComponentEntity(org.keycloak.models.map.realm.entity.MapComponentEntity) ComponentFactory(org.keycloak.component.ComponentFactory) ModelDuplicateException(org.keycloak.models.ModelDuplicateException)

Aggregations

ComponentFactory (org.keycloak.component.ComponentFactory)1 ComponentValidationException (org.keycloak.component.ComponentValidationException)1 ModelDuplicateException (org.keycloak.models.ModelDuplicateException)1 MapComponentEntity (org.keycloak.models.map.realm.entity.MapComponentEntity)1