aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws/src/main
diff options
context:
space:
mode:
authorDaniel Schwarz <bartfastiel@users.noreply.github.com>2017-08-14 14:34:29 +0200
committerGitHub <noreply@github.com>2017-08-14 14:34:29 +0200
commitffff02cbed3e5f94bbf0c1718425d66e19ac3901 (patch)
tree6d99fd0df0913d32b37da9c8b3a280af6ad856d1 /sonar-ws/src/main
parent3a98cfe82a4eaf08eade2517dd115837b0126799 (diff)
downloadsonarqube-ffff02cbed3e5f94bbf0c1718425d66e19ac3901.tar.gz
sonarqube-ffff02cbed3e5f94bbf0c1718425d66e19ac3901.zip
SONAR-9704 verify that the compute engine is resilient
Diffstat (limited to 'sonar-ws/src/main')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java11
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/component/SuggestionsWsRequest.java95
2 files changed, 106 insertions, 0 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java
index 005e47d92ed..b7186af495f 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java
@@ -21,6 +21,7 @@ package org.sonarqube.ws.client.component;
import com.google.common.base.Joiner;
import java.util.List;
+import java.util.stream.Collectors;
import org.sonarqube.ws.WsComponents.SearchProjectsWsResponse;
import org.sonarqube.ws.WsComponents.SearchWsResponse;
import org.sonarqube.ws.WsComponents.ShowWsResponse;
@@ -28,11 +29,13 @@ import org.sonarqube.ws.WsComponents.TreeWsResponse;
import org.sonarqube.ws.client.BaseService;
import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.WsConnector;
+import org.sonarqube.ws.client.WsResponse;
import static org.sonar.api.server.ws.WebService.Param;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_SEARCH;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_SEARCH_PROJECTS;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_SHOW;
+import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_SUGGESTIONS;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_TREE;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.CONTROLLER_COMPONENTS;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_COMPONENT;
@@ -92,4 +95,12 @@ public class ComponentsService extends BaseService {
.setParam(Param.FIELDS, !additionalFields.isEmpty() ? inlineMultipleParamValue(additionalFields) : null);
return call(get, SearchProjectsWsResponse.parser());
}
+
+ public WsResponse suggestions(SuggestionsWsRequest request) {
+ GetRequest get = new GetRequest(path(ACTION_SUGGESTIONS))
+ .setParam("more", request.getMore() == null ? null : request.getMore().toString())
+ .setParam("recentlyBrowsed", request.getRecentlyBrowsed().stream().collect(Collectors.joining(",")))
+ .setParam("s", request.getS());
+ return call(get);
+ }
}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/SuggestionsWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/SuggestionsWsRequest.java
new file mode 100644
index 00000000000..ca7fd84d11c
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/SuggestionsWsRequest.java
@@ -0,0 +1,95 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonarqube.ws.client.component;
+
+import java.util.Collections;
+import java.util.List;
+
+public class SuggestionsWsRequest {
+
+ public static final int MAX_PAGE_SIZE = 500;
+ public static final int DEFAULT_PAGE_SIZE = 100;
+
+ public enum More {
+ VW,
+ SVW,
+ APP,
+ TRK,
+ BRC,
+ FIL,
+ UTS
+ }
+
+ private final More more;
+ private final List<String> recentlyBrowsed;
+ private final String s;
+
+ private SuggestionsWsRequest(Builder builder) {
+ this.more = builder.more;
+ this.recentlyBrowsed = builder.recentlyBrowsed;
+ this.s = builder.s;
+ }
+
+ public More getMore() {
+ return more;
+ }
+
+ public List<String> getRecentlyBrowsed() {
+ return recentlyBrowsed;
+ }
+
+ public String getS() {
+ return s;
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+
+ private More more;
+ private List<String> recentlyBrowsed = Collections.emptyList();
+ private String s;
+
+ private Builder() {
+ // enforce static factory method
+ }
+
+ public Builder setMore(More more) {
+ this.more = more;
+ return this;
+ }
+
+ public Builder setRecentlyBrowsed(List<String> recentlyBrowsed) {
+ this.recentlyBrowsed = recentlyBrowsed;
+ return this;
+ }
+
+ public Builder setS(String s) {
+ this.s = s;
+ return this;
+ }
+
+ public SuggestionsWsRequest build() {
+ return new SuggestionsWsRequest(this);
+ }
+ }
+}