aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Schwarz <daniel.schwarz@sonarsource.com>2017-04-21 16:26:23 +0200
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>2017-04-24 11:45:27 +0200
commit0f1b6de6d557cf3a3ee6c37f4b569455bca20f4c (patch)
treeacdec6531fe0085aa4278b4ac9e6cb2ca4f28e15
parent70c5d0b38896e0d431d8d687d397f7e17919cef9 (diff)
downloadsonarqube-0f1b6de6d557cf3a3ee6c37f4b569455bca20f4c.tar.gz
sonarqube-0f1b6de6d557cf3a3ee6c37f4b569455bca20f4c.zip
apply conventions for pagination to api/projects/provisioned
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/project/ws/ProvisionedAction.java12
-rw-r--r--server/sonar-server/src/main/resources/org/sonar/server/project/ws/projects-example-provisioned.json10
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/project/ws/ProvisionedActionTest.java3
-rw-r--r--sonar-ws/src/main/protobuf/ws-components.proto6
4 files changed, 18 insertions, 13 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/project/ws/ProvisionedAction.java b/server/sonar-server/src/main/java/org/sonar/server/project/ws/ProvisionedAction.java
index 28288cb63b9..5c6675783ef 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/project/ws/ProvisionedAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/project/ws/ProvisionedAction.java
@@ -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);
}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/project/ws/projects-example-provisioned.json b/server/sonar-server/src/main/resources/org/sonar/server/project/ws/projects-example-provisioned.json
index 4bb9f843654..a0e8c528b7c 100644
--- a/server/sonar-server/src/main/resources/org/sonar/server/project/ws/projects-example-provisioned.json
+++ b/server/sonar-server/src/main/resources/org/sonar/server/project/ws/projects-example-provisioned.json
@@ -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
+ ]
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/ProvisionedActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/ProvisionedActionTest.java
index 63b75b04eb2..21ce68ce276 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/ProvisionedActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/ProvisionedActionTest.java
@@ -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);
diff --git a/sonar-ws/src/main/protobuf/ws-components.proto b/sonar-ws/src/main/protobuf/ws-components.proto
index 27a36617708..5b0445288b9 100644
--- a/sonar-ws/src/main/protobuf/ws-components.proto
+++ b/sonar-ws/src/main/protobuf/ws-components.proto
@@ -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;