use of com.enonic.xp.content.ContentPropertyNames.ATTACHMENT in project xp by enonic.
the class ContentDataSerializer method mapValidationError.
private ValidationError mapValidationError(final PropertySet ve) {
final Object[] args = Optional.ofNullable(ve.getString("args")).map(argsJson -> {
try {
return OBJECT_MAPPER.readValue(argsJson, Object[].class);
} catch (JsonProcessingException e) {
throw new UncheckedIOException(e);
}
}).orElse(null);
final ValidationErrorCode errorCode = ValidationErrorCode.parse(ve.getString("errorCode"));
if (ve.hasProperty("propertyPath")) {
return ValidationError.dataError(errorCode, PropertyPath.from(ve.getString("propertyPath"))).message(ve.getString("message"), true).i18n(ve.getString("i18n")).args(args).build();
} else if (ve.hasProperty("attachment")) {
return ValidationError.attachmentError(errorCode, BinaryReference.from(ve.getString("attachment"))).message(ve.getString("message"), true).i18n(ve.getString("i18n")).args(args).build();
} else {
return ValidationError.generalError(errorCode).message(ve.getString("message"), true).i18n(ve.getString("i18n")).args(args).build();
}
}
Aggregations