cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [4/4] git commit: updated refs/heads/master to fa74b3a
Date Mon, 28 Jul 2014 21:55:29 GMT
CS-19072: fixed broken pagination and count in listVpcOfferings


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

Branch: refs/heads/master
Commit: fa74b3a300a679f3e47a3fac13fab323cda34cf3
Parents: 8b98cc2
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Jul 28 14:41:50 2014 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Mon Jul 28 14:44:12 2014 -0700

----------------------------------------------------------------------
 .../network/vpc/VpcProvisioningService.java     |  4 +++-
 .../command/user/vpc/ListVPCOfferingsCmd.java   | 10 +++++-----
 .../com/cloud/network/vpc/VpcManagerImpl.java   | 21 ++++++++++++++++----
 3 files changed, 25 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fa74b3a3/api/src/com/cloud/network/vpc/VpcProvisioningService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/vpc/VpcProvisioningService.java b/api/src/com/cloud/network/vpc/VpcProvisioningService.java
index 82a7baa..cce2850 100644
--- a/api/src/com/cloud/network/vpc/VpcProvisioningService.java
+++ b/api/src/com/cloud/network/vpc/VpcProvisioningService.java
@@ -20,6 +20,8 @@ package com.cloud.network.vpc;
 import java.util.List;
 import java.util.Map;
 
+import com.cloud.utils.Pair;
+
 public interface VpcProvisioningService {
 
     public VpcOffering getVpcOffering(long vpcOfferingId);
@@ -29,7 +31,7 @@ public interface VpcProvisioningService {
                                          Map serviceCapabilitystList,
                                          Long serviceOfferingId);
 
-    List<? extends VpcOffering> listVpcOfferings(Long id, String name, String displayText,
List<String> supportedServicesStr, Boolean isDefault, String keyword,
+    Pair<List<? extends VpcOffering>,Integer> listVpcOfferings(Long id, String
name, String displayText, List<String> supportedServicesStr, Boolean isDefault, String
keyword,
         String state, Long startIndex, Long pageSizeVal);
 
     /**

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fa74b3a3/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCOfferingsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCOfferingsCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCOfferingsCmd.java
index e76afc9..69d7c8b 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCOfferingsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCOfferingsCmd.java
@@ -19,16 +19,16 @@ 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.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseListCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.VpcOfferingResponse;
+import org.apache.log4j.Logger;
 
 import com.cloud.network.vpc.VpcOffering;
+import com.cloud.utils.Pair;
 
 @APICommand(name = "listVPCOfferings", description = "Lists VPC offerings", responseObject
= VpcOfferingResponse.class,
         requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
@@ -93,17 +93,17 @@ public class ListVPCOfferingsCmd extends BaseListCmd {
 
     @Override
     public void execute() {
-        List<? extends VpcOffering> offerings =
+        Pair<List<? extends VpcOffering>, Integer> offerings =
             _vpcProvSvc.listVpcOfferings(getId(), getVpcOffName(), getDisplayText(), getSupportedServices(),
isDefault, this.getKeyword(), getState(),
                 this.getStartIndex(), this.getPageSizeVal());
         ListResponse<VpcOfferingResponse> response = new ListResponse<VpcOfferingResponse>();
         List<VpcOfferingResponse> offeringResponses = new ArrayList<VpcOfferingResponse>();
-        for (VpcOffering offering : offerings) {
+        for (VpcOffering offering : offerings.first()) {
             VpcOfferingResponse offeringResponse = _responseGenerator.createVpcOfferingResponse(offering);
             offeringResponses.add(offeringResponse);
         }
 
-        response.setResponses(offeringResponses);
+        response.setResponses(offeringResponses, offerings.second());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fa74b3a3/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 9971bd5..5aa4721 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -113,6 +113,7 @@ import com.cloud.user.ResourceLimitService;
 import com.cloud.user.User;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
+import com.cloud.utils.StringUtils;
 import com.cloud.utils.Ternary;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.concurrency.NamedThreadFactory;
@@ -608,9 +609,9 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
     }
 
     @Override
-    public List<? extends VpcOffering> listVpcOfferings(Long id, String name, String
displayText, List<String> supportedServicesStr, Boolean isDefault, String keyword,
+    public Pair<List<? extends VpcOffering>,Integer> listVpcOfferings(Long id,
String name, String displayText, List<String> supportedServicesStr, Boolean isDefault,
String keyword,
         String state, Long startIndex, Long pageSizeVal) {
-        Filter searchFilter = new Filter(VpcOfferingVO.class, "created", false, startIndex,
pageSizeVal);
+        Filter searchFilter = new Filter(VpcOfferingVO.class, "created", false, null, null);
         SearchCriteria<VpcOfferingVO> sc = _vpcOffDao.createSearchCriteria();
 
         if (keyword != null) {
@@ -670,9 +671,21 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
                 }
             }
 
-            return supportedOfferings;
+            List<?> wPagination = StringUtils.applyPagination(supportedOfferings, startIndex,
pageSizeVal);
+            if (wPagination != null) {
+                @SuppressWarnings("unchecked")
+                Pair<List<? extends VpcOffering>, Integer> listWPagination =
new Pair<List<? extends VpcOffering>, Integer>((List<VpcOffering>) wPagination,
supportedOfferings.size());
+                return listWPagination;
+            }
+            return new Pair<List<? extends VpcOffering>, Integer>(supportedOfferings,
supportedOfferings.size());
         } else {
-            return offerings;
+            List<?> wPagination = StringUtils.applyPagination(offerings, startIndex,
pageSizeVal);
+            if (wPagination != null) {
+                @SuppressWarnings("unchecked")
+                Pair<List<? extends VpcOffering>, Integer> listWPagination =
new Pair<List<? extends VpcOffering>, Integer>((List<VpcOffering>) wPagination,
offerings.size());
+                return listWPagination;
+            }
+            return new Pair<List<? extends VpcOffering>, Integer>(offerings,
offerings.size());
         }
     }
 


Mime
View raw message