diff --git a/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java b/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java index 5e8dae63..63985439 100644 --- a/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java +++ b/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java @@ -6,6 +6,7 @@ import cz.cvut.kbss.study.dto.PatientRecordDto; import cz.cvut.kbss.study.dto.RecordImportResult; import cz.cvut.kbss.study.exception.NotFoundException; +import cz.cvut.kbss.study.exception.ValidationException; import cz.cvut.kbss.study.model.PatientRecord; import cz.cvut.kbss.study.model.RecordPhase; import cz.cvut.kbss.study.model.User; @@ -157,14 +158,13 @@ private PatientRecord findInternal(String key) { return record; } - - @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public ResponseEntity createRecord(@RequestBody PatientRecord record) { if(userService.getCurrentUser().getInstitution() == null) - return ResponseEntity.status(HttpStatus.CONFLICT).body("User is not assigned to any institution"); + throw new ValidationException("record.save-error.user-not-assigned-to-institution", + "User is not assigned to any institution."); recordService.persist(record); if (LOG.isTraceEnabled()) {