diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2013-05-29 10:21:01 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2013-05-29 10:21:01 +0200 |
commit | 89636790c88a41156293cab10bd18669e285867d (patch) | |
tree | 9f7aa8bc900c39b783d66dc39a848b3de9036887 /sonar-ws-client/src/main/java/org/sonar/wsclient | |
parent | 3e7c244c67ab7095d90e3730acfac04b227559e3 (diff) | |
download | sonarqube-89636790c88a41156293cab10bd18669e285867d.tar.gz sonarqube-89636790c88a41156293cab10bd18669e285867d.zip |
SONAR-3755 Issues WS Client now always returned the created/modified issue
Diffstat (limited to 'sonar-ws-client/src/main/java/org/sonar/wsclient')
-rw-r--r-- | sonar-ws-client/src/main/java/org/sonar/wsclient/issue/DefaultIssueClient.java | 21 | ||||
-rw-r--r-- | sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueClient.java | 10 |
2 files changed, 21 insertions, 10 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/DefaultIssueClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/DefaultIssueClient.java index 3d9e37c44b9..ceef7fe98fc 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/DefaultIssueClient.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/DefaultIssueClient.java @@ -25,6 +25,7 @@ import org.sonar.wsclient.internal.EncodingUtils; import org.sonar.wsclient.internal.HttpRequestFactory; import javax.annotation.Nullable; + import java.util.List; import java.util.Map; @@ -54,38 +55,42 @@ public class DefaultIssueClient implements IssueClient { } @Override - public void create(NewIssue newIssue) { + public Issue create(NewIssue newIssue) { HttpRequest request = requestFactory.post(NewIssue.BASE_URL, newIssue.urlParams()); if (!request.ok()) { throw new IllegalStateException("Fail to create issue. Bad HTTP response status: " + request.code()); } + return createIssueResult(request); } @Override - public void setSeverity(String issueKey, String severity) { + public Issue setSeverity(String issueKey, String severity) { Map<String, Object> params = EncodingUtils.toMap("issue", issueKey, "severity", severity); HttpRequest request = requestFactory.post("/api/issues/set_severity", params); if (!request.ok()) { throw new IllegalStateException("Fail to set severity. Bad HTTP response status: " + request.code()); } + return createIssueResult(request); } @Override - public void assign(String issueKey, @Nullable String assignee) { + public Issue assign(String issueKey, @Nullable String assignee) { Map<String, Object> params = EncodingUtils.toMap("issue", issueKey, "assignee", assignee); HttpRequest request = requestFactory.post("/api/issues/assign", params); if (!request.ok()) { throw new IllegalStateException("Fail to assign issue to user. Bad HTTP response status: " + request.code()); } + return createIssueResult(request); } @Override - public void plan(String issueKey, @Nullable String actionPlanKey) { + public Issue plan(String issueKey, @Nullable String actionPlanKey) { Map<String, Object> params = EncodingUtils.toMap("issue", issueKey, "plan", actionPlanKey); HttpRequest request = requestFactory.post("/api/issues/plan", params); if (!request.ok()) { throw new IllegalStateException("Fail to link action plan. Bad HTTP response status: " + request.code()); } + return createIssueResult(request); } @Override @@ -111,13 +116,19 @@ public class DefaultIssueClient implements IssueClient { } @Override - public void doTransition(String issueKey, String transition) { + public Issue doTransition(String issueKey, String transition) { Map<String, Object> params = EncodingUtils.toMap("issue", issueKey, "transition", transition); HttpRequest request = requestFactory.post("/api/issues/do_transition", params); if (!request.ok()) { throw new IllegalStateException("Fail to execute transition on issue " + issueKey + ".Bad HTTP response status: " + request.code()); } + return createIssueResult(request); } + private Issue createIssueResult(HttpRequest request){ + String json = request.body("UTF-8"); + Map jsonRoot = (Map) JSONValue.parse(json); + return new Issue((Map) jsonRoot.get("issue")); + } } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueClient.java index 324c9e79132..2130d3c92ae 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueClient.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueClient.java @@ -30,18 +30,18 @@ public interface IssueClient { Issues find(IssueQuery query); - void assign(String issueKey, @Nullable String assignee); + Issue assign(String issueKey, @Nullable String assignee); - void setSeverity(String issueKey, String severity); + Issue setSeverity(String issueKey, String severity); - void plan(String issueKey, @Nullable String actionPlan); + Issue plan(String issueKey, @Nullable String actionPlan); IssueComment addComment(String issueKey, String markdownText); - void create(NewIssue issue); + Issue create(NewIssue issue); List<String> transitions(String issueKey); - void doTransition(String issueKey, String transition); + Issue doTransition(String issueKey, String transition); } |