use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class RestExceptionHandler method processValidationError.
@ExceptionHandler(value = ValidationGenericException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public RestResponse processValidationError(ValidationGenericException 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 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.RestResponse in project entando-core by entando.
the class DatabaseController method deleteDumpReport.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/report/{reportCode}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> deleteDumpReport(@PathVariable String reportCode) {
logger.debug("Deleting dump report -> code {}", reportCode);
this.getDatabaseService().deleteDumpReport(reportCode);
logger.debug("Deleted dump report -> {}", reportCode);
Map<String, String> response = new HashMap<>();
response.put("code", reportCode);
return new ResponseEntity<>(new RestResponse(response), HttpStatus.OK);
}
use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class DatabaseController method getStatus.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/status", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getStatus() {
Integer status = this.getDatabaseService().getStatus();
Map<String, String> response = new HashMap<>();
response.put("status", String.valueOf(status));
logger.debug("Required database status -> {}", status);
return new ResponseEntity<>(new RestResponse(response), HttpStatus.OK);
}
use of org.entando.entando.web.common.model.RestResponse in project entando-core by entando.
the class DatabaseController method getDumpReports.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getDumpReports(@Valid RestListRequest requestList) {
this.getDatabaseValidator().validateRestListRequest(requestList);
PagedMetadata<ShortDumpReportDto> result = this.getDatabaseService().getShortDumpReportDtos(requestList);
this.getDatabaseValidator().validateRestListResult(requestList, result);
return new ResponseEntity<>(new RestResponse(result.getBody(), new ArrayList<>(), result), HttpStatus.OK);
}
Aggregations