Hello,
I am trying to update comments for users that have been migrated from the internal Jira user database to a directory database. The code snippet I am using currently in a proof of concept is a groovy script with scriptrunner:
comments.each { comment ->
MutableComment mutableComment = commentManager.getMutableComment(comment.getId())
CommentService.CommentParameters commentParameters = new CommentService.CommentParameters.CommentParametersBuilder().author(userId).body(comment.getBody()).build()
CommentService.CommentUpdateValidationResult commentUpdateValidationResult = commentService.validateCommentUpdate(currentUser,mutableComment.getId(),commentParameters)
if (commentUpdateValidationResult.getWarningCollection().hasAnyWarnings()) {
log.debug "Comment Warnings: " + commentUpdateValidationResult.getWarningCollection().hasAnyWarnings()
}
if (commentUpdateValidationResult.getErrorCollection().hasAnyErrors()) {
log.debug "Comment Errors: " + commentUpdateValidationResult.getErrorCollection().hasAnyErrors()
}
if (commentUpdateValidationResult.isValid()) {
log.debug "Updating user comment ${comment.getId()} for issue ${comment.getIssue()} for user ${user.getKey()} to ${userId.getName()}"
commentService.update(currentUser, commentUpdateValidationResult, false)
The script compiles and runs without issues. It reports that the comment(s) are properly updated. But they are not. There is no error message or indication what might be wrong. Do you see any issue with the approach? Is there a working way?
Thank you and best regards,
Nico