private boolean postComment(Issue issue, Comment comment, boolean parallelRequest) throws NotFoundException { if (comment.isPrivate()) Utils.logWarnMessage( LOG, "Private comments are not currently supported by " + getClass().getName()); String trackerId = issue.getTrackerId().orElse(getIssueKey(issue.getURL())); String restURI = API_ISSUE_PATH + trackerId + COMMENT_ISSUE_PATH; JSONObject req = new JSONObject(); req.put("body", comment.getBody()); try { // A new JiraClient is created here to allow for comments to be posted in parallel // The underlying JiraClient is not thread-safe, hence it is necessary to create a new // JiraClient object for each request. if (parallelRequest) { ICredentials credentials = new BasicCredentials(config.getUsername(), config.getPassword()); new JiraClient(baseUrl.toString(), credentials).getRestClient().post(restURI, req); } else { jiraClient.getRestClient().post(restURI, req); } } catch (Exception ex) { throw new NotFoundException("Failed to add comment to issue " + issue.getURL(), ex); } return true; }
private net.rcarz.jiraclient.Issue getIssue(Issue issue) throws NotFoundException { String trackerId = issue.getTrackerId().orElse(getIssueKey(issue.getURL())); return getIssue(trackerId); }