use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.VALIDATION_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method update.
@ApiOperation("Update analysis.")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}", method = PUT)
public JsonResult<D> update(@PathVariable("analysisId") Long id, @RequestBody @Valid AnalysisUpdateDTO analysisDTO, BindingResult binding) throws NotExistException, NotUniqueException, ValidationException {
JsonResult<D> result;
if (binding.hasErrors()) {
result = new JsonResult<>(VALIDATION_ERROR);
for (FieldError fieldError : binding.getFieldErrors()) {
result.getValidatorErrors().put(fieldError.getField(), fieldError.getDefaultMessage());
}
} else {
T analysis = conversionService.convert(analysisDTO, getAnalysisClass());
analysis.setId(id);
analysis = analysisService.update(analysis);
result = new JsonResult<>(NO_ERROR);
result.setResult(conversionService.convert(analysis, getAnalysisDTOClass()));
}
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.VALIDATION_ERROR in project ArachneCentralAPI by OHDSI.
the class ExceptionHandlingController method exceptionHandler.
@ExceptionHandler(NotExistException.class)
public ResponseEntity<JsonResult> exceptionHandler(NotExistException ex) {
LOGGER.error(ex.getMessage());
JsonResult result = new JsonResult<>(VALIDATION_ERROR);
result.setErrorMessage(ex.getMessage());
result.getValidatorErrors().put(ex.getEntity().getSimpleName(), ex.getMessage());
return new ResponseEntity<>(result, HttpStatus.OK);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.VALIDATION_ERROR in project ArachneCentralAPI by OHDSI.
the class ExceptionHandlingController method exceptionHandler.
@ExceptionHandler(NoExecutableFileException.class)
public ResponseEntity<JsonResult> exceptionHandler(NoExecutableFileException ex) {
LOGGER.error(ex.getMessage(), ex);
JsonResult result = new JsonResult(VALIDATION_ERROR);
result.setErrorMessage(ex.getMessage());
return new ResponseEntity<>(result, HttpStatus.OK);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.VALIDATION_ERROR in project ArachneCentralAPI by OHDSI.
the class ExceptionHandlingController method exceptionHandler.
@ExceptionHandler(ConstraintViolationException.class)
public ResponseEntity<JsonResult> exceptionHandler(ConstraintViolationException ex) {
LOGGER.warn(ex.getMessage());
JsonResult result = new JsonResult<>(VALIDATION_ERROR);
if (!ex.getConstraintViolations().isEmpty()) {
result = setValidationErrors(ex.getConstraintViolations());
}
return new ResponseEntity<>(result, HttpStatus.OK);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.VALIDATION_ERROR in project ArachneCentralAPI by OHDSI.
the class ExceptionHandlingController method exceptionHandler.
@ExceptionHandler(UserNotFoundException.class)
public ResponseEntity<JsonResult> exceptionHandler(UserNotFoundException ex, HttpServletResponse response) throws IOException {
LOGGER.error(ex.getMessage(), ex);
JsonResult result = new JsonResult<>(VALIDATION_ERROR);
result.setErrorMessage(ex.getMessage());
result.getValidatorErrors().put(ex.getField(), ex.getMessage());
response.sendRedirect("/auth/login?message=email-not-confirmed");
return new ResponseEntity<>(result, HttpStatus.OK);
}
Aggregations