use of io.atlasmap.v2.Validations in project oxTrust by GluuFederation.
the class ResourceValidator method validateValidableAttributes.
/**
* Inspects the resource passed in the constructor and applies validations for every attribute annotated with
* {@link Validator}. Validations are of different nature as seen{@link Validations here}.
* @throws SCIMException When a validation does not pass (the {@link Validations#apply(Validations, Object) apply}
* method returns false)
*/
public void validateValidableAttributes() throws SCIMException {
Map<String, List<Method>> map = IntrospectUtil.validableCoreAttrs.get(resourceClass);
for (String attributePath : map.keySet()) {
Field f = IntrospectUtil.findFieldFromPath(resourceClass, attributePath);
Validations valToApply = f.getAnnotation(Validator.class).value();
log.debug("Validating value(s) of attribute '{}'", attributePath);
for (Object val : IntrospectUtil.getAttributeValues(resource, map.get(attributePath))) {
if (val != null && !Validations.apply(valToApply, val)) {
log.error("Error validating attribute '{}', wrong value supplied: '{}'", attributePath, val.toString());
throw new SCIMException(String.format(ATTR_VALIDATION_FAILED, attributePath));
}
}
}
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class DefaultAtlasSession method initialize.
protected void initialize() {
properties = new ConcurrentHashMap<String, Object>();
validations = new Validations();
audits = new Audits();
head.unset();
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class DefaultAtlasContext method doCreateSession.
private AtlasSession doCreateSession() {
AtlasSession session = new DefaultAtlasSession(mappingDefinition);
session.setAtlasContext(this);
session.setAudits(new Audits());
session.setValidations(new Validations());
setDefaultSessionProperties(session);
return session;
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class DefaultAtlasValidationService method validateMapMapping.
private void validateMapMapping(List<Mapping> fieldMappings, List<Validation> validations, Set<String> usedIds) {
for (Mapping fieldMapping : fieldMappings) {
String mappingId = fieldMapping.getId();
validateMappingId(mappingId, usedIds, validations);
Validators.MAP_INPUT_NOT_NULL.get().validate(fieldMapping.getInputField(), validations, mappingId);
if (fieldMapping.getInputField() != null) {
Validators.MAP_INPUT_FIELD_NOT_EMPTY.get().validate(fieldMapping.getInputField(), validations, mappingId);
}
Validators.MAP_OUTPUT_NOT_NULL.get().validate(fieldMapping.getOutputField(), validations, mappingId, ValidationStatus.WARN);
if (fieldMapping.getOutputField() != null) {
Validators.MAP_OUTPUT_FIELD_NOT_EMPTY.get().validate(fieldMapping.getOutputField(), validations, mappingId, ValidationStatus.WARN);
}
}
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class DefaultAtlasValidationService method validateCombineMapping.
private void validateCombineMapping(List<Mapping> fieldMappings, List<Validation> validations, Set<String> usedIds) {
for (Mapping fieldMapping : fieldMappings) {
String mappingId = fieldMapping.getId();
validateMappingId(mappingId, usedIds, validations);
Validators.COMBINE_OUTPUT_NOT_NULL.get().validate(fieldMapping.getOutputField(), validations, mappingId);
if (fieldMapping.getOutputField() != null) {
Validators.COMBINE_OUTPUT_FIELD_NOT_EMPTY.get().validate(fieldMapping.getOutputField(), validations, mappingId);
// source must be a String type
}
Validators.COMBINE_INPUT_NOT_NULL.get().validate(fieldMapping.getInputField(), validations, mappingId, ValidationStatus.WARN);
Validators.COMBINE_INPUT_FIELD_NOT_EMPTY.get().validate(fieldMapping.getInputField(), validations, mappingId, ValidationStatus.WARN);
if (fieldMapping.getInputField() != null) {
for (Field field : fieldMapping.getInputField()) {
Validators.COMBINE_INPUT_FIELD_NOT_NULL.get().validate(field, validations, mappingId);
if (field.getIndex() == null || field.getIndex() < 0) {
Validators.COMBINE_INPUT_FIELD_FIELD_ACTION_INDEX_POSITIVE.get().validate(field.getIndex(), validations, mappingId);
}
}
}
}
}
Aggregations