From an event listener on Jira Server 8.x and JSD 4. (tried 8.0.1/ 4.0.1 and also the latest 8.1.0/ 4.1.0)
an exception is thrown, when I add an internal comment:
[INFO] [talledLocalContainer] 2019-05-07 13:57:08,691 http-nio-2990-exec-10 ERROR agrant-sd-demo /rest/servicedesk/1/servicedesk/customer/comment [atlassian.event.internal.AsynchronousAbleEventDispatcher] There was an exception thrown trying to dispatch event [com.atlassian.jira.event.issue.IssueEvent@44415529[issue=TEST-42,comment=com.atlassian.jira.issue.comments.CommentImpl@746adc81,worklog=<null>,changelog=<null>,eventTypeId=6,sendMail=true,params={eventsource=action, baseurl=http://localhost:2990/jira},subtasksUpdated=false,spanningOperation=Optional.empty]] from the invoker [SingleParameterMethodListenerInvoker{method=public void my.package.EventController.onIssueEvent(com.atlassian.jira.event.issue.IssueEvent), listener=my.package.EventController@5807713a}]
[INFO] [talledLocalContainer] java.lang.RuntimeException:
sd.api.error.comment.forbidden. Listener: my.package.EventController event: com.atlassian.jira.event.issue.IssueEvent
The exception just tells me sd.api.error.comment.forbidden and the comment is also created without any problems. But there is a lot of noise in the log file which I need to get rid of.
This is happening regardless of the user I’m providing in the create comment method (i.e. an admin or a user which has the Service Desk Team role for the project) and it is not happening in Jira 7.13/ JSD 3.16 and most likely none of the older versions.
I’m preparing the comment by setting its properties to flag it internal with below method:
private Map<String, JSONObject> getCommentProperties() {
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("internal", true);
JSONObject jsonObject = new JSONObject(jsonMap);
Map<String, JSONObject> commentProperties = new HashMap<>();
commentProperties.put("sd.public.comment", jsonObject);
return commentProperties;
}
and I’m creating the comment as follows:
Map<String, JSONObject> commentProperties = getCommentProperties();
// create internal comment
commentManager.create(issue,
commentingUser,
commentBody,
null,
null,
new Date(),
commentProperties, true);
In case anybody is wondering about the two null parameters passed to the method: these are for further restricting the comment, which is not needed here.
Did anybody encountered this is as well? I’m wondering why this isn’t a problem in JSD 3.
Do I have add internal comments differently on JSD 4 via Java API?
Best,
Johannes