diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-12-04 15:52:09 +0100 |
---|---|---|
committer | Daniel Schwarz <bartfastiel@users.noreply.github.com> | 2017-12-06 14:40:17 +0100 |
commit | 9cba9e0a34bd4b7fa24a7b9c9b8616c0c47273da (patch) | |
tree | 9e2eacc6002d403c9bd32976d90003e1edd68646 /sonar-ws/src/main | |
parent | 2259c6808e011a95fa1d0b8e5681f507befdb4e9 (diff) | |
download | sonarqube-9cba9e0a34bd4b7fa24a7b9c9b8616c0c47273da.tar.gz sonarqube-9cba9e0a34bd4b7fa24a7b9c9b8616c0c47273da.zip |
Remove deprecated MeasuresService
Diffstat (limited to 'sonar-ws/src/main')
14 files changed, 13 insertions, 826 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseService.java index 4c6a0e9449e..46e07dbb804 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseService.java @@ -52,7 +52,7 @@ public abstract class BaseService { return wsConnector.call(request).failIfNotSuccessful(); } - public <T extends Message> T convert(WsResponse response, Parser<T> parser) { + public static <T extends Message> T convert(WsResponse response, Parser<T> parser) { try (InputStream byteStream = response.contentStream()) { byte[] bytes = IOUtils.toByteArray(byteStream); // HTTP header "Content-Type" is not verified. It may be different than protobuf. diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java index 27d06ffac66..71d261c2718 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java @@ -63,7 +63,6 @@ class DefaultWsClient implements WsClient { private final UserGroupsService userGroupsService; private final UserTokensService userTokensService; private final QualitygatesService qualityGatesService; - private final org.sonarqube.ws.client.measure.MeasuresService measuresOld; private final MeasuresService measures; private final SystemService systemService; private final CeService ceService; @@ -90,7 +89,6 @@ class DefaultWsClient implements WsClient { this.userGroupsService = new UserGroupsService(wsConnector); this.userTokensService = new UserTokensService(wsConnector); this.qualityGatesService = new QualitygatesService(wsConnector); - this.measuresOld = new org.sonarqube.ws.client.measure.MeasuresService(wsConnector); this.measures = new MeasuresService(wsConnector); this.systemService = new SystemService(wsConnector); this.ceService = new CeService(wsConnector); @@ -166,11 +164,6 @@ class DefaultWsClient implements WsClient { } @Override - public org.sonarqube.ws.client.measure.MeasuresService measuresOld() { - return measuresOld; - } - - @Override public MeasuresService measures() { return measures; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java index 1de94f492e4..75ac3a18e1c 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java @@ -91,12 +91,6 @@ public interface WsClient { QualitygatesService qualityGates(); - /** - * @deprecated since 7.0 use {@link #measures()} instead - */ - @Deprecated - org.sonarqube.ws.client.measure.MeasuresService measuresOld(); - MeasuresService measures(); SystemService system(); diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentRequest.java deleted file mode 100644 index 4eb5bbcab20..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentRequest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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.measure; - -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class ComponentRequest { - private String componentId; - private String componentKey; - private String component; - private String branch; - private List<String> metricKeys; - private List<String> additionalFields; - private String developerId; - private String developerKey; - - /** - * @deprecated since 6.6, please use {@link #getComponent()} instead - */ - @Deprecated - @CheckForNull - public String getComponentId() { - return componentId; - } - - /** - * @deprecated since 6.6, please use {@link #setComponent(String)} instead - */ - @Deprecated - public ComponentRequest setComponentId(@Nullable String componentId) { - this.componentId = componentId; - return this; - } - - /** - * @deprecated since 6.6, please use {@link #getComponent()} instead - */ - @Deprecated - @CheckForNull - public String getComponentKey() { - return componentKey; - } - - /** - * @deprecated since 6.6, please use {@link #setComponent(String)} instead - */ - @Deprecated - public ComponentRequest setComponentKey(@Nullable String componentKey) { - this.componentKey = componentKey; - return this; - } - - @CheckForNull - public String getComponent() { - return component; - } - - public ComponentRequest setComponent(@Nullable String component) { - this.component = component; - return this; - } - - @CheckForNull - public String getBranch() { - return branch; - } - - public ComponentRequest setBranch(@Nullable String branch) { - this.branch = branch; - return this; - } - - public List<String> getMetricKeys() { - return metricKeys; - } - - public ComponentRequest setMetricKeys(@Nullable List<String> metricKeys) { - this.metricKeys = metricKeys; - return this; - } - - @CheckForNull - public List<String> getAdditionalFields() { - return additionalFields; - } - - public ComponentRequest setAdditionalFields(@Nullable List<String> additionalFields) { - this.additionalFields = additionalFields; - return this; - } - - @CheckForNull - public String getDeveloperId() { - return developerId; - } - - public ComponentRequest setDeveloperId(@Nullable String developerId) { - this.developerId = developerId; - return this; - } - - @CheckForNull - public String getDeveloperKey() { - return developerKey; - } - - public ComponentRequest setDeveloperKey(@Nullable String developerKey) { - this.developerKey = developerKey; - return this; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentTreeRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentTreeRequest.java deleted file mode 100644 index fa6bb474a70..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/ComponentTreeRequest.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * 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.measure; - -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class ComponentTreeRequest { - - private String baseComponentId; - private String baseComponentKey; - private String component; - private String branch; - private String strategy; - private List<String> qualifiers; - private List<String> additionalFields; - private String query; - private List<String> sort; - private Boolean asc; - private String metricSort; - private Integer metricPeriodSort; - private String metricSortFilter; - private List<String> metricKeys; - private Integer page; - private Integer pageSize; - private String developerId; - private String developerKey; - - /** - * @deprecated since 6.6, please use {@link #getComponent()} instead - */ - @Deprecated - @CheckForNull - public String getBaseComponentId() { - return baseComponentId; - } - - /** - * @deprecated since 6.6, please use {@link #setComponent(String)} instead - */ - @Deprecated - public ComponentTreeRequest setBaseComponentId(@Nullable String baseComponentId) { - this.baseComponentId = baseComponentId; - return this; - } - - /** - * @deprecated since 6.6, please use {@link #getComponent()} instead - */ - @Deprecated - @CheckForNull - public String getBaseComponentKey() { - return baseComponentKey; - } - - /** - * @deprecated since 6.6, please use {@link #setComponent(String)} instead - */ - @Deprecated - public ComponentTreeRequest setBaseComponentKey(@Nullable String baseComponentKey) { - this.baseComponentKey = baseComponentKey; - return this; - } - - @CheckForNull - public String getComponent() { - return component; - } - - public ComponentTreeRequest setComponent(@Nullable String component) { - this.component = component; - return this; - } - - @CheckForNull - public String getBranch() { - return branch; - } - - public ComponentTreeRequest setBranch(@Nullable String branch) { - this.branch = branch; - return this; - } - - @CheckForNull - public String getStrategy() { - return strategy; - } - - public ComponentTreeRequest setStrategy(String strategy) { - this.strategy = strategy; - return this; - } - - @CheckForNull - public List<String> getQualifiers() { - return qualifiers; - } - - public ComponentTreeRequest setQualifiers(@Nullable List<String> qualifiers) { - this.qualifiers = qualifiers; - return this; - } - - @CheckForNull - public List<String> getAdditionalFields() { - return additionalFields; - } - - public ComponentTreeRequest setAdditionalFields(@Nullable List<String> additionalFields) { - this.additionalFields = additionalFields; - return this; - } - - @CheckForNull - public String getQuery() { - return query; - } - - public ComponentTreeRequest setQuery(@Nullable String query) { - this.query = query; - return this; - } - - @CheckForNull - public List<String> getSort() { - return sort; - } - - public ComponentTreeRequest setSort(@Nullable List<String> sort) { - this.sort = sort; - return this; - } - - @CheckForNull - public String getMetricSort() { - return metricSort; - } - - public ComponentTreeRequest setMetricSort(@Nullable String metricSort) { - this.metricSort = metricSort; - return this; - } - - @CheckForNull - public String getMetricSortFilter() { - return metricSortFilter; - } - - public ComponentTreeRequest setMetricSortFilter(@Nullable String metricSortFilter) { - this.metricSortFilter = metricSortFilter; - return this; - } - - @CheckForNull - public List<String> getMetricKeys() { - return metricKeys; - } - - public ComponentTreeRequest setMetricKeys(List<String> metricKeys) { - this.metricKeys = metricKeys; - return this; - } - - @CheckForNull - public Boolean getAsc() { - return asc; - } - - public ComponentTreeRequest setAsc(@Nullable Boolean asc) { - this.asc = asc; - return this; - } - - @CheckForNull - public Integer getPage() { - return page; - } - - public ComponentTreeRequest setPage(int page) { - this.page = page; - return this; - } - - @CheckForNull - public Integer getPageSize() { - return pageSize; - } - - public ComponentTreeRequest setPageSize(int pageSize) { - this.pageSize = pageSize; - return this; - } - - @CheckForNull - public Integer getMetricPeriodSort() { - return metricPeriodSort; - } - - public ComponentTreeRequest setMetricPeriodSort(@Nullable Integer metricPeriodSort) { - this.metricPeriodSort = metricPeriodSort; - return this; - } - - @CheckForNull - public String getDeveloperId() { - return developerId; - } - - public ComponentTreeRequest setDeveloperId(@Nullable String developerId) { - this.developerId = developerId; - return this; - } - - @CheckForNull - public String getDeveloperKey() { - return developerKey; - } - - public ComponentTreeRequest setDeveloperKey(@Nullable String developerKey) { - this.developerKey = developerKey; - return this; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java deleted file mode 100644 index e68608e655e..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresService.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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.measure; - -import org.sonar.api.server.ws.WebService.Param; -import org.sonarqube.ws.Measures.ComponentTreeWsResponse; -import org.sonarqube.ws.Measures.ComponentWsResponse; -import org.sonarqube.ws.Measures.SearchHistoryResponse; -import org.sonarqube.ws.Measures.SearchWsResponse; -import org.sonarqube.ws.client.BaseService; -import org.sonarqube.ws.client.GetRequest; -import org.sonarqube.ws.client.WsConnector; - -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ACTION_COMPONENT; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ACTION_COMPONENT_TREE; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.ACTION_SEARCH_HISTORY; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.CONTROLLER_MEASURES; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.DEPRECATED_PARAM_BASE_COMPONENT_ID; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.DEPRECATED_PARAM_BASE_COMPONENT_KEY; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.DEPRECATED_PARAM_COMPONENT_ID; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.DEPRECATED_PARAM_COMPONENT_KEY; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_ADDITIONAL_FIELDS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_BRANCH; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_COMPONENT; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_DEVELOPER_ID; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_DEVELOPER_KEY; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_FROM; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRICS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_KEYS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_SORT; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_SORT_FILTER; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_PROJECT_KEYS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_QUALIFIERS; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_STRATEGY; -import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_TO; - -/** - * @deprecated since 7.0, use {@link org.sonarqube.ws.client.measures.MeasuresService} instead - */ -@Deprecated -public class MeasuresService extends BaseService { - public MeasuresService(WsConnector wsConnector) { - super(wsConnector, CONTROLLER_MEASURES); - } - - public ComponentTreeWsResponse componentTree(ComponentTreeRequest request) { - GetRequest getRequest = new GetRequest(path(ACTION_COMPONENT_TREE)) - .setParam(DEPRECATED_PARAM_BASE_COMPONENT_ID, request.getBaseComponentId()) - .setParam(DEPRECATED_PARAM_BASE_COMPONENT_KEY, request.getBaseComponentKey()) - .setParam(PARAM_COMPONENT, request.getComponent()) - .setParam(PARAM_BRANCH, request.getBranch()) - .setParam(PARAM_STRATEGY, request.getStrategy()) - .setParam(PARAM_QUALIFIERS, inlineMultipleParamValue(request.getQualifiers())) - .setParam(PARAM_METRIC_KEYS, inlineMultipleParamValue(request.getMetricKeys())) - .setParam(PARAM_ADDITIONAL_FIELDS, inlineMultipleParamValue(request.getAdditionalFields())) - .setParam(PARAM_DEVELOPER_ID, request.getDeveloperId()) - .setParam(PARAM_DEVELOPER_KEY, request.getDeveloperKey()) - .setParam("q", request.getQuery()) - .setParam("p", request.getPage()) - .setParam("ps", request.getPageSize()) - .setParam("s", inlineMultipleParamValue(request.getSort())) - .setParam("asc", request.getAsc()) - .setParam(PARAM_METRIC_SORT, request.getMetricSort()) - .setParam(PARAM_METRIC_SORT_FILTER, request.getMetricSortFilter()); - - return call(getRequest, ComponentTreeWsResponse.parser()); - } - - public ComponentWsResponse component(ComponentRequest request) { - GetRequest getRequest = new GetRequest(path(ACTION_COMPONENT)) - .setParam(DEPRECATED_PARAM_COMPONENT_ID, request.getComponentId()) - .setParam(DEPRECATED_PARAM_COMPONENT_KEY, request.getComponentKey()) - .setParam(PARAM_COMPONENT, request.getComponent()) - .setParam(PARAM_BRANCH, request.getBranch()) - .setParam(PARAM_ADDITIONAL_FIELDS, inlineMultipleParamValue(request.getAdditionalFields())) - .setParam(PARAM_METRIC_KEYS, inlineMultipleParamValue(request.getMetricKeys())) - .setParam(PARAM_DEVELOPER_ID, request.getDeveloperId()) - .setParam(PARAM_DEVELOPER_KEY, request.getDeveloperKey()); - - return call(getRequest, ComponentWsResponse.parser()); - } - - public SearchHistoryResponse searchHistory(SearchHistoryRequest request) { - GetRequest getRequest = new GetRequest(path(ACTION_SEARCH_HISTORY)) - .setParam(PARAM_COMPONENT, request.getComponent()) - .setParam(PARAM_BRANCH, request.getBranch()) - .setParam(PARAM_METRICS, inlineMultipleParamValue(request.getMetrics())) - .setParam(PARAM_FROM, request.getFrom()) - .setParam(PARAM_TO, request.getTo()) - .setParam(Param.PAGE, request.getPage()) - .setParam(Param.PAGE_SIZE, request.getPageSize()); - - return call(getRequest, SearchHistoryResponse.parser()); - } - - public SearchWsResponse search(SearchRequest request) { - GetRequest getRequest = new GetRequest(path(ACTION_SEARCH_HISTORY)) - .setParam(PARAM_PROJECT_KEYS, inlineMultipleParamValue(request.getProjectKeys())) - .setParam(PARAM_METRIC_KEYS, inlineMultipleParamValue(request.getMetricKeys())); - return call(getRequest, SearchWsResponse.parser()); - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java deleted file mode 100644 index 519ec102d41..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/MeasuresWsParameters.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.measure; - -import com.google.common.collect.ImmutableSortedSet; -import java.util.Set; - -public class MeasuresWsParameters { - public static final String CONTROLLER_MEASURES = "api/measures"; - - // actions - public static final String ACTION_COMPONENT_TREE = "component_tree"; - public static final String ACTION_COMPONENT = "component"; - public static final String ACTION_SEARCH_HISTORY = "search_history"; - - // parameters - public static final String DEPRECATED_PARAM_BASE_COMPONENT_ID = "baseComponentId"; - public static final String DEPRECATED_PARAM_BASE_COMPONENT_KEY = "baseComponentKey"; - public static final String PARAM_COMPONENT = "component"; - public static final String PARAM_BRANCH = "branch"; - public static final String PARAM_STRATEGY = "strategy"; - public static final String PARAM_QUALIFIERS = "qualifiers"; - public static final String PARAM_METRICS = "metrics"; - public static final String PARAM_METRIC_KEYS = "metricKeys"; - public static final String PARAM_METRIC_SORT = "metricSort"; - public static final String PARAM_METRIC_PERIOD_SORT = "metricPeriodSort"; - public static final String PARAM_METRIC_SORT_FILTER = "metricSortFilter"; - public static final String PARAM_ADDITIONAL_FIELDS = "additionalFields"; - public static final String DEPRECATED_PARAM_COMPONENT_ID = "componentId"; - public static final String DEPRECATED_PARAM_COMPONENT_KEY = "componentKey"; - public static final String PARAM_PROJECT_KEYS = "projectKeys"; - public static final String PARAM_DEVELOPER_ID = "developerId"; - public static final String PARAM_DEVELOPER_KEY = "developerKey"; - public static final String PARAM_FROM = "from"; - public static final String PARAM_TO = "to"; - - public static final String ADDITIONAL_METRICS = "metrics"; - public static final String ADDITIONAL_PERIODS = "periods"; - - public static final Set<String> ADDITIONAL_FIELDS = ImmutableSortedSet.of(ADDITIONAL_METRICS, ADDITIONAL_PERIODS); - - private MeasuresWsParameters() { - // static constants only - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchHistoryRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchHistoryRequest.java deleted file mode 100644 index b99b9b77b43..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchHistoryRequest.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * 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.measure; - -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import static java.lang.String.format; - -public class SearchHistoryRequest { - public static final int MAX_PAGE_SIZE = 1_000; - public static final int DEFAULT_PAGE_SIZE = 100; - - private final String component; - private final String branch; - private final List<String> metrics; - private final String from; - private final String to; - private final int page; - private final int pageSize; - - public SearchHistoryRequest(Builder builder) { - this.component = builder.component; - this.branch = builder.branch; - this.metrics = builder.metrics; - this.from = builder.from; - this.to = builder.to; - this.page = builder.page; - this.pageSize = builder.pageSize; - } - - public String getComponent() { - return component; - } - - @CheckForNull - public String getBranch() { - return branch; - } - - public List<String> getMetrics() { - return metrics; - } - - @CheckForNull - public String getFrom() { - return from; - } - - @CheckForNull - public String getTo() { - return to; - } - - public int getPage() { - return page; - } - - public int getPageSize() { - return pageSize; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String component; - private String branch; - private List<String> metrics; - private String from; - private String to; - private int page = 1; - private int pageSize = DEFAULT_PAGE_SIZE; - - private Builder() { - // enforce build factory method - } - - public Builder setComponent(String component) { - this.component = component; - return this; - } - - public Builder setBranch(@Nullable String branch) { - this.branch = branch; - return this; - } - - public Builder setMetrics(List<String> metrics) { - this.metrics = metrics; - return this; - } - - public Builder setFrom(@Nullable String from) { - this.from = from; - return this; - } - - public Builder setTo(@Nullable String to) { - this.to = to; - return this; - } - - public Builder setPage(int page) { - this.page = page; - return this; - } - - public Builder setPageSize(int pageSize) { - this.pageSize = pageSize; - return this; - } - - public SearchHistoryRequest build() { - checkArgument(component != null && !component.isEmpty(), "Component key is required"); - checkArgument(metrics != null && !metrics.isEmpty(), "Metric keys are required"); - checkArgument(pageSize <= MAX_PAGE_SIZE, "Page size (%d) must be lower than or equal to %d", pageSize, MAX_PAGE_SIZE); - - return new SearchHistoryRequest(this); - } - - private static void checkArgument(boolean condition, String message, Object... args) { - if (!condition) { - throw new IllegalArgumentException(format(message, args)); - } - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchRequest.java deleted file mode 100644 index 5c8cc2bec0e..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/SearchRequest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.measure; - -import java.util.List; - -import static com.google.common.base.Preconditions.checkArgument; - -public class SearchRequest { - private static final int MAX_NB_PROJECTS = 100; - - private final List<String> metricKeys; - private final List<String> projectKeys; - - public SearchRequest(Builder builder) { - metricKeys = builder.metricKeys; - projectKeys = builder.projectKeys; - } - - public List<String> getMetricKeys() { - return metricKeys; - } - - public List<String> getProjectKeys() { - return projectKeys; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private List<String> metricKeys; - private List<String> projectKeys; - - private Builder() { - // enforce method constructor - } - - public Builder setMetricKeys(List<String> metricKeys) { - this.metricKeys = metricKeys; - return this; - } - - public Builder setProjectKeys(List<String> projectKeys) { - this.projectKeys = projectKeys; - return this; - } - - public SearchRequest build() { - checkArgument(metricKeys != null && !metricKeys.isEmpty(), "Metric keys must be provided"); - checkArgument(projectKeys != null && !projectKeys.isEmpty(), "Project keys must be provided"); - int nbComponents = projectKeys.size(); - checkArgument(nbComponents <= MAX_NB_PROJECTS, - "%s projects provided, more than maximum authorized (%s)", nbComponents, MAX_NB_PROJECTS); - return new SearchRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/package-info.java deleted file mode 100644 index f4cc7064364..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measure/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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. - */ -@ParametersAreNonnullByDefault -package org.sonarqube.ws.client.measure; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/ComponentRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/ComponentRequest.java index eea21c7966c..8611025b452 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/ComponentRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/ComponentRequest.java @@ -37,7 +37,7 @@ public class ComponentRequest { private String componentId; private String developerId; private String developerKey; - private String metricKeys; + private List<String> metricKeys; /** * Example value: "periods,metrics" @@ -125,12 +125,12 @@ public class ComponentRequest { * This is a mandatory parameter. * Example value: "ncloc,complexity,violations" */ - public ComponentRequest setMetricKeys(String metricKeys) { + public ComponentRequest setMetricKeys(List<String> metricKeys) { this.metricKeys = metricKeys; return this; } - public String getMetricKeys() { + public List<String> getMetricKeys() { return metricKeys; } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/ComponentTreeRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/ComponentTreeRequest.java index c63da756229..a7373c34f45 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/ComponentTreeRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/ComponentTreeRequest.java @@ -38,7 +38,7 @@ public class ComponentTreeRequest { private String component; private String developerId; private String developerKey; - private String metricKeys; + private List<String> metricKeys; private String metricPeriodSort; private String metricSort; private String metricSortFilter; @@ -153,12 +153,12 @@ public class ComponentTreeRequest { * This is a mandatory parameter. * Example value: "ncloc,complexity,violations" */ - public ComponentTreeRequest setMetricKeys(String metricKeys) { + public ComponentTreeRequest setMetricKeys(List<String> metricKeys) { this.metricKeys = metricKeys; return this; } - public String getMetricKeys() { + public List<String> getMetricKeys() { return metricKeys; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/MeasuresService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/MeasuresService.java index 7422d8aae2d..bbea8ca23d9 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/MeasuresService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/MeasuresService.java @@ -57,7 +57,7 @@ public class MeasuresService extends BaseService { .setParam("componentId", request.getComponentId()) .setParam("developerId", request.getDeveloperId()) .setParam("developerKey", request.getDeveloperKey()) - .setParam("metricKeys", request.getMetricKeys()), + .setParam("metricKeys", request.getMetricKeys() == null ? null : request.getMetricKeys().stream().collect(Collectors.joining(","))), ComponentWsResponse.parser()); } @@ -78,7 +78,7 @@ public class MeasuresService extends BaseService { .setParam("component", request.getComponent()) .setParam("developerId", request.getDeveloperId()) .setParam("developerKey", request.getDeveloperKey()) - .setParam("metricKeys", request.getMetricKeys()) + .setParam("metricKeys", request.getMetricKeys() == null ? null : request.getMetricKeys().stream().collect(Collectors.joining(","))) .setParam("metricPeriodSort", request.getMetricPeriodSort()) .setParam("metricSort", request.getMetricSort()) .setParam("metricSortFilter", request.getMetricSortFilter()) @@ -101,7 +101,7 @@ public class MeasuresService extends BaseService { public SearchWsResponse search(SearchRequest request) { return call( new GetRequest(path("search")) - .setParam("metricKeys", request.getMetricKeys()) + .setParam("metricKeys", request.getMetricKeys() == null ? null : request.getMetricKeys().stream().collect(Collectors.joining(","))) .setParam("projectKeys", request.getProjectKeys() == null ? null : request.getProjectKeys().stream().collect(Collectors.joining(","))), SearchWsResponse.parser()); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/SearchRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/SearchRequest.java index bd7614fb216..422c6ffa977 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/SearchRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/measures/SearchRequest.java @@ -31,19 +31,19 @@ import javax.annotation.Generated; @Generated("sonar-ws-generator") public class SearchRequest { - private String metricKeys; + private List<String> metricKeys; private List<String> projectKeys; /** * This is a mandatory parameter. * Example value: "ncloc,complexity,violations" */ - public SearchRequest setMetricKeys(String metricKeys) { + public SearchRequest setMetricKeys(List<String> metricKeys) { this.metricKeys = metricKeys; return this; } - public String getMetricKeys() { + public List<String> getMetricKeys() { return metricKeys; } |