aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacek Poreda <jacek.poreda@sonarsource.com>2023-08-02 09:03:29 +0200
committersonartech <sonartech@sonarsource.com>2023-08-02 20:03:03 +0000
commit4f214cb37958b2cceddfe33c3bd10d7de260e219 (patch)
tree129333387b393d0fa3c26354510fcd5f080b4441
parentcea8d3b9c04ee7b61be40d50290fe5554d8dd633 (diff)
downloadsonarqube-4f214cb37958b2cceddfe33c3bd10d7de260e219.tar.gz
sonarqube-4f214cb37958b2cceddfe33c3bd10d7de260e219.zip
Revert "SONAR-19233 Drop deprecated paging response fields"
This reverts commit 9db233a378f3590359054b908c82d06ae095930b.
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangelogActionIT.java10
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java14
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/UsersActionIT.java9
-rw-r--r--server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionComponentsIT/no_issue.json4
-rw-r--r--server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/apply_paging_with_one_component.json3
-rw-r--r--server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/default_page_size_is_100.json3
-rw-r--r--server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/empty_result.json3
-rw-r--r--server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_leak_period.json3
-rw-r--r--server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_leak_period_has_no_effect_on_prs.json3
-rw-r--r--server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_main_scope.json3
-rw-r--r--server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_main_scope_2.json3
-rw-r--r--server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_test_scope.json3
-rw-r--r--server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/no_issue.json1
-rw-r--r--server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/paging.json3
-rw-r--r--server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/result_for_rule_search.json3
-rw-r--r--server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/search_by_variants_with_facets.json3
-rw-r--r--server/sonar-webserver-webapi/src/it/resources/org/sonar/server/qualityprofile/ws/ChangelogActionIT/changelog_example.json43
-rw-r--r--server/sonar-webserver-webapi/src/it/resources/org/sonar/server/rule/ws/SearchActionIT/paging.json3
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java1
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java9
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java18
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java10
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java18
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/DefaultActiveRulesLoaderTest.java7
-rw-r--r--sonar-ws/src/main/protobuf/ws-issues.proto6
-rw-r--r--sonar-ws/src/main/protobuf/ws-rules.proto7
27 files changed, 160 insertions, 37 deletions
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangelogActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangelogActionIT.java
index d47b9957a4e..7d282d04319 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangelogActionIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangelogActionIT.java
@@ -80,6 +80,9 @@ public class ChangelogActionIT {
.getInput();
assertJson(response).isSimilarTo("{\n" +
+ " \"total\": 1,\n" +
+ " \"p\": 1,\n" +
+ " \"ps\": 50,\n" +
" \"paging\": {\n" +
" \"pageIndex\": 1,\n" +
" \"pageSize\": 50,\n" +
@@ -176,7 +179,7 @@ public class ChangelogActionIT {
.execute()
.getInput();
- assertJson(response).isSimilarTo("{\"paging\":{\"pageIndex\":1,\"pageSize\":50,\"total\":0},\"events\":[]}");
+ assertJson(response).isSimilarTo("{\"total\":0,\"p\":1,\"ps\":50,\"paging\":{\"pageIndex\":1,\"pageSize\":50,\"total\":0},\"events\":[]}");
}
@Test
@@ -344,14 +347,13 @@ public class ChangelogActionIT {
.setChangeType(ActiveRuleChange.Type.ACTIVATED.name())
.setData(ImmutableMap.of("severity", "MAJOR", "param_format", "^[A-Z][a-zA-Z0-9]*$", "ruleUuid", rule3.getUuid())));
- String result = ws.newRequest()
+ ws.newRequest()
.setMethod("GET")
.setParam(PARAM_LANGUAGE, profile.getLanguage())
.setParam(PARAM_QUALITY_PROFILE, profile.getName())
.setParam("ps", "10")
.execute()
- .getInput();
- assertJson(result).isSimilarTo(ws.getDef().responseExampleAsString());
+ .assertJson(this.getClass(), "changelog_example.json");
}
@Test
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java
index 96ffd6534a7..a99e9d26800 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java
@@ -163,6 +163,8 @@ public class SearchActionIT {
.setParam(WebService.Param.FIELDS, "actives")
.executeProtobuf(Rules.SearchResponse.class);
+ assertThat(response.getTotal()).isZero();
+ assertThat(response.getP()).isOne();
assertThat(response.getPaging().getTotal()).isZero();
assertThat(response.getPaging().getPageIndex()).isOne();
assertThat(response.getPaging().getPageSize()).isNotZero();
@@ -556,6 +558,7 @@ public class SearchActionIT {
SearchResponse result = ws.newRequest()
.setParam("f", "langName")
.executeProtobuf(SearchResponse.class);
+ assertThat(result.getTotal()).isOne();
assertThat(result.getPaging().getTotal()).isOne();
assertThat(result.getPaging().getPageIndex()).isOne();
assertThat(result.getRulesCount()).isOne();
@@ -580,6 +583,7 @@ public class SearchActionIT {
SearchResponse result = ws.newRequest()
.setParam("f", "debtRemFn,remFnOverloaded,defaultDebtRemFn")
.executeProtobuf(SearchResponse.class);
+ assertThat(result.getTotal()).isOne();
assertThat(result.getPaging().getTotal()).isOne();
assertThat(result.getPaging().getPageIndex()).isOne();
assertThat(result.getRulesCount()).isOne();
@@ -613,6 +617,7 @@ public class SearchActionIT {
SearchResponse result = ws.newRequest()
.setParam("f", "debtRemFn,remFnOverloaded,defaultDebtRemFn")
.executeProtobuf(SearchResponse.class);
+ assertThat(result.getTotal()).isOne();
assertThat(result.getPaging().getTotal()).isOne();
assertThat(result.getPaging().getPageIndex()).isOne();
assertThat(result.getRulesCount()).isOne();
@@ -646,6 +651,7 @@ public class SearchActionIT {
SearchResponse result = ws.newRequest()
.setParam("f", "debtRemFn,remFnOverloaded,defaultDebtRemFn")
.executeProtobuf(SearchResponse.class);
+ assertThat(result.getTotal()).isOne();
assertThat(result.getPaging().getTotal()).isOne();
assertThat(result.getPaging().getPageIndex()).isOne();
assertThat(result.getRulesCount()).isOne();
@@ -677,6 +683,7 @@ public class SearchActionIT {
.setParam("f", "isTemplate")
.setParam("is_template", "true")
.executeProtobuf(SearchResponse.class);
+ assertThat(result.getTotal()).isOne();
assertThat(result.getPaging().getTotal()).isOne();
assertThat(result.getPaging().getPageIndex()).isOne();
assertThat(result.getRulesCount()).isOne();
@@ -700,6 +707,7 @@ public class SearchActionIT {
.setParam("f", "templateKey")
.setParam("template_key", templateRule.getRepositoryKey() + ":" + templateRule.getRuleKey())
.executeProtobuf(SearchResponse.class);
+ assertThat(result.getTotal()).isOne();
assertThat(result.getPaging().getTotal()).isOne();
assertThat(result.getPaging().getPageIndex()).isOne();
assertThat(result.getRulesCount()).isOne();
@@ -717,6 +725,7 @@ public class SearchActionIT {
SearchResponse result = ws.newRequest().executeProtobuf(SearchResponse.class);
+ assertThat(result.getTotal()).isZero();
assertThat(result.getPaging().getTotal()).isZero();
assertThat(result.getPaging().getPageIndex()).isOne();
assertThat(result.getRulesCount()).isZero();
@@ -735,6 +744,7 @@ public class SearchActionIT {
.setParam("q", rule.getName())
.setParam("activation", "true")
.executeProtobuf(SearchResponse.class);
+ assertThat(result.getTotal()).isOne();
assertThat(result.getPaging().getTotal()).isOne();
assertThat(result.getPaging().getPageIndex()).isOne();
assertThat(result.getRulesCount()).isOne();
@@ -779,6 +789,7 @@ public class SearchActionIT {
.setParam("activation", "true")
.setParam("qprofile", profile.getKee())
.executeProtobuf(SearchResponse.class);
+ assertThat(result.getTotal()).isOne();
assertThat(result.getPaging().getTotal()).isOne();
assertThat(result.getPaging().getPageIndex()).isOne();
assertThat(result.getRulesCount()).isOne();
@@ -835,6 +846,7 @@ public class SearchActionIT {
.setParam("qprofile", profile.getKee())
.executeProtobuf(SearchResponse.class);
+ assertThat(result.getTotal()).isOne();
assertThat(result.getPaging().getTotal()).isOne();
assertThat(result.getPaging().getPageIndex()).isOne();
assertThat(result.getRulesCount()).isOne();
@@ -1048,12 +1060,14 @@ public class SearchActionIT {
requestPopulator.accept(request);
Rules.SearchResponse response = request.executeProtobuf(Rules.SearchResponse.class);
+ assertThat(response.getP()).isOne();
assertThat(response.getPaging().getPageIndex()).isOne();
assertThat(response.getPaging().getPageSize()).isNotZero();
RuleKey[] expectedRuleKeys = stream(expectedRules).map(RuleDto::getKey).toList().toArray(new RuleKey[0]);
assertThat(response.getRulesList())
.extracting(r -> RuleKey.parse(r.getKey()))
.containsExactlyInAnyOrder(expectedRuleKeys);
+ assertThat(response.getTotal()).isEqualTo(expectedRules.length);
assertThat(response.getPaging().getTotal()).isEqualTo(expectedRules.length);
assertThat(response.getRulesCount()).isEqualTo(expectedRules.length);
}
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/UsersActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/UsersActionIT.java
index c0aa16ed73a..3888e144b20 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/UsersActionIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/usergroups/ws/UsersActionIT.java
@@ -71,7 +71,6 @@ public class UsersActionIT {
assertThat(wsDef.since()).isEqualTo("5.2");
assertThat(wsDef.isPost()).isFalse();
assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
- tuple("10.2", "Response fields 'total', 's', 'ps' dropped"),
tuple("10.0", "Field 'managed' added to the payload."),
tuple("10.0", "Parameter 'id' is removed. Use 'name' instead."),
tuple("9.8", "response fields 'total', 's', 'ps' have been deprecated, please use 'paging' object instead."),
@@ -116,6 +115,8 @@ public class UsersActionIT {
assertJson(result).isSimilarTo("""
{
+ "p": 1,
+ "total": 0,
"paging": {
"pageIndex": 1,
"pageSize": 25,
@@ -254,6 +255,9 @@ public class UsersActionIT {
.execute()
.getInput()).isSimilarTo("""
{
+ "p": 1,
+ "ps": 1,
+ "total": 2,
"paging": {
"pageIndex": 1,
"pageSize": 1,
@@ -271,6 +275,9 @@ public class UsersActionIT {
.execute()
.getInput()).isSimilarTo("""
{
+ "p": 2,
+ "ps": 1,
+ "total": 2,
"paging": {
"pageIndex": 2,
"pageSize": 1,
diff --git a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionComponentsIT/no_issue.json b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionComponentsIT/no_issue.json
index ba70d56c58a..ce8bbfbeeb7 100644
--- a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionComponentsIT/no_issue.json
+++ b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionComponentsIT/no_issue.json
@@ -1,6 +1,4 @@
{
- "paging": {
- "total": 0
- },
+ "total": 0,
"issues": []
}
diff --git a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/apply_paging_with_one_component.json b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/apply_paging_with_one_component.json
index 8e6bb76d1fb..2629aa292a6 100644
--- a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/apply_paging_with_one_component.json
+++ b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/apply_paging_with_one_component.json
@@ -1,4 +1,7 @@
{
+ "total": 501,
+ "p": 1,
+ "ps": 100,
"paging": {
"pageIndex": 1,
"pageSize": 100,
diff --git a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/default_page_size_is_100.json b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/default_page_size_is_100.json
index 5aa53738e1c..13af5a2ede8 100644
--- a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/default_page_size_is_100.json
+++ b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/default_page_size_is_100.json
@@ -1,4 +1,7 @@
{
+ "total": 0,
+ "p": 1,
+ "ps": 100,
"paging": {
"pageIndex": 1,
"pageSize": 100,
diff --git a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/empty_result.json b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/empty_result.json
index 8b19589dc6a..acda7495d25 100644
--- a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/empty_result.json
+++ b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/empty_result.json
@@ -1,4 +1,7 @@
{
+ "total": 0,
+ "p": 1,
+ "ps": 100,
"paging": {
"pageIndex": 1,
"pageSize": 100,
diff --git a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_leak_period.json b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_leak_period.json
index 9ecdda62fbf..65d8323fe65 100644
--- a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_leak_period.json
+++ b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_leak_period.json
@@ -1,4 +1,7 @@
{
+ "total": 1,
+ "p": 1,
+ "ps": 100,
"paging": {
"pageIndex": 1,
"pageSize": 100,
diff --git a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_leak_period_has_no_effect_on_prs.json b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_leak_period_has_no_effect_on_prs.json
index 2fe198d8f3f..f54458ec29a 100644
--- a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_leak_period_has_no_effect_on_prs.json
+++ b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_leak_period_has_no_effect_on_prs.json
@@ -1,4 +1,7 @@
{
+ "total": 2,
+ "p": 1,
+ "ps": 100,
"paging": {
"pageIndex": 1,
"pageSize": 100,
diff --git a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_main_scope.json b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_main_scope.json
index 43ceaf9a40a..740f756f398 100644
--- a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_main_scope.json
+++ b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_main_scope.json
@@ -1,4 +1,7 @@
{
+ "total": 2,
+ "p": 1,
+ "ps": 100,
"paging": {
"pageIndex": 1,
"pageSize": 100,
diff --git a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_main_scope_2.json b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_main_scope_2.json
index 7f6f8799555..b5945de7c84 100644
--- a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_main_scope_2.json
+++ b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_main_scope_2.json
@@ -1,4 +1,7 @@
{
+ "total": 2,
+ "p": 1,
+ "ps": 100,
"paging": {
"pageIndex": 1,
"pageSize": 100,
diff --git a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_test_scope.json b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_test_scope.json
index 139d8801972..e87cfca059d 100644
--- a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_test_scope.json
+++ b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/filter_by_test_scope.json
@@ -1,4 +1,7 @@
{
+ "total": 1,
+ "p": 1,
+ "ps": 100,
"paging": {
"pageIndex": 1,
"pageSize": 100,
diff --git a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/no_issue.json b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/no_issue.json
index b7fb469ac21..5d7390f509e 100644
--- a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/no_issue.json
+++ b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/no_issue.json
@@ -1,4 +1,5 @@
{
+ "total": 0,
"issues": [],
"paging": {
"pageIndex": 1,
diff --git a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/paging.json b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/paging.json
index f996885b3cd..e9042aabbe7 100644
--- a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/paging.json
+++ b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/paging.json
@@ -1,4 +1,7 @@
{
+ "total": 12,
+ "p": 2,
+ "ps": 9,
"paging": {
"pageIndex": 2,
"pageSize": 9,
diff --git a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/result_for_rule_search.json b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/result_for_rule_search.json
index 39a61addd16..964d722b8de 100644
--- a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/result_for_rule_search.json
+++ b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/result_for_rule_search.json
@@ -1,4 +1,7 @@
{
+ "total": 1,
+ "p": 1,
+ "ps": 100,
"paging": {
"pageIndex": 1,
"pageSize": 100,
diff --git a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/search_by_variants_with_facets.json b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/search_by_variants_with_facets.json
index 057955f0368..3798206a378 100644
--- a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/search_by_variants_with_facets.json
+++ b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/issue/ws/SearchActionIT/search_by_variants_with_facets.json
@@ -1,4 +1,7 @@
{
+ "total": 3,
+ "p": 1,
+ "ps": 100,
"paging": {
"pageIndex": 1,
"pageSize": 100,
diff --git a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/qualityprofile/ws/ChangelogActionIT/changelog_example.json b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/qualityprofile/ws/ChangelogActionIT/changelog_example.json
new file mode 100644
index 00000000000..c40c1bb7f32
--- /dev/null
+++ b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/qualityprofile/ws/ChangelogActionIT/changelog_example.json
@@ -0,0 +1,43 @@
+{
+ "total": 3,
+ "ps": 10,
+ "p": 1,
+ "paging": {
+ "pageSize": 10,
+ "total": 3,
+ "pageIndex": 1
+ },
+ "events": [
+ {
+ "date" : "2015-02-23T17:58:39+0100",
+ "action" : "ACTIVATED",
+ "authorLogin" : "anakin.skywalker",
+ "authorName" : "Anakin Skywalker",
+ "ruleKey" : "java:S2438",
+ "ruleName" : "\"Threads\" should not be used where \"Runnables\" are expected",
+ "params" : {
+ "severity" : "CRITICAL"
+ }
+ },
+ {
+ "date" : "2015-02-23T17:58:18+0100",
+ "action" : "DEACTIVATED",
+ "authorLogin" : "padme.amidala",
+ "authorName" : "Padme Amidala",
+ "ruleKey" : "java:S2162",
+ "ruleName" : "\"equals\" methods should be symmetric and work for subclasses"
+ },
+ {
+ "action" : "ACTIVATED",
+ "authorLogin" : "obiwan.kenobi",
+ "authorName" : "Obiwan Kenobi",
+ "ruleKey" : "java:S00101",
+ "ruleName" : "Class names should comply with a naming convention",
+ "date" : "2014-09-12T15:20:46+0200",
+ "params" : {
+ "severity" : "MAJOR",
+ "format" : "^[A-Z][a-zA-Z0-9]*$"
+ }
+ }
+ ]
+}
diff --git a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/rule/ws/SearchActionIT/paging.json b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/rule/ws/SearchActionIT/paging.json
index f996885b3cd..e9042aabbe7 100644
--- a/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/rule/ws/SearchActionIT/paging.json
+++ b/server/sonar-webserver-webapi/src/it/resources/org/sonar/server/rule/ws/SearchActionIT/paging.json
@@ -1,4 +1,7 @@
{
+ "total": 12,
+ "p": 2,
+ "ps": 9,
"paging": {
"pageIndex": 2,
"pageSize": 9,
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java
index e09c0347ba4..674c74cca2e 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java
@@ -194,7 +194,6 @@ public class SearchAction implements IssuesWsAction {
+ "<br/>When issue indexation is in progress returns 503 service unavailable HTTP code.")
.setSince("3.6")
.setChangelog(
- new Change("10.2", "Response fields 'total', 's', 'ps' dropped"),
new Change("10.2", format("Parameter '%s' renamed to '%s'", PARAM_COMPONENT_KEYS, PARAM_COMPONENTS)),
new Change("10.1", "Add the 'codeVariants' parameter, facet and response field"),
new Change("10.0", "Parameter 'sansTop25' is deprecated"),
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java
index 1e769addf39..3622343ea1b 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java
@@ -101,7 +101,7 @@ public class SearchResponseFormat {
SearchWsResponse formatSearch(Set<SearchAdditionalField> fields, SearchResponseData data, Paging paging, Facets facets) {
SearchWsResponse.Builder response = SearchWsResponse.newBuilder();
- response.setPaging(formatPaging(paging));
+ formatPaging(paging, response);
ofNullable(data.getEffortTotal()).ifPresent(response::setEffortTotal);
response.addAllIssues(createIssues(fields, data));
response.addAllComponents(formatComponents(data));
@@ -142,6 +142,13 @@ public class SearchResponseFormat {
return response.build();
}
+ private static void formatPaging(Paging paging, SearchWsResponse.Builder response) {
+ response.setP(paging.pageIndex());
+ response.setPs(paging.pageSize());
+ response.setTotal(paging.total());
+ response.setPaging(formatPaging(paging));
+ }
+
private static Common.Paging.Builder formatPaging(Paging paging) {
return Common.Paging.newBuilder()
.setPageIndex(paging.pageIndex())
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java
index d04088c192b..57b3a8b902b 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java
@@ -70,7 +70,6 @@ public class ChangelogAction implements QProfileWsAction {
.setDescription("Get the history of changes on a quality profile: rule activation/deactivation, change in parameters/severity. " +
"Events are ordered by date in descending order (most recent first).")
.setChangelog(
- new org.sonar.api.server.ws.Change("10.2", "Response fields 'total', 's', 'ps' dropped"),
new org.sonar.api.server.ws.Change("9.8", "response fields 'total', 's', 'ps' have been deprecated, please use 'paging' object instead"),
new org.sonar.api.server.ws.Change("9.8", "The field 'paging' has been added to the response"))
.setHandler(this)
@@ -145,6 +144,11 @@ public class ChangelogAction implements QProfileWsAction {
Map<String, UserDto> usersByUuid, Map<String, RuleDto> rulesByRuleUuids) {
json.beginObject();
writePaging(json, total, page, pageSize);
+ json.name("paging").beginObject()
+ .prop("pageIndex", page)
+ .prop("pageSize", pageSize)
+ .prop("total", total)
+ .endObject();
json.name("events").beginArray();
changelogs.forEach(change -> {
JsonWriter changeWriter = json.beginObject();
@@ -179,12 +183,14 @@ public class ChangelogAction implements QProfileWsAction {
json.endObject();
}
+ /**
+ * @deprecated since 9.8 - replaced by 'paging' object structure.
+ */
+ @Deprecated(since = "9.8")
private static void writePaging(JsonWriter json, int total, int page, int pageSize) {
- json.name("paging").beginObject()
- .prop("pageIndex", page)
- .prop("pageSize", pageSize)
- .prop("total", total)
- .endObject();
+ json.prop("total", total);
+ json.prop(Param.PAGE, page);
+ json.prop(Param.PAGE_SIZE, pageSize);
}
/**
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java
index 2e406da2d2f..8f52faa0822 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java
@@ -165,8 +165,7 @@ public class SearchAction implements RulesWsAction {
new Change("10.0", "The value 'debtRemFn' for the 'f' parameter has been deprecated, use 'remFn' instead"),
new Change("10.0", "The value 'defaultDebtRemFn' for the 'f' parameter has been deprecated, use 'defaultRemFn' instead"),
new Change("10.0", "The value 'sansTop25' for the parameter 'facets' has been deprecated"),
- new Change("10.0", "Parameter 'sansTop25' is deprecated"),
- new Change("10.2", "Response fields 'total', 's', 'ps' dropped")
+ new Change("10.0", "Parameter 'sansTop25' is deprecated")
);
action.createParam(FACETS)
@@ -204,7 +203,7 @@ public class SearchAction implements RulesWsAction {
private SearchResponse buildResponse(DbSession dbSession, SearchRequest request, SearchOptions context, SearchResult result, RuleQuery query) {
SearchResponse.Builder responseBuilder = SearchResponse.newBuilder();
- writePaging(responseBuilder, result, context);
+ writeStatistics(responseBuilder, result, context);
doContextResponse(dbSession, request, result, responseBuilder, query);
if (!context.getFacets().isEmpty()) {
writeFacets(responseBuilder, request, context, result);
@@ -212,7 +211,10 @@ public class SearchAction implements RulesWsAction {
return responseBuilder.build();
}
- private static void writePaging(SearchResponse.Builder response, SearchResult searchResult, SearchOptions context) {
+ private static void writeStatistics(SearchResponse.Builder response, SearchResult searchResult, SearchOptions context) {
+ response.setTotal(searchResult.total);
+ response.setP(context.getPage());
+ response.setPs(context.getLimit());
response.setPaging(formatPaging(searchResult.total, context.getPage(), context.getLimit()));
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java
index b08e76f2596..01fc9477cfd 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java
@@ -76,7 +76,6 @@ public class UsersAction implements UserGroupsWsAction {
.addSearchQuery("freddy", "names", "logins")
.addPagingParams(25)
.setChangelog(
- new Change("10.2", "Response fields 'total', 's', 'ps' dropped"),
new Change("10.0", "Field 'managed' added to the payload."),
new Change("10.0", "Parameter 'id' is removed. Use 'name' instead."),
new Change("9.8", "response fields 'total', 's', 'ps' have been deprecated, please use 'paging' object instead."),
@@ -112,6 +111,11 @@ public class UsersAction implements UserGroupsWsAction {
json.beginObject();
writeMembers(json, users, userUuidToIsManaged);
writePaging(json, paging);
+ json.name("paging").beginObject()
+ .prop("pageIndex", page)
+ .prop("pageSize", pageSize)
+ .prop("total", total)
+ .endObject();
json.endObject();
}
}
@@ -134,12 +138,14 @@ public class UsersAction implements UserGroupsWsAction {
json.endArray();
}
+ /**
+ * @deprecated since 9.8 - replaced by 'paging' object structure.
+ */
+ @Deprecated(since = "9.8")
private static void writePaging(JsonWriter json, Paging paging) {
- json.name("paging").beginObject()
- .prop("pageIndex", paging.pageIndex())
- .prop("pageSize", paging.pageSize())
- .prop("total", paging.total())
- .endObject();
+ json.prop(Param.PAGE, paging.pageIndex())
+ .prop(Param.PAGE_SIZE, paging.pageSize())
+ .prop("total", paging.total());
}
private static String getMembership(String selected) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java
index 6c1766f54e3..5768377de8e 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRulesLoader.java
@@ -63,9 +63,9 @@ public class DefaultActiveRulesLoader implements ActiveRulesLoader {
SearchResponse response = loadFromStream(wsClient.call(getRequest).contentStream());
List<LoadedActiveRule> pageRules = readPage(response);
ruleList.addAll(pageRules);
- loaded += response.getPaging().getPageSize();
+ loaded += response.getPs();
- if (response.getPaging().getTotal() <= loaded) {
+ if (response.getTotal() <= loaded) {
break;
}
page++;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/DefaultActiveRulesLoaderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/DefaultActiveRulesLoaderTest.java
index 059a0efbe8d..60b19337d23 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/DefaultActiveRulesLoaderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/DefaultActiveRulesLoaderTest.java
@@ -33,7 +33,6 @@ import org.sonar.api.utils.MessageException;
import org.sonar.scanner.WsTestUtil;
import org.sonar.scanner.bootstrap.DefaultScannerWsClient;
import org.sonar.scanner.scan.branch.BranchConfiguration;
-import org.sonarqube.ws.Common;
import org.sonarqube.ws.Rules;
import org.sonarqube.ws.Rules.Active;
import org.sonarqube.ws.Rules.ActiveList;
@@ -138,7 +137,8 @@ public class DefaultActiveRulesLoaderTest {
});
rules.setActives(actives);
- rules.setPaging(Common.Paging.newBuilder().setPageSize(numberOfRules).setTotal(total));
+ rules.setPs(numberOfRules);
+ rules.setTotal(total);
return new ByteArrayInputStream(rules.build().toByteArray());
}
@@ -156,7 +156,8 @@ public class DefaultActiveRulesLoaderTest {
});
rules.setActives(actives);
- rules.setPaging(Common.Paging.newBuilder().setPageSize(3).setTotal(3));
+ rules.setPs(3);
+ rules.setTotal(3);
return new ByteArrayInputStream(rules.build().toByteArray());
}
}
diff --git a/sonar-ws/src/main/protobuf/ws-issues.proto b/sonar-ws/src/main/protobuf/ws-issues.proto
index aa88ec34083..d545fe7e75d 100644
--- a/sonar-ws/src/main/protobuf/ws-issues.proto
+++ b/sonar-ws/src/main/protobuf/ws-issues.proto
@@ -29,9 +29,9 @@ option optimize_for = SPEED;
// Response of GET api/issues/search
message SearchWsResponse {
reserved 5;
- reserved 1;
- reserved 2;
- reserved 3;
+ optional int64 total = 1 [deprecated=true];
+ optional int64 p = 2 [deprecated=true];
+ optional int32 ps = 3 [deprecated=true];
optional sonarqube.ws.commons.Paging paging = 4;
// Total amount of effort, only when the facet "total" is enabled
diff --git a/sonar-ws/src/main/protobuf/ws-rules.proto b/sonar-ws/src/main/protobuf/ws-rules.proto
index 2e68e4c0766..e1e242b8b81 100644
--- a/sonar-ws/src/main/protobuf/ws-rules.proto
+++ b/sonar-ws/src/main/protobuf/ws-rules.proto
@@ -41,9 +41,10 @@ message ListResponse {
// WS api/rules/search
message SearchResponse {
- reserved 1;
- reserved 2;
- reserved 3;
+ optional int64 total = 1 [deprecated=true];
+ optional int32 p = 2 [deprecated=true];
+ optional int64 ps = 3 [deprecated=true];
+
repeated Rule rules = 4;
optional Actives actives = 5;
optional QProfiles qProfiles = 6;