io.imunity.scim.user.mapping.evaluation.SimpleMappingEvaluator Maven / Gradle / Ivy
/*
* Copyright (c) 2021 Bixbit - Krzysztof Benedyczak. All rights reserved.
* See LICENCE.txt file for licensing information.
*/
package io.imunity.scim.user.mapping.evaluation;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Component;
import io.imunity.scim.config.AttributeDefinitionWithMapping;
import io.imunity.scim.config.SimpleAttributeMapping;
import pl.edu.icm.unity.base.exceptions.EngineException;
import pl.edu.icm.unity.base.utils.Log;
@Component
class SimpleMappingEvaluator implements MappingEvaluator
{
private static final Logger log = Log.getLogger(Log.U_SERVER_SCIM, SimpleMappingEvaluator.class);
private final DataArrayResolver dataArrayResolver;
private final UnityToSCIMDataConverter targetDataConverter;
private final MVELEvaluator mvelEvaluator;
SimpleMappingEvaluator(DataArrayResolver dataArrayResolver, UnityToSCIMDataConverter targetDataConverter,
MVELEvaluator mvelEvaluator)
{
this.dataArrayResolver = dataArrayResolver;
this.targetDataConverter = targetDataConverter;
this.mvelEvaluator = mvelEvaluator;
}
@Override
public String getId()
{
return SimpleAttributeMapping.id;
}
@Override
public EvaluationResult eval(AttributeDefinitionWithMapping attributeDefinitionWithMapping,
EvaluatorContext context, MappingEvaluatorRegistry registry) throws EngineException
{
log.debug("Eval simple mapping for attribute {}", attributeDefinitionWithMapping.attributeDefinition.name);
SimpleAttributeMapping mapping = (SimpleAttributeMapping) attributeDefinitionWithMapping.attributeMapping;
return attributeDefinitionWithMapping.attributeDefinition.multiValued
? evalMulti(attributeDefinitionWithMapping, context, registry, mapping)
: evalSingle(attributeDefinitionWithMapping, context, registry, mapping);
}
private EvaluationResult evalSingle(AttributeDefinitionWithMapping attributeDefinitionWithMapping,
EvaluatorContext context, MappingEvaluatorRegistry registry, SimpleAttributeMapping mapping)
throws EngineException
{
Optional