Skip to content

Commit

Permalink
Merge pull request #63 from kbss-cvut/validation-exception-msg-id-193
Browse files Browse the repository at this point in the history
[kbss-cvut/record-manager-ui#193] Throw validation error in case if u…
  • Loading branch information
blcham authored Aug 11, 2024
2 parents 3111977 + c1c293f commit 6360631
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -157,14 +158,13 @@ private PatientRecord findInternal(String key) {
return record;
}



@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public ResponseEntity<String> 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()) {
Expand Down

0 comments on commit 6360631

Please sign in to comment.