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