use of org.hisp.dhis.interpretation.InterpretationComment in project dhis2-core by dhis2.
the class InterpretationController method updateComment.
@PutMapping("/{uid}/comments/{cuid}")
@ResponseStatus(HttpStatus.NO_CONTENT)
@ResponseBody
public WebMessage updateComment(@PathVariable("uid") String uid, @PathVariable("cuid") String cuid, @RequestBody String content) {
Interpretation interpretation = interpretationService.getInterpretation(uid);
if (interpretation == null) {
return conflict("Interpretation does not exist: " + uid);
}
for (InterpretationComment comment : interpretation.getComments()) {
if (comment.getUid().equals(cuid)) {
if (!currentUserService.getCurrentUser().equals(comment.getCreatedBy()) && !currentUserService.currentUserIsSuper()) {
throw new AccessDeniedException("You are not allowed to update this comment.");
}
comment.setText(content);
interpretationService.updateComment(interpretation, comment);
}
}
return null;
}
Aggregations