diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-01-04 10:12:01 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-01-05 17:30:17 +0100 |
commit | de4bd7cf6c5ac9dba12040b19635ab4305ce2bde (patch) | |
tree | 478f5732b6470741991507e2822d757adc2c65de /sonar-ws | |
parent | 094521fd01f0f37ad98e2b28217a3f569be14609 (diff) | |
download | sonarqube-de4bd7cf6c5ac9dba12040b19635ab4305ce2bde.tar.gz sonarqube-de4bd7cf6c5ac9dba12040b19635ab4305ce2bde.zip |
SONAR-7131 WS components/show show one component and its ancestors
Diffstat (limited to 'sonar-ws')
4 files changed, 92 insertions, 1 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 fcee519bdb0..2630839acf4 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 @@ -20,11 +20,23 @@ package org.sonarqube.ws.client.component; +import com.google.common.base.Joiner; import org.sonarqube.ws.WsComponents.SearchWsResponse; +import org.sonarqube.ws.WsComponents.ShowWsResponse; +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 static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_SHOW; +import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_TREE; +import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_BASE_COMPONENT_ID; +import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_BASE_COMPONENT_KEY; +import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ID; +import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_KEY; +import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_QUALIFIERS; +import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_STRATEGY; + public class ComponentsService extends BaseService { public ComponentsService(WsConnector wsConnector) { @@ -33,10 +45,30 @@ public class ComponentsService extends BaseService { public SearchWsResponse search(SearchWsRequest request) { GetRequest get = new GetRequest(path("search")) - .setParam("qualifiers", request.getQualifiers()) + .setParam("qualifiers", Joiner.on(",").join(request.getQualifiers())) .setParam("p", request.getPage()) .setParam("ps", request.getPageSize()) .setParam("q", request.getQuery()); return call(get, SearchWsResponse.parser()); } + + public TreeWsResponse tree(TreeWsRequest request) { + GetRequest get = new GetRequest(path(ACTION_TREE)) + .setParam(PARAM_BASE_COMPONENT_ID, request.getBaseComponentId()) + .setParam(PARAM_BASE_COMPONENT_KEY, request.getBaseComponentKey()) + .setParam(PARAM_QUALIFIERS, request.getQualifiers()) + .setParam(PARAM_STRATEGY, request.getStrategy()) + .setParam("p", request.getPage()) + .setParam("ps", request.getPageSize()) + .setParam("q", request.getQuery()) + .setParam("s", request.getSort()); + return call(get, TreeWsResponse.parser()); + } + + public ShowWsResponse show(ShowWsRequest request) { + GetRequest get = new GetRequest(path(ACTION_SHOW)) + .setParam(PARAM_ID, request.getId()) + .setParam(PARAM_KEY, request.getKey()); + return call(get, ShowWsResponse.parser()); + } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsWsParameters.java index b9739c4480e..02d6fd688bc 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsWsParameters.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsWsParameters.java @@ -27,6 +27,7 @@ public class ComponentsWsParameters { //actions public static final String ACTION_TREE = "tree"; + public static final String ACTION_SHOW = "show"; // parameters public static final String PARAM_QUALIFIERS = "qualifiers"; @@ -34,4 +35,6 @@ public class ComponentsWsParameters { public static final String PARAM_BASE_COMPONENT_ID = "baseComponentId"; public static final String PARAM_BASE_COMPONENT_KEY = "baseComponentKey"; public static final String PARAM_STRATEGY = "strategy"; + public static final String PARAM_ID = "id"; + public static final String PARAM_KEY = "key"; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ShowWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ShowWsRequest.java new file mode 100644 index 00000000000..37a7c77f040 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ShowWsRequest.java @@ -0,0 +1,49 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 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. + */ + +package org.sonarqube.ws.client.component; + +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; + +public class ShowWsRequest { + @CheckForNull + private String id; + @CheckForNull + private String key; + + public String getId() { + return id; + } + + public ShowWsRequest setId(@Nullable String id) { + this.id = id; + return this; + } + + public String getKey() { + return key; + } + + public ShowWsRequest setKey(@Nullable String key) { + this.key = key; + return this; + } +} diff --git a/sonar-ws/src/main/protobuf/ws-components.proto b/sonar-ws/src/main/protobuf/ws-components.proto index 03ded8c9bb7..d9e86b0e0e4 100644 --- a/sonar-ws/src/main/protobuf/ws-components.proto +++ b/sonar-ws/src/main/protobuf/ws-components.proto @@ -39,6 +39,13 @@ message TreeWsResponse { repeated Component components = 3; } +// WS api/components/show +message ShowWsResponse { + optional sonarqube.ws.commons.Paging paging = 1; + optional Component component = 2; + repeated Component ancestors = 3; +} + message Component { optional string id = 1; optional string key = 2; |