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);
}
Aggregations