use of org.entando.entando.web.common.model.RestError in project entando-core by entando.
the class RestExceptionHandler method processRestRourceNotFoundEx.
@ExceptionHandler(value = RestRourceNotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
@ResponseBody
public RestResponse processRestRourceNotFoundEx(RestRourceNotFoundException ex) {
logger.debug("Handling {} error", ex.getClass().getSimpleName());
RestResponse response = null;
if (null != ex.getBindingResult()) {
BindingResult result = ex.getBindingResult();
response = processAllErrors(result);
} else {
response = new RestResponse();
RestError error = new RestError(ex.getErrorCode(), this.resolveLocalizedErrorMessage("NOT_FOUND", new Object[] { ex.getObjectName(), ex.getObjectCode() }));
List<RestError> errors = new ArrayList<>();
errors.add(error);
response.setErrors(errors);
response.setMetaData(new HashMap<>());
}
return response;
}
use of org.entando.entando.web.common.model.RestError in project entando-core by entando.
the class RestExceptionHandler method processGlobalErrors.
private RestResponse processGlobalErrors(RestResponse dto, List<ObjectError> globalErrors) {
if (null != globalErrors) {
List<RestError> errors = new ArrayList<>();
for (ObjectError globalError : globalErrors) {
String localizedErrorMessage = resolveLocalizedErrorMessage(globalError);
errors.add(new RestError(globalError.getCode(), localizedErrorMessage));
}
dto.addErrors(errors);
}
return dto;
}
use of org.entando.entando.web.common.model.RestError in project entando-core by entando.
the class RestExceptionHandler method processEntandoTokenException.
@ExceptionHandler(value = EntandoTokenException.class)
@ResponseStatus(HttpStatus.FORBIDDEN)
@ResponseBody
public RestResponse processEntandoTokenException(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.RestError 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.RestError in project entando-core by entando.
the class RestExceptionHandler method processFieldErrors.
private RestResponse processFieldErrors(RestResponse dto, List<FieldError> fieldErrors) {
if (null != fieldErrors) {
List<RestError> errors = new ArrayList<>();
for (FieldError fieldError : fieldErrors) {
String localizedErrorMessage = resolveLocalizedErrorMessage(fieldError);
errors.add(new RestError(fieldError.getCode(), localizedErrorMessage));
}
dto.addErrors(errors);
}
return dto;
}
Aggregations