Hi,
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.
HI Silviu,
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.
https://docs.atlassian.com/jira/6.1.5/com/atlassian/jira/issue/comments/MutableComment.html
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
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();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.