io.imunity.scim.user.mapping.evaluation.ComplexMappingEvaluator 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.HashMap;
import java.util.List;
import java.util.Map;
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.ComplexAttributeMapping;
import pl.edu.icm.unity.base.exceptions.EngineException;
import pl.edu.icm.unity.base.utils.Log;
@Component
class ComplexMappingEvaluator implements MappingEvaluator
{
private static final Logger log = Log.getLogger(Log.U_SERVER_SCIM, ComplexMappingEvaluator.class);
private final DataArrayResolver dataArrayResolver;
ComplexMappingEvaluator(DataArrayResolver dataArrayResolver)
{
this.dataArrayResolver = dataArrayResolver;
}
@Override
public String getId()
{
return ComplexAttributeMapping.id;
}
@Override
public EvaluationResult eval(AttributeDefinitionWithMapping attributeDefinitionWithMapping,
EvaluatorContext context, MappingEvaluatorRegistry mappingEvaluatorRegistry) throws EngineException
{
log.debug("Eval complex mapping for attribute {}", attributeDefinitionWithMapping.attributeDefinition.name);
return attributeDefinitionWithMapping.attributeDefinition.multiValued
? evalMulti(attributeDefinitionWithMapping, context, mappingEvaluatorRegistry)
: evalSingle(attributeDefinitionWithMapping, context, mappingEvaluatorRegistry);
}
private EvaluationResult evalMulti(AttributeDefinitionWithMapping attributeDefinitionWithMapping,
EvaluatorContext context, MappingEvaluatorRegistry mappingEvaluatorRegistry) throws EngineException
{
List