(Long id, CommentPatchDTO commentPatchDTO, User user)
| 73 | } |
| 74 | |
| 75 | public Comment update(Long id, CommentPatchDTO commentPatchDTO, User user) { |
| 76 | Comment savedComment = |
| 77 | commentRepository.findById(id).orElseThrow(() -> new CustomException("Not found", |
| 78 | HttpStatus.NOT_FOUND)); |
| 79 | if (!savedComment.getUser().getId().equals(user.getId())) |
| 80 | throw new CustomException("Access denied", HttpStatus.FORBIDDEN); |
| 81 | |
| 82 | WorkOrder workOrder = savedComment.getWorkOrder(); |
| 83 | |
| 84 | Comment updatedComment = commentRepository.saveAndFlush(commentMapper.updateComment(savedComment, |
| 85 | commentPatchDTO)); |
| 86 | em.refresh(updatedComment); |
| 87 | |
| 88 | Set<User> notifiedUsers = getNotifiedUsers(updatedComment, workOrder, user); |
| 89 | sendCommentNotifications(updatedComment, workOrder, notifiedUsers, user, true); |
| 90 | |
| 91 | return updatedComment; |
| 92 | } |
| 93 | |
| 94 | public List<Comment> findByCriteria(CommentCriteria criteria, User user) { |
| 95 | Specification<Comment> specification = (root, query, cb) -> { |
nothing calls this directly
no test coverage detected