1
0
Fork 0

implemented adding comments to issues

master
Bob Carroll 2013-05-22 13:36:00 -07:00
parent 4521a149ae
commit 6648210199
1 changed files with 56 additions and 15 deletions

View File

@ -190,21 +190,21 @@ public final class Issue extends Resource {
private String key = null;
/* system fields */
public User assignee = null;
public List<Attachment> attachments = null;
public List<Comment> comments = null;
public List<Component> components = null;
public String description = null;
public Date dueDate = null;
public List<Version> fixVersions = null;
public IssueType issueType = null;
public List<String> labels = null;
public Priority priority = null;
public User reporter = null;
public Status status = null;
public String summary = null;
public TimeTracking timeTracking = null;
public List<Version> versions = null;
private User assignee = null;
private List<Attachment> attachments = null;
private List<Comment> comments = null;
private List<Component> components = null;
private String description = null;
private Date dueDate = null;
private List<Version> fixVersions = null;
private IssueType issueType = null;
private List<String> labels = null;
private Priority priority = null;
private User reporter = null;
private Status status = null;
private String summary = null;
private TimeTracking timeTracking = null;
private List<Version> versions = null;
/**
* Creates an issue from a JSON payload.
@ -286,6 +286,47 @@ public final class Issue extends Resource {
return (JSONArray)result.get("transitions");
}
/**
* Adds a comment to this issue.
*
* @param body Comment text
*
* @throws JiraException when the comment creation fails
*/
public void addComment(String body) throws JiraException {
addComment(body, null, null);
}
/**
* Adds a comment to this issue with limited visibility.
*
* @param body Comment text
* @param visType Target audience type (role or group)
* @param visName Name of the role or group to limit visibility to
*
* @throws JiraException when the comment creation fails
*/
public void addComment(String body, String visType, String visName)
throws JiraException {
JSONObject req = new JSONObject();
req.put("body", body);
if (visType != null && visName != null) {
JSONObject vis = new JSONObject();
vis.put("type", visType);
vis.put("value", visName);
req.put("visibility", vis);
}
try {
restclient.post(getRestUri(key) + "/comment", req);
} catch (Exception ex) {
throw new JiraException("Failed to retrieve issue " + key, ex);
}
}
/**
* Retrieves the given issue record.
*