/** * Retrieves the given comment record. * * @param restclient REST client instance * @param issue Internal JIRA ID of the associated issue * @param id Internal JIRA ID of the comment * * @return a comment instance * * @throws JiraException when the retrieval fails */ public static Comment get(RestClient restclient, String issue, String id) throws JiraException { JSON result = null; try { result = restclient.get(getBaseUri() + "issue/" + issue + "/comment/" + id); } catch (Exception ex) { throw new JiraException("Failed to retrieve comment " + id + " on issue " + issue, ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); return new Comment(restclient, (JSONObject)result, issue); }
/** * Retrieves the given comment record. * * @param restclient REST client instance * @param issue Internal JIRA ID of the associated issue * @param id Internal JIRA ID of the comment * * @return a comment instance * * @throws JiraException when the retrieval fails */ public static Comment get(RestClient restclient, String issue, String id) throws JiraException { JSON result = null; try { result = restclient.get(getBaseUri() + "issue/" + issue + "/comment/" + id); } catch (Exception ex) { throw new JiraException("Failed to retrieve comment " + id + " on issue " + issue, ex); } if (!(result instanceof JSONObject)) throw new JiraException("JSON payload is malformed"); return new Comment(restclient, (JSONObject)result); }
/** * 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 Comment 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); } JSON result = null; try { result = restclient.post(getRestUri(key) + "/comment", req); } catch (Exception ex) { throw new JiraException("Failed add comment to issue " + key, ex); } if (!(result instanceof JSONObject)) { throw new JiraException("JSON payload is malformed"); } return new Comment(restclient, (JSONObject) result, key); }
result = (T)new ChangeLogItem(restclient, (JSONObject)r); else if (type == Comment.class) result = (T)new Comment(restclient, (JSONObject)r); else if (type == Component.class) result = (T)new Component(restclient, (JSONObject)r);
result = (T)new ChangeLogItem(restclient, (JSONObject)r); else if (type == Comment.class) result = (T)new Comment(restclient, (JSONObject)r, parentId); else if (type == Component.class) result = (T)new Component(restclient, (JSONObject)r);