Search in sources :

Example 1 with AtlasValidationException

use of io.atlasmap.api.AtlasValidationException in project atlasmap by atlasmap.

the class KafkaConnectModule method processPreValidation.

@Override
public void processPreValidation(AtlasInternalSession session) throws AtlasException {
    if (session == null || session.getMapping() == null) {
        throw new AtlasValidationException("Invalid session: Session and AtlasMapping must be specified");
    }
    Validations validations = session.getValidations();
    KafkaConnectValidationService kafkaConnectValidationService = new KafkaConnectValidationService(getConversionService(), getFieldActionService());
    kafkaConnectValidationService.setMode(getMode());
    kafkaConnectValidationService.setDocId(getDocId());
    List<Validation> kafkaConnectValidations = kafkaConnectValidationService.validateMapping(session.getMapping());
    if (kafkaConnectValidations != null && !kafkaConnectValidations.isEmpty()) {
        validations.getValidation().addAll(kafkaConnectValidations);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Detected " + kafkaConnectValidations.size() + " json validation notices");
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("{}: processPreValidation completed", getDocId());
    }
}
Also used : Validation(io.atlasmap.v2.Validation) Validations(io.atlasmap.v2.Validations) AtlasValidationException(io.atlasmap.api.AtlasValidationException)

Example 2 with AtlasValidationException

use of io.atlasmap.api.AtlasValidationException in project atlasmap by atlasmap.

the class JsonModule method processPreValidation.

@Override
public void processPreValidation(AtlasInternalSession atlasSession) throws AtlasException {
    if (atlasSession == null || atlasSession.getMapping() == null) {
        throw new AtlasValidationException("Invalid session: Session and AtlasMapping must be specified");
    }
    Validations validations = atlasSession.getValidations();
    JsonValidationService jsonValidationService = new JsonValidationService(getConversionService(), getFieldActionService());
    jsonValidationService.setMode(getMode());
    jsonValidationService.setDocId(getDocId());
    List<Validation> jsonValidations = jsonValidationService.validateMapping(atlasSession.getMapping());
    if (jsonValidations != null && !jsonValidations.isEmpty()) {
        validations.getValidation().addAll(jsonValidations);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Detected " + jsonValidations.size() + " json validation notices");
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("{}: processPreValidation completed", getDocId());
    }
}
Also used : Validation(io.atlasmap.v2.Validation) Validations(io.atlasmap.v2.Validations) AtlasValidationException(io.atlasmap.api.AtlasValidationException)

Example 3 with AtlasValidationException

use of io.atlasmap.api.AtlasValidationException in project atlasmap by atlasmap.

the class AtlasMappingService method loadMapping.

public AtlasMapping loadMapping(File file, AtlasMappingFormat format) throws AtlasValidationException {
    try {
        AtlasMapping atlasMapping;
        switch(format) {
            case XML:
                StreamSource streamSource = new StreamSource(file);
                atlasMapping = createUnmarshaller().unmarshal(streamSource, AtlasMapping.class).getValue();
                break;
            case JSON:
                atlasMapping = jsonMapper.readValue(file, AtlasMapping.class);
                break;
            default:
                throw new AtlasValidationException("Unsupported mapping format: " + format.value);
        }
        validate(atlasMapping);
        return atlasMapping;
    } catch (Exception e) {
        throw new AtlasValidationException(e.getMessage(), e);
    }
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) StreamSource(javax.xml.transform.stream.StreamSource) AtlasValidationException(io.atlasmap.api.AtlasValidationException) AtlasValidationException(io.atlasmap.api.AtlasValidationException) AtlasException(io.atlasmap.api.AtlasException) URISyntaxException(java.net.URISyntaxException) JAXBException(javax.xml.bind.JAXBException)

Example 4 with AtlasValidationException

use of io.atlasmap.api.AtlasValidationException in project atlasmap by atlasmap.

the class AtlasMappingService method loadMapping.

public AtlasMapping loadMapping(Reader reader, AtlasMappingFormat format) throws AtlasValidationException {
    try {
        AtlasMapping atlasMapping;
        switch(format) {
            case XML:
                StreamSource streamSource = new StreamSource(reader);
                atlasMapping = createUnmarshaller().unmarshal(streamSource, AtlasMapping.class).getValue();
                break;
            case JSON:
                atlasMapping = jsonMapper.readValue(reader, AtlasMapping.class);
                break;
            default:
                throw new AtlasValidationException("Unsupported mapping format: " + format.value);
        }
        validate(atlasMapping);
        return atlasMapping;
    } catch (Exception e) {
        throw new AtlasValidationException(e.getMessage(), e);
    }
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) StreamSource(javax.xml.transform.stream.StreamSource) AtlasValidationException(io.atlasmap.api.AtlasValidationException) AtlasValidationException(io.atlasmap.api.AtlasValidationException) AtlasException(io.atlasmap.api.AtlasException) URISyntaxException(java.net.URISyntaxException) JAXBException(javax.xml.bind.JAXBException)

Aggregations

AtlasValidationException (io.atlasmap.api.AtlasValidationException)4 AtlasException (io.atlasmap.api.AtlasException)2 AtlasMapping (io.atlasmap.v2.AtlasMapping)2 Validation (io.atlasmap.v2.Validation)2 Validations (io.atlasmap.v2.Validations)2 URISyntaxException (java.net.URISyntaxException)2 JAXBException (javax.xml.bind.JAXBException)2 StreamSource (javax.xml.transform.stream.StreamSource)2