cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject git commit: updated refs/heads/master to 477f913
Date Mon, 28 Jul 2014 22:26:58 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master d42e20429 -> 477f91327


CS-19072: fixed broken pagination and count in listVpcs


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/477f9132
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/477f9132
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/477f9132

Branch: refs/heads/master
Commit: 477f91327c4c0d11ea39cc2327409f6053238c24
Parents: d42e204
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Jul 28 15:06:14 2014 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Mon Jul 28 15:26:02 2014 -0700

----------------------------------------------------------------------
 api/src/com/cloud/network/vpc/VpcService.java   |  2 +-
 .../command/admin/vpc/ListVPCsCmdByAdmin.java   | 14 +++++++-------
 .../api/command/user/vpc/ListVPCsCmd.java       | 14 +++++++-------
 .../com/cloud/network/vpc/VpcManagerImpl.java   | 20 ++++++++++++++++----
 4 files changed, 31 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/477f9132/api/src/com/cloud/network/vpc/VpcService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpc/VpcService.java b/api/src/com/cloud/network/vpc/VpcService.java
index dd9cabc..713844d 100644
--- a/api/src/com/cloud/network/vpc/VpcService.java
+++ b/api/src/com/cloud/network/vpc/VpcService.java
@@ -97,7 +97,7 @@ public interface VpcService {
      * @param vpc
      * @return
      */
-    public List<? extends Vpc> listVpcs(Long id, String vpcName, String displayText,
List<String> supportedServicesStr, String cidr, Long vpcOffId, String state,
+    public Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName,
String displayText, List<String> supportedServicesStr, String cidr, Long vpcOffId, String
state,
         String accountName, Long domainId, String keyword, Long startIndex, Long pageSizeVal,
Long zoneId, Boolean isRecursive, Boolean listAll, Boolean restartRequired,
         Map<String, String> tags, Long projectId, Boolean display);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/477f9132/api/src/org/apache/cloudstack/api/command/admin/vpc/ListVPCsCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/vpc/ListVPCsCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vpc/ListVPCsCmdByAdmin.java
index 3a95e44..02f47a2 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/vpc/ListVPCsCmdByAdmin.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/vpc/ListVPCsCmdByAdmin.java
@@ -19,15 +19,15 @@ package org.apache.cloudstack.api.command.admin.vpc;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.command.user.vpc.ListVPCsCmd;
 import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.VpcResponse;
+import org.apache.log4j.Logger;
 
 import com.cloud.network.vpc.Vpc;
+import com.cloud.utils.Pair;
 
 
 @APICommand(name = "listVPCs", description = "Lists VPCs", responseObject = VpcResponse.class,
responseView = ResponseView.Full)
@@ -36,18 +36,18 @@ public class ListVPCsCmdByAdmin extends ListVPCsCmd {
 
     @Override
     public void execute() {
-        List<? extends Vpc> vpcs =
+        Pair<List<? extends Vpc>, Integer> vpcs =
                 _vpcService.listVpcs(getId(), getVpcName(), getDisplayText(), getSupportedServices(),
getCidr(), getVpcOffId(), getState(), getAccountName(), getDomainId(),
                         getKeyword(), getStartIndex(), getPageSizeVal(), getZoneId(), isRecursive(),
listAll(), getRestartRequired(), getTags(),
                         getProjectId(), getDisplay());
         ListResponse<VpcResponse> response = new ListResponse<VpcResponse>();
-        List<VpcResponse> offeringResponses = new ArrayList<VpcResponse>();
-        for (Vpc vpc : vpcs) {
+        List<VpcResponse> vpcResponses = new ArrayList<VpcResponse>();
+        for (Vpc vpc : vpcs.first()) {
             VpcResponse offeringResponse = _responseGenerator.createVpcResponse(ResponseView.Full,
vpc);
-            offeringResponses.add(offeringResponse);
+            vpcResponses.add(offeringResponse);
         }
 
-        response.setResponses(offeringResponses);
+        response.setResponses(vpcResponses, vpcs.second());
         response.setResponseName(getCommandName());
         setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/477f9132/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCsCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCsCmd.java
index 9079dff..9531b81 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCsCmd.java
@@ -19,8 +19,6 @@ package org.apache.cloudstack.api.command.user.vpc;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
@@ -31,8 +29,10 @@ import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.VpcOfferingResponse;
 import org.apache.cloudstack.api.response.VpcResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.log4j.Logger;
 
 import com.cloud.network.vpc.Vpc;
+import com.cloud.utils.Pair;
 
 
 @APICommand(name = "listVPCs", description = "Lists VPCs", responseObject = VpcResponse.class,
responseView = ResponseView.Restricted, entityType = {Vpc.class},
@@ -129,18 +129,18 @@ public class ListVPCsCmd extends BaseListTaggedResourcesCmd {
 
     @Override
     public void execute() {
-        List<? extends Vpc> vpcs =
+        Pair<List<? extends Vpc>, Integer> vpcs =
             _vpcService.listVpcs(getId(), getVpcName(), getDisplayText(), getSupportedServices(),
getCidr(), getVpcOffId(), getState(), getAccountName(), getDomainId(),
                 getKeyword(), getStartIndex(), getPageSizeVal(), getZoneId(), isRecursive(),
listAll(), getRestartRequired(), getTags(),
                 getProjectId(), getDisplay());
         ListResponse<VpcResponse> response = new ListResponse<VpcResponse>();
-        List<VpcResponse> offeringResponses = new ArrayList<VpcResponse>();
-        for (Vpc vpc : vpcs) {
+        List<VpcResponse> vpcResponses = new ArrayList<VpcResponse>();
+        for (Vpc vpc : vpcs.first()) {
             VpcResponse offeringResponse = _responseGenerator.createVpcResponse(ResponseView.Restricted,
vpc);
-            offeringResponses.add(offeringResponse);
+            vpcResponses.add(offeringResponse);
         }
 
-        response.setResponses(offeringResponses);
+        response.setResponses(vpcResponses, vpcs.second());
         response.setResponseName(getCommandName());
         setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/477f9132/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index 5aa4721..5a90233 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -1003,7 +1003,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
     }
 
     @Override
-    public List<? extends Vpc> listVpcs(Long id, String vpcName, String displayText,
List<String> supportedServicesStr, String cidr, Long vpcOffId, String state,
+    public Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName,
String displayText, List<String> supportedServicesStr, String cidr, Long vpcOffId, String
state,
         String accountName, Long domainId, String keyword, Long startIndex, Long pageSizeVal,
Long zoneId, Boolean isRecursive, Boolean listAll, Boolean restartRequired,
         Map<String, String> tags, Long projectId, Boolean display) {
         Account caller = CallContext.current().getCallingAccount();
@@ -1015,7 +1015,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
         domainId = domainIdRecursiveListProject.first();
         isRecursive = domainIdRecursiveListProject.second();
         ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
-        Filter searchFilter = new Filter(VpcVO.class, "created", false, startIndex, pageSizeVal);
+        Filter searchFilter = new Filter(VpcVO.class, "created", false, null, null);
 
         SearchBuilder<VpcVO> sb = _vpcDao.createSearchBuilder();
         _accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
@@ -1128,9 +1128,21 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
                 }
             }
 
-            return supportedVpcs;
+            List<?> wPagination = StringUtils.applyPagination(supportedVpcs, startIndex,
pageSizeVal);
+            if (wPagination != null) {
+                @SuppressWarnings("unchecked")
+                Pair<List<? extends Vpc>, Integer> listWPagination = new Pair<List<?
extends Vpc>, Integer>((List<Vpc>) wPagination, supportedVpcs.size());
+                return listWPagination;
+            }
+            return new Pair<List<? extends Vpc>, Integer>(supportedVpcs, supportedVpcs.size());
         } else {
-            return vpcs;
+            List<?> wPagination = StringUtils.applyPagination(vpcs, startIndex, pageSizeVal);
+            if (wPagination != null) {
+                @SuppressWarnings("unchecked")
+                Pair<List<? extends Vpc>, Integer> listWPagination = new Pair<List<?
extends Vpc>, Integer>((List<Vpc>) wPagination, vpcs.size());
+                return listWPagination;
+            }
+            return new Pair<List<? extends Vpc>, Integer>(vpcs, vpcs.size());
         }
     }
 


Mime
View raw message