use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class RestExceptionHandler method processEntandoAuthorizationException.
@ExceptionHandler(value = EntandoAuthorizationException.class)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ResponseBody
public RestResponse processEntandoAuthorizationException(EntandoAuthorizationException ex) {
logger.debug("Handling {} error", ex.getClass().getSimpleName());
RestResponse response = new RestResponse();
RestError error = new RestError(RestErrorCodes.UNAUTHORIZED, this.resolveLocalizedErrorMessage("UNAUTHORIZED", new Object[] { ex.getUsername(), ex.getRequestURI(), ex.getMethod() }));
List<RestError> errors = new ArrayList<>();
errors.add(error);
response.setErrors(errors);
return response;
}
use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class RestExceptionHandler method processValidationError.
@ExceptionHandler(value = MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public RestResponse processValidationError(MethodArgumentNotValidException ex) {
logger.debug("Handling {} error", ex.getClass().getSimpleName());
BindingResult result = ex.getBindingResult();
RestResponse response = processAllErrors(result);
return response;
}
use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class RestExceptionHandler method processAllErrors.
private RestResponse processAllErrors(List<FieldError> fieldErrors, List<ObjectError> objectErrors) {
RestResponse dto = new RestResponse();
processFieldErrors(dto, fieldErrors);
processGlobalErrors(dto, objectErrors);
return dto;
}
use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class RestExceptionHandler method processRuntimeExceptionException.
@ExceptionHandler(value = RuntimeException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public RestResponse processRuntimeExceptionException(RuntimeException ex) {
logger.debug("Handling {} error", ex.getClass().getSimpleName());
RestResponse response = new RestResponse();
RestError error = new RestError(RestErrorCodes.INTERNAL_ERROR, this.resolveLocalizedErrorMessage("GENERIC_ERROR", new Object[] { ex.getMessage() }));
List<RestError> errors = new ArrayList<>();
errors.add(error);
response.setErrors(errors);
ex.printStackTrace();
return response;
}
use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class RestExceptionHandler method processValidationError.
@ExceptionHandler(value = ValidationConflictException.class)
@ResponseStatus(HttpStatus.CONFLICT)
@ResponseBody
public RestResponse processValidationError(ValidationConflictException ex) {
logger.debug("Handling {} error", ex.getClass().getSimpleName());
BindingResult result = ex.getBindingResult();
RestResponse response = processAllErrors(result);
return response;
}
Aggregations