]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6479 WS permissions/users take out Paging from the loop when building response
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Thu, 27 Aug 2015 12:09:29 +0000 (14:09 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Thu, 27 Aug 2015 14:52:32 +0000 (16:52 +0200)
server/sonar-server/src/main/java/org/sonar/server/permission/ws/UsersAction.java

index fef9128c304a0e62440be21e19af36f6184ac27d..ef2f92555961ab01c6edf2ef35420a6be89a2648 100644 (file)
@@ -36,7 +36,7 @@ import org.sonar.server.permission.PermissionFinder;
 import org.sonar.server.permission.UserWithPermissionQueryResult;
 import org.sonar.server.permission.ws.PermissionRequest.Builder;
 import org.sonar.server.user.UserSession;
-import org.sonarqube.ws.Common;
+import org.sonarqube.ws.Common.Paging;
 import org.sonarqube.ws.Permissions.UsersResponse;
 
 import static com.google.common.base.Objects.firstNonNull;
@@ -105,7 +105,6 @@ public class UsersAction implements PermissionsWsAction {
 
     UsersResponse.Builder userResponse = UsersResponse.newBuilder();
     UsersResponse.User.Builder user = UsersResponse.User.newBuilder();
-    Common.Paging.Builder paging = Common.Paging.newBuilder();
     for (UserWithPermission userWithPermission : usersWithPermission) {
       userResponse.addUsers(
         user
@@ -114,14 +113,14 @@ public class UsersAction implements PermissionsWsAction {
           .setName(nullToEmpty(userWithPermission.name()))
           .setEmail(nullToEmpty(userWithPermission.email()))
           .setSelected(userWithPermission.hasPermission()));
-      userResponse.setPaging(
-        paging
-          .clear()
-          .setPageIndex(page)
-          .setPageSize(pageSize)
-          .setTotal(usersResult.total())
-        );
     }
+    userResponse.setPaging(
+      Paging.newBuilder()
+        .clear()
+        .setPageIndex(page)
+        .setPageSize(pageSize)
+        .setTotal(usersResult.total())
+      );
 
     return userResponse.build();
   }