public void postTaskOnComment(String message, Long commentId) { String request = baseUrl + TASKS_API; JsonObject anchor = new JsonObject(); anchor.put("id", commentId); anchor.put("type", "COMMENT"); JsonObject json = new JsonObject(); json.put("anchor", anchor); json.put("text", message); postCreate(request, json, MessageFormat.format(TASK_POST_ERROR_MESSAGE, commentId)); }
private String getBody(String fileName, String fileContent) { JsonObject files = new JsonObject(); JsonObject singleFile = new JsonObject(); singleFile.put("content", fileContent); files.put(fileName, singleFile); JsonObject body = new JsonObject(); body.put("files", files); body.put("public", "true"); body.put("description", fileName); return body.toJson(); } }
private String getBody(String fileName, String fileContent) { JsonObject files = new JsonObject(); JsonObject singleFile = new JsonObject(); singleFile.put("content", fileContent); files.put(fileName, singleFile); JsonObject body = new JsonObject(); body.put("files", files); body.put("public", "true"); body.put("description", fileName); return body.toJson(); } }
public void addPullRequestReviewer(PullRequestRef pr, long pullRequestVersion, List<StashUser> reviewers) { String request = MessageFormat.format(API_ONE_PR, baseUrl, pr.project(), pr.repository(), pr.pullRequestId()); JsonObject json = new JsonObject(); JsonArray jsonReviewers = new JsonArray(); for (StashUser reviewer : reviewers) { JsonObject reviewerName = new JsonObject(); reviewerName.put("name", reviewer.getName()); JsonObject user = new JsonObject(); user.put("user", reviewerName); jsonReviewers.add(user); } json.put("reviewers", jsonReviewers); json.put("id", pr.pullRequestId()); json.put("version", pullRequestVersion); put(request, json, MessageFormat.format(PULL_REQUEST_PUT_ERROR_MESSAGE, pr.repository(), pr.pullRequestId())); }
public StashComment postCommentLineOnPullRequest(PullRequestRef pr, String message, String path, long line, IssueType type) { String request = MessageFormat.format(API_ONE_PR_ALL_COMMENTS, baseUrl, pr.project(), pr.repository(), pr.pullRequestId()); JsonObject anchor = new JsonObject(); if (line != 0L) { anchor.put("line", line); anchor.put("lineType", type.name()); } String fileType = "TO"; if (type == IssueType.CONTEXT) { fileType = "FROM"; } anchor.put("fileType", fileType); anchor.put("path", path); JsonObject json = new JsonObject(); json.put("text", message); json.put("anchor", anchor); JsonObject response = postCreate(request, json, MessageFormat.format(COMMENT_POST_ERROR_MESSAGE, pr.repository(), pr.pullRequestId())); return StashCollector.extractComment(response, path, line); }
public void postCommentOnPullRequest(PullRequestRef pr, String report) { String request = MessageFormat.format(API_ONE_PR_ALL_COMMENTS, baseUrl, pr.project(), pr.repository(), pr.pullRequestId()); JsonObject json = new JsonObject(); json.put("text", report); postCreate(request, json, MessageFormat.format(COMMENT_POST_ERROR_MESSAGE, pr.repository(), pr.pullRequestId())); }