Class ErrorConstraintViolationExceptionConverter
java.lang.Object
com.totvs.tjf.api.response.error.converter.ErrorExceptionConverter
com.totvs.tjf.api.response.error.converter.ErrorConstraintViolationExceptionConverter
- Direct Known Subclasses:
ErrorTransactionSystemExceptionConverter
ConstraintViolation and ApiError converter to
ApiErrorResponse.- Author:
- Thiago A. de Souza Weber
-
Nested Class Summary
Nested classes/interfaces inherited from class com.totvs.tjf.api.response.error.converter.ErrorExceptionConverter
ErrorExceptionConverter.ExceptionErrorMap -
Field Summary
FieldsFields inherited from class com.totvs.tjf.api.response.error.converter.ErrorExceptionConverter
API_ERROR_NULL_ERROR_MESSAGE, EXCEPTION_NULL_ERROR_MESSAGE -
Constructor Summary
ConstructorsConstructorDescriptionErrorConstraintViolationExceptionConverter(com.totvs.tjf.core.i18n.I18nService i18nService) -
Method Summary
Modifier and TypeMethodDescriptionconvert(javax.validation.ConstraintViolation<?> violation) Converts the givenConstraintViolationto anErrorExceptionConverter.ExceptionErrorMapcontaining theHttpStatusand theApiErrorResponsewith: HttpStatus:BAD_REQUEST; ApiErrorMessage: Code: asConstraintViolation.getMessageTemplate(); Message: an already localized and interpolated message provided byConstraintViolation.getMessage(); and Detailed message: a concatenation with the violated property name and the invalid value.convertAsGeneric(Exception exception) Converts the givenExceptionto anErrorExceptionConverter.ExceptionErrorMapcontaining theHttpStatusand theApiErrorResponsewith: HttpStatus:INTERNAL_SERVER_ERROR; ApiErrorMessage: Code:exception.getClass().getSimpleName(); Message:exception.getLocalizedMessage(); and Detailed message:exception.getCause().getLocalizedMessage(), if a cause exist.protected StringgetViolationCode(javax.validation.ConstraintViolation<?> violation) Return theviolation.getMessageTemplate()without the interpolation tags.protected StringgetViolationDetail(javax.validation.ConstraintViolation<?> violation) Return the violation detail based on theviolation.getPropertyPath()and theviolation.getInvalidValue().Methods inherited from class com.totvs.tjf.api.response.error.converter.ErrorExceptionConverter
convert, convertAsError, convertAsError
-
Field Details
-
CONSTRAINT_VIOLATION_NULL_ERROR_MESSAGE
- See Also:
-
-
Constructor Details
-
ErrorConstraintViolationExceptionConverter
public ErrorConstraintViolationExceptionConverter(com.totvs.tjf.core.i18n.I18nService i18nService)
-
-
Method Details
-
convertAsGeneric
Description copied from class:ErrorExceptionConverterConverts the givenExceptionto anErrorExceptionConverter.ExceptionErrorMapcontaining theHttpStatusand theApiErrorResponsewith:- HttpStatus:
INTERNAL_SERVER_ERROR; - ApiErrorMessage:
- Code:
exception.getClass().getSimpleName(); - Message:
exception.getLocalizedMessage(); and - Detailed message:
exception.getCause().getLocalizedMessage(), if a cause exist.
- Code:
- Overrides:
convertAsGenericin classErrorExceptionConverter- Parameters:
exception- generic exception to be converted- Returns:
- instance of
ErrorExceptionConverter.ExceptionErrorMap
- HttpStatus:
-
convert
public ErrorExceptionConverter.ExceptionErrorMap convert(javax.validation.ConstraintViolation<?> violation) Converts the givenConstraintViolationto anErrorExceptionConverter.ExceptionErrorMapcontaining theHttpStatusand theApiErrorResponsewith:- HttpStatus:
BAD_REQUEST; - ApiErrorMessage:
- Code: as
ConstraintViolation.getMessageTemplate(); - Message: an already localized and interpolated message provided by
ConstraintViolation.getMessage(); and - Detailed message: a concatenation with the violated property name and the invalid value.
- Code: as
- Parameters:
violation- violation to be converted- Returns:
- instance of
ErrorExceptionConverter.ExceptionErrorMap - Throws:
NullPointerException- in case the given violation be null- See Also:
- HttpStatus:
-
getViolationCode
Return theviolation.getMessageTemplate()without the interpolation tags.- Parameters:
violation- violation to be parsed- Returns:
- message template value
- Throws:
NullPointerException- in case the given violation be null
-
getViolationDetail
Return the violation detail based on theviolation.getPropertyPath()and theviolation.getInvalidValue().Example: age: 4
- Parameters:
violation- violation to be parsed- Returns:
- violation detail
- Throws:
NullPointerException- in case the given violation be null
-