]> source.dussan.org Git - sonarqube.git/commitdiff
apply conventions for pagination to api/projects/provisioned
authorDaniel Schwarz <daniel.schwarz@sonarsource.com>
Fri, 21 Apr 2017 14:26:23 +0000 (16:26 +0200)
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>
Mon, 24 Apr 2017 09:45:27 +0000 (11:45 +0200)
server/sonar-server/src/main/java/org/sonar/server/project/ws/ProvisionedAction.java
server/sonar-server/src/main/resources/org/sonar/server/project/ws/projects-example-provisioned.json
server/sonar-server/src/test/java/org/sonar/server/project/ws/ProvisionedActionTest.java
sonar-ws/src/main/protobuf/ws-components.proto

index 28288cb63b9eeab0e92f44218e2a8b10f98696ba..5c6675783ef337e875ab83161101f67609e8f87c 100644 (file)
@@ -40,6 +40,7 @@ import org.sonar.db.organization.OrganizationDto;
 import org.sonar.server.es.SearchOptions;
 import org.sonar.server.organization.DefaultOrganizationProvider;
 import org.sonar.server.user.UserSession;
+import org.sonarqube.ws.Common.Paging;
 import org.sonarqube.ws.WsComponents.ProvisionedWsResponse;
 import org.sonarqube.ws.WsComponents.ProvisionedWsResponse.Component;
 
@@ -82,7 +83,9 @@ public class ProvisionedAction implements ProjectsWsAction {
       .addSearchQuery("sonar", "names", "keys")
       .addFieldsParam(POSSIBLE_FIELDS);
 
-    action.setChangelog(new Change("6.4", "The 'uuid' field is deprecated in the response"));
+    action.setChangelog(
+      new Change("6.4", "The 'uuid' field is deprecated in the response"),
+      new Change("6.4", "Paging response fields is now in a Paging object"));
 
     support.addOrganizationParam(action);
   }
@@ -107,9 +110,10 @@ public class ProvisionedAction implements ProjectsWsAction {
       int nbOfProjects = dbClient.componentDao().countProvisioned(dbSession, organization.getUuid(), query, QUALIFIERS_FILTER);
       ProvisionedWsResponse result = ProvisionedWsResponse.newBuilder()
         .addAllProjects(writeProjects(projects, desiredFields))
-        .setTotal(nbOfProjects)
-        .setP(options.getPage())
-        .setPs(options.getLimit())
+        .setPaging(Paging.newBuilder()
+          .setTotal(nbOfProjects)
+          .setPageIndex(options.getPage())
+          .setPageSize(options.getLimit()))
         .build();
       writeProtobuf(result, request, response);
     }
index 4bb9f8436547c30d029e645ab590ecc5c662d188..a0e8c528b7cc817b86ca80d90b3932d499fef13f 100644 (file)
@@ -1,4 +1,9 @@
 {
+  "paging": {
+    "total": 2,
+    "pageIndex": 1,
+    "pageSize": 100
+  },
   "projects": [
     {
       "uuid": "ce4c03d6-430f-40a9-b777-ad877c00aa4d",
@@ -12,8 +17,5 @@
       "name": "Roslyn",
       "creationDate": "2013-03-04T23:03:44+0100"
     }
-  ],
-  "total": 2,
-  "p": 1,
-  "ps": 100
+  ]
 }
index 63b75b04eb24dcf784a0537421390f4024f03ac2..21ce68ce276b603f95f7fe553dada8a452a18b47 100644 (file)
@@ -72,7 +72,8 @@ public class ProvisionedActionTest {
       "Require 'Create Projects' permission.");
     assertThat(action.since()).isEqualTo("5.2");
     assertThat(action.changelog()).extracting(Change::getVersion, Change::getDescription).containsExactlyInAnyOrder(
-      tuple("6.4", "The 'uuid' field is deprecated in the response")
+      tuple("6.4", "The 'uuid' field is deprecated in the response"),
+      tuple("6.4", "Paging response fields is now in a Paging object")
     );
 
     assertThat(action.params()).hasSize(5);
index 27a3661770800eba687ab67e075556265b9bbea5..5b0445288b997af157c8e0b0b05cd9b4b0ca1e35 100644 (file)
@@ -89,10 +89,8 @@ message SearchProjectsWsResponse {
 
 // WS api/components/provisioned
 message ProvisionedWsResponse {
-  repeated Component projects = 1;
-  optional int64 total = 2;
-  optional int32 p = 3;
-  optional int64 ps = 4;
+  optional sonarqube.ws.commons.Paging paging = 1;
+  repeated Component projects = 2;
 
   message Component {
     optional string uuid = 1;