aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-12-19 13:26:01 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-12-19 18:20:15 +0100
commit785a3106418f3f32402e3fa0e89f2ef3ebe6b254 (patch)
tree5a267ec797ba5a58f35dc2ee5d2a8c5ade83c138 /sonar-ws
parentc688ff54703b1dc3bdbc4a05f919c71b28a23aad (diff)
downloadsonarqube-785a3106418f3f32402e3fa0e89f2ef3ebe6b254.tar.gz
sonarqube-785a3106418f3f32402e3fa0e89f2ef3ebe6b254.zip
SONAR-7286 Create WS api/favorites/search
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/favorite/FavoritesService.java17
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/favorite/FavoritesWsParameters.java1
-rw-r--r--sonar-ws/src/main/protobuf/ws-favorites.proto39
3 files changed, 57 insertions, 0 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/favorite/FavoritesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/favorite/FavoritesService.java
index 91eede2140b..c24e8c3f7a1 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/favorite/FavoritesService.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/favorite/FavoritesService.java
@@ -20,12 +20,17 @@
package org.sonarqube.ws.client.favorite;
+import javax.annotation.Nullable;
+import org.sonar.api.server.ws.WebService.Param;
+import org.sonarqube.ws.Favorites.SearchResponse;
import org.sonarqube.ws.client.BaseService;
+import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.PostRequest;
import org.sonarqube.ws.client.WsConnector;
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.ACTION_ADD;
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.ACTION_REMOVE;
+import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.ACTION_SEARCH;
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.CONTROLLER_FAVORITES;
import static org.sonarqube.ws.client.favorite.FavoritesWsParameters.PARAM_COMPONENT;
@@ -45,4 +50,16 @@ public class FavoritesService extends BaseService {
call(post);
}
+
+ public SearchResponse search(@Nullable Integer page, @Nullable Integer pageSize) {
+ GetRequest get = new GetRequest(path(ACTION_SEARCH));
+ if (page != null) {
+ get.setParam(Param.PAGE, page);
+ }
+ if (pageSize != null) {
+ get.setParam(Param.PAGE_SIZE, pageSize);
+ }
+
+ return call(get, SearchResponse.parser());
+ }
}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/favorite/FavoritesWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/favorite/FavoritesWsParameters.java
index 3c39c735ede..bca2767e415 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/favorite/FavoritesWsParameters.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/favorite/FavoritesWsParameters.java
@@ -25,6 +25,7 @@ public class FavoritesWsParameters {
public static final String ACTION_ADD = "add";
public static final String ACTION_REMOVE = "remove";
+ public static final String ACTION_SEARCH = "search";
public static final String PARAM_COMPONENT = "component";
diff --git a/sonar-ws/src/main/protobuf/ws-favorites.proto b/sonar-ws/src/main/protobuf/ws-favorites.proto
new file mode 100644
index 00000000000..64a75848238
--- /dev/null
+++ b/sonar-ws/src/main/protobuf/ws-favorites.proto
@@ -0,0 +1,39 @@
+// SonarQube, open source software quality management tool.
+// Copyright (C) 2008-2016 SonarSource
+// mailto:contact AT sonarsource DOT com
+//
+// SonarQube 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.
+//
+// SonarQube 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.
+
+syntax = "proto2";
+
+package sonarqube.ws.favorite;
+
+import "ws-commons.proto";
+
+option java_package = "org.sonarqube.ws";
+option java_outer_classname = "Favorites";
+option optimize_for = SPEED;
+
+// WS api/favorites/search
+message SearchResponse {
+ optional sonarqube.ws.commons.Paging paging = 1;
+ repeated Favorite favorites = 2;
+}
+
+message Favorite {
+ optional string key = 1;
+ optional string name = 2;
+ optional string qualifier = 3;
+}