Skip to content

Commit

Permalink
Merge pull request micromata#3 from bitwig/master
Browse files Browse the repository at this point in the history
Added interface for adding comments to Jira issue.
  • Loading branch information
mrkoenigstein authored Oct 29, 2017
2 parents e7c4764 + cc4b290 commit e09db29
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<groupId>de.micromata</groupId>
<artifactId>jiraRestClient</artifactId>
<version>2.3</version>
<version>2.4</version>
<packaging>jar</packaging>

<properties>
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/de/micromata/jira/rest/client/IssueClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,10 @@ boolean transferWorklogInIssue(String issueKey,
*/
Future<CommentsBean> getCommentsByIssue(String issueKey) throws RestException, IOException;

/**
* Add comment to issue.
*/
boolean addCommentToIssue(String issueKey, CommentBean comment) throws
RestException,
URISyntaxException, IOException;
}
27 changes: 27 additions & 0 deletions src/main/java/de/micromata/jira/rest/core/IssueClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,33 @@ public Future<CommentsBean> getCommentsByIssue(final String issueKey)
});
}

@Override
public boolean addCommentToIssue(final String issueKey, final CommentBean comment) throws
RestException,
URISyntaxException,
IOException
{
Validate.notNull(issueKey);
Validate.notNull(comment);

final String json = gson.toJson(comment);
final URIBuilder uriBuilder = buildPath(ISSUE, issueKey, COMMENT);
final HttpPost method = HttpMethodFactory.createPostMethod(uriBuilder.build(), json);
final CloseableHttpResponse response = client.execute(method, clientContext);
final int statusCode = response.getStatusLine().getStatusCode();

if (statusCode == HttpURLConnection.HTTP_CREATED) {
method.releaseConnection();
response.close();
return true;
} else {
final RestException restException = new RestException(response);
method.releaseConnection();
response.close();
throw restException;
}
}

public Future<Byte[]> getAttachment(final URI uri) throws RestException,
IOException {

Expand Down

0 comments on commit e09db29

Please sign in to comment.