Source side

Data Filter

When creating a data filter for a connection, which is going to send comments, you need to remember, that not all the comments have to be sent over.
You can choose to send over only the comments, which have no security restrictions:

replica.comments = commentHelper.filterLocal(issue.comments)

Also, you can use the groovy collection methods, which allow for high grained control over the collection contents:

For instance, if you would like to send only Luke Skywalker's comments:

replica.comments = issue.comments.findAll { comment -> == "Luke Skywalker"; comment }

Destination side

With the help of commentHelper methods, you can manipulate comments and define how the created issue comments will look like.

It's possible to merge, add, filter and format comments.

Create Processor

You can add the new remote comments by setting:


issue.comments += replica.addedComments

You can also manipulate the comments via helper methods:
// Format each remote comment - add the author
issue.comments = commentHelper.mergeComments(issue, replica,                       
                       comment ->
                       comment.body =
                          "[" + +
                                  "| mailto:" + + "]" +
                                  " commented: \n" +
                          "{quote}\n" +
                          comment.body + ";\n" +

You can gather statistic from the comments:
def numberOfCommentsPerAuthors = issue.comments.inject([:]) { result, comment ->   
  def numberOfCommentsPerAuthor = result[]
  numberOfCommentsPerAuthor = numberOfCommentsPerAuthor ?: 0
  result[] = numberOfCommentsPerAuthor + 1
Example for a comment list containing:
   body:"I'm a jedi knight, like my father before me"
   body:"I am your father!"

numberOfCommentsPerAuthors would be ["luke.skywalker" : 2,"darth.vader" : 1]

Change Processor

With the help of mergeComments commentHelper, you can add the new comments and keep the existing comments updated (no comments to be removed).

issue.comments = commentHelper.mergeComments(issue, replica)

You can also make the issue comments the same as the ones, sent from the remote instance:

Danger zone: this would remove all the comments, which are not present on the remote issue replica. Use with caution.

issue.comments = replica.comments

See Also