api/src/main/java/com/epam/pipeline/manager/issue/IssueManager.java
@Transactional(propagation = Propagation.REQUIRED)
    public IssueComment updateComment(Long issueId, Long commentId, IssueCommentVO commentVO) {
        IssueComment issueComment = loadComment(issueId, commentId);
        loadIssueAndCheckIfNotClosed(issueId);
        String text = commentVO.getText();
        ensureNotEmptyString(text, MessageConstants.ERROR_INVALID_COMMENT_TEXT);
        issueComment.setText(text);
        commentDao.updateComment(issueComment);

        // Find the attachments that were removed during update and delete them
        HashSet<Attachment> newAttachments = new HashSet<>(commentVO.getAttachments());
        List<Attachment> allAttachments = attachmentDao.loadAttachmentsByCommentId(commentId);
        List<Attachment> toDelete = allAttachments.stream().filter(a -> !newAttachments.contains(a))
            .collect(Collectors.toList());
        attachmentFileManager.deleteAttachments(toDelete);

        // New attachments might be added so we need to link them to this comment
        commentVO.getAttachments().forEach(a -> attachmentDao.updateAttachmentCommentId(a.getId(), commentId));

        return issueComment;
    }
/**
     * Updates comment specified by ID. If issue was closed or issue doesn't exist or comment doesn't exist an error
     * will be thrown. If text for comment is empty exception will be thrown.
     * @param issueId issue's ID
     * @param commentId comment's ID
     * @param commentVO comment's text
     * @return updated {@link IssueComment}
     */
Updates comment specified by ID. If issue was closed or issue doesn't exist or comment doesn't exist an error
will be thrown. If text for comment is empty exception will be thrown.
@param issueId issue's ID
@param commentId comment's ID
@param commentVO comment's text
@return updated  IssueComment
Updates comment specified by ID . If issue was closed or issue doesn ' t exist or comment doesn ' t exist an error will be thrown . If text for comment is empty exception will be thrown . @param issueId issue ' s ID @param commentId comment ' s ID @param commentVO comment ' s text @return updated IssueComment
@Transactional(propagation = Propagation.REQUIRED)
    public IssueComment updateComment(Long issueId, Long commentId, IssueCommentVO commentVO) {
        IssueComment issueComment = loadComment(issueId, commentId);
        loadIssueAndCheckIfNotClosed(issueId);
        String text = commentVO.getText();
        ensureNotEmptyString(text, MessageConstants.ERROR_INVALID_COMMENT_TEXT);
        issueComment.setText(text);
        commentDao.updateComment(issueComment);
        HashSet<Attachment> newAttachments = new HashSet<>(commentVO.getAttachments());
        List<Attachment> allAttachments = attachmentDao.loadAttachmentsByCommentId(commentId);
        List<Attachment> toDelete = allAttachments.stream().filter(a -> !newAttachments.contains(a))
            .collect(Collectors.toList());
        attachmentFileManager.deleteAttachments(toDelete);
        commentVO.getAttachments().forEach(a -> attachmentDao.updateAttachmentCommentId(a.getId(), commentId));
        return issueComment;
    }
@ Transactional ( propagation = Propagation . REQUIRED ) public IssueComment updateComment ( Long issueId , Long commentId , IssueCommentVO commentVO ) { IssueComment issueComment = loadComment ( issueId , commentId ) ; loadIssueAndCheckIfNotClosed ( issueId ) ; String text = commentVO . getText ( ) ; ensureNotEmptyString ( text , MessageConstants . ERROR_INVALID_COMMENT_TEXT ) ; issueComment . setText ( text ) ; commentDao . updateComment ( issueComment ) ; HashSet < Attachment > newAttachments = new HashSet < > ( commentVO . getAttachments ( ) ) ; List < Attachment > allAttachments = attachmentDao . loadAttachmentsByCommentId ( commentId ) ; List < Attachment > toDelete = allAttachments . stream ( ) . filter ( a -> ! newAttachments . contains ( a ) ) . collect ( Collectors . toList ( ) ) ; attachmentFileManager . deleteAttachments ( toDelete ) ; commentVO . getAttachments ( ) . forEach ( a -> attachmentDao . updateAttachmentCommentId ( a . getId ( ) , commentId ) ) ; return issueComment ; }
Updates comment specified by ID.
Updates comment specified by ID .
// Find the attachments that were removed during update and delete them // New attachments might be added so we need to link them to this comment