private void editComment( IssueChangeHolder issueChangeHolder, Map<String, Object> commentParams, String body) { final ApplicationUser user = authenticationContext.getUser(); final long commentId = Long.valueOf((String) commentParams.get(PARAM_COMMENT_ID)); final ErrorCollection errorCollection = new SimpleErrorCollection(); MutableComment mutableComment = commentService.getMutableComment(user, commentId, errorCollection); CommentParametersBuilder builder = CommentParameters.builder(mutableComment); if (StringUtils.isNotBlank(body)) { builder.body(body); } String groupLevel = (String) commentParams.get(PARAM_GROUP_LEVEL); String roleLevelIdStr = (String) commentParams.get(PARAM_ROLE_LEVEL); builder.visibility(Visibilities.fromGroupAndStrRoleId(groupLevel, roleLevelIdStr)); builder.commentProperties(getCommentPropertiesQuietly(commentParams)); final CommentService.CommentUpdateValidationResult validationResult = commentService.validateCommentUpdate(user, commentId, builder.build()); if (validationResult.isValid()) { commentService.update(user, validationResult, true); issueChangeHolder.setComment(mutableComment); } else { log.error( "Error updating comment id '" + commentId + "' Error(s): '" + errorCollection.toString() + "'"); } }
private void removeComment(IssueChangeHolder issueChangeHolder, Map commentParams) { final ApplicationUser user = authenticationContext.getUser(); final ErrorCollection errorCollection = new SimpleErrorCollection(); final long commentId = Long.valueOf((String) commentParams.get(PARAM_COMMENT_ID)); Comment comment = commentService.getCommentById(user, commentId, errorCollection); commentService.delete(new JiraServiceContextImpl(user, errorCollection), comment, true); if (errorCollection.hasAnyErrors()) { log.error( "Error updating comment id '" + commentId + "' Error(s): '" + errorCollection.toString() + "'"); } else { issueChangeHolder.setComment(comment); } }