aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2017-09-25 16:56:35 +0200
committerStas Vilchik <stas.vilchik@sonarsource.com>2017-10-02 17:18:15 +0200
commitdd0fa0f97aece83d26772a839ead80dc20a5afad (patch)
treea3ac360a4eadf108d9d23533f13a8fe1dc60e842 /sonar-ws
parentbb0bd260f3742c010b9e7034ea5d6947e694a130 (diff)
downloadsonarqube-dd0fa0f97aece83d26772a839ead80dc20a5afad.tar.gz
sonarqube-dd0fa0f97aece83d26772a839ead80dc20a5afad.zip
SONAR-1330 Search for groups allowed to edit single quality profile
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java15
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchGroupsRequest.java127
-rw-r--r--sonar-ws/src/main/protobuf/ws-qualityprofiles.proto12
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java27
4 files changed, 181 insertions, 0 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java
index ed65f9d6dab..fe2a4171b73 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesService.java
@@ -23,6 +23,7 @@ import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.QualityProfiles;
import org.sonarqube.ws.QualityProfiles.CopyWsResponse;
import org.sonarqube.ws.QualityProfiles.CreateWsResponse;
+import org.sonarqube.ws.QualityProfiles.SearchGroupsResponse;
import org.sonarqube.ws.QualityProfiles.SearchUsersResponse;
import org.sonarqube.ws.QualityProfiles.SearchWsResponse;
import org.sonarqube.ws.QualityProfiles.ShowResponse;
@@ -49,6 +50,7 @@ import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_REMOVE_USER;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_RESTORE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SEARCH;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SEARCH_GROUPS;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SEARCH_USERS;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SET_DEFAULT;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SHOW;
@@ -228,4 +230,17 @@ public class QualityProfilesService extends BaseService {
.setParam(PARAM_LANGUAGE, request.getLanguage())
.setParam(PARAM_GROUP, request.getGroup()));
}
+
+ public SearchGroupsResponse searchGroups(SearchGroupsRequest request) {
+ return call(
+ new GetRequest(path(ACTION_SEARCH_GROUPS))
+ .setParam(PARAM_ORGANIZATION, request.getOrganization())
+ .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile())
+ .setParam(PARAM_LANGUAGE, request.getLanguage())
+ .setParam(TEXT_QUERY, request.getQuery())
+ .setParam(SELECTED, request.getSelected())
+ .setParam(PAGE, request.getPage())
+ .setParam(PAGE_SIZE, request.getPageSize()),
+ SearchGroupsResponse.parser());
+ }
}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchGroupsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchGroupsRequest.java
new file mode 100644
index 00000000000..bf515ef724b
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualityprofile/SearchGroupsRequest.java
@@ -0,0 +1,127 @@
+/*
+ * 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.qualityprofile;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
+public class SearchGroupsRequest {
+
+ private String organization;
+ private String qualityProfile;
+ private String language;
+ private String selected;
+ private String query;
+ private Integer page;
+ private Integer pageSize;
+
+ private SearchGroupsRequest(Builder builder) {
+ this.organization = builder.organization;
+ this.qualityProfile = builder.qualityProfile;
+ this.language = builder.language;
+ this.selected = builder.selected;
+ this.query = builder.query;
+ this.page = builder.page;
+ this.pageSize = builder.pageSize;
+ }
+
+ @CheckForNull
+ public String getOrganization() {
+ return organization;
+ }
+
+ public String getQualityProfile() {
+ return qualityProfile;
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ @CheckForNull
+ public String getQuery() {
+ return query;
+ }
+
+ public String getSelected() {
+ return selected;
+ }
+
+ public Integer getPage() {
+ return page;
+ }
+
+ public Integer getPageSize() {
+ return pageSize;
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private String organization;
+ private String qualityProfile;
+ private String language;
+ private String selected;
+ private String query;
+ private Integer page;
+ private Integer pageSize;
+
+ public Builder setOrganization(@Nullable String organization) {
+ this.organization = organization;
+ return this;
+ }
+
+ public Builder setQualityProfile(String qualityProfile) {
+ this.qualityProfile = qualityProfile;
+ return this;
+ }
+
+ public Builder setLanguage(String language) {
+ this.language = language;
+ return this;
+ }
+
+ public Builder setSelected(String selected) {
+ this.selected = selected;
+ return this;
+ }
+
+ public Builder setQuery(@Nullable String query) {
+ this.query = query;
+ return this;
+ }
+
+ public Builder setPage(Integer page) {
+ this.page = page;
+ return this;
+ }
+
+ public Builder setPageSize(Integer pageSize) {
+ this.pageSize = pageSize;
+ return this;
+ }
+
+ public SearchGroupsRequest build() {
+ return new SearchGroupsRequest(this);
+ }
+ }
+}
diff --git a/sonar-ws/src/main/protobuf/ws-qualityprofiles.proto b/sonar-ws/src/main/protobuf/ws-qualityprofiles.proto
index 2300e8baa77..cd3143aa43a 100644
--- a/sonar-ws/src/main/protobuf/ws-qualityprofiles.proto
+++ b/sonar-ws/src/main/protobuf/ws-qualityprofiles.proto
@@ -152,3 +152,15 @@ message SearchUsersResponse {
optional bool selected = 4;
}
}
+
+// WS api/qualityprofiles/search_groups
+message SearchGroupsResponse {
+ optional sonarqube.ws.commons.Paging paging = 1;
+ repeated Group groups = 2;
+
+ message Group {
+ optional string name = 1;
+ optional string description = 2;
+ optional bool selected = 3;
+ }
+}
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java
index a3dd96ee3c0..8d90866470c 100644
--- a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java
+++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java
@@ -306,4 +306,31 @@ public class QualityProfilesServiceTest {
.hasParam(PARAM_GROUP, "users")
.andNoOtherParam();
}
+
+ @Test
+ public void search_groups() {
+ underTest.searchGroups(SearchGroupsRequest.builder()
+ .setOrganization("O1")
+ .setQualityProfile("P1")
+ .setLanguage("Xoo")
+ .setQuery("users")
+ .setSelected("all")
+ .setPage(5)
+ .setPageSize(50)
+ .build()
+ );
+ GetRequest getRequest = serviceTester.getGetRequest();
+
+ assertThat(serviceTester.getGetParser()).isSameAs(QualityProfiles.SearchGroupsResponse.parser());
+ serviceTester.assertThat(getRequest)
+ .hasPath("search_groups")
+ .hasParam(PARAM_ORGANIZATION, "O1")
+ .hasParam(PARAM_QUALITY_PROFILE, "P1")
+ .hasParam(PARAM_LANGUAGE, "Xoo")
+ .hasParam(TEXT_QUERY, "users")
+ .hasParam(SELECTED, "all")
+ .hasParam(PAGE, 5)
+ .hasParam(PAGE_SIZE, 50)
+ .andNoOtherParam();
+ }
}