I need to update a comment,
I can get the comment id and author.
Just need to update the comment body with plugin.
Which class should i use?
I have tried CommentManager.Update().
But i can not find how to update the comment body.
void update(Comment comment, boolean dispatchEvent) Persists the updated comment. Parameters: comment - to update dispatchEvent - if true then an event of type EventType.ISSUE_COMMENT_EDITED_ID will be dispatched and any notifications listening for that event will be triggered. If false no event will be dispatched. Throws: IllegalArgumentException - if comment passed in is null or its id is null
I have had a look in the JIRA sources and you need to get a MutableComment in the first place. Note that getCommentById returns a Comment, but under the hood, there is actually a MutableComment). You can setBody with this interface. The rest is simple, as you have already found out the update method in CommentManager.
I can see the mutableComment description says:
Represents a comment's in JIRA. After calling any 'setter' method, you will need to call
CommentService.update(com.atlassian.jira.user.ApplicationUser, com.atlassian.jira.issue.comments.MutableComment, boolean, com.atlassian.jira.util.ErrorCollection) which does permission checking or
CommentManager.update(com.atlassian.jira.issue.comments.Comment, boolean) which will just store the provided object, to persist the change to the database.
Should i use commentService or CommentManager to update comment?
What the different between them?
If i want to use CommentService to update the comment, how to get the ErrorCollection instance?
CommentService uses CommentManager under the hood. If you want, you can use CommentService to also check for permissions, but I think you will only need CommentManager.
As for ErrorCollection, here is how JIRA does:
SimpleErrorCollection errorCollection = new SimpleErrorCollection();
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot