diff --git a/api/src/com/cloud/api/BaseListCmd.java b/api/src/com/cloud/api/BaseListCmd.java index 6c4a743168f..cec856707d9 100755 --- a/api/src/com/cloud/api/BaseListCmd.java +++ b/api/src/com/cloud/api/BaseListCmd.java @@ -24,6 +24,7 @@ import com.cloud.exception.InvalidParameterValueException; public abstract class BaseListCmd extends BaseCmd { private static Long MAX_PAGESIZE = null; + public static Long PAGESIZE_UNLIMITED = -1L; // /////////////////////////////////////////////////// // ///////// BaseList API parameters ///////////////// @@ -58,7 +59,7 @@ public abstract class BaseListCmd extends BaseCmd { throw new InvalidParameterValueException("Page size can't exceed max allowed page size value: " + MAX_PAGESIZE.longValue()); } - if (pageSize != null && pageSize.longValue() == -1 && page != null) { + if (pageSize != null && pageSize.longValue() == PAGESIZE_UNLIMITED && page != null) { throw new InvalidParameterValueException("Can't specify page parameter when pagesize is -1 (Unlimited)"); } @@ -66,7 +67,7 @@ public abstract class BaseListCmd extends BaseCmd { } static void configure() { - if (_configService.getDefaultPageSize().longValue() != -1) { + if (_configService.getDefaultPageSize().longValue() != PAGESIZE_UNLIMITED) { MAX_PAGESIZE = _configService.getDefaultPageSize(); } } @@ -80,8 +81,12 @@ public abstract class BaseListCmd extends BaseCmd { public Long getPageSizeVal() { Long defaultPageSize = MAX_PAGESIZE; Integer pageSizeInt = getPageSize(); - if (pageSizeInt != null && pageSizeInt.intValue() != -1) { - defaultPageSize = pageSizeInt.longValue(); + if (pageSizeInt != null) { + if (pageSizeInt.longValue() == PAGESIZE_UNLIMITED) { + defaultPageSize = null; + } else { + defaultPageSize = pageSizeInt.longValue(); + } } return defaultPageSize; } diff --git a/api/src/com/cloud/api/commands/UpdateStorageNetworkIpRangeCmd.java b/api/src/com/cloud/api/commands/UpdateStorageNetworkIpRangeCmd.java index 5be97ad1733..675ffb149ec 100755 --- a/api/src/com/cloud/api/commands/UpdateStorageNetworkIpRangeCmd.java +++ b/api/src/com/cloud/api/commands/UpdateStorageNetworkIpRangeCmd.java @@ -9,7 +9,6 @@ import com.cloud.api.IdentityMapper; import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; -import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.StorageNetworkIpRangeResponse; import com.cloud.dc.StorageNetworkIpRange; import com.cloud.event.EventTypes; diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java index 3a88155aebe..c216dda4574 100755 --- a/server/src/com/cloud/api/ApiDispatcher.java +++ b/server/src/com/cloud/api/ApiDispatcher.java @@ -175,9 +175,15 @@ public class ApiDispatcher { Map unpackedParams = cmd.unpackParams(params); if (cmd instanceof BaseListCmd) { - if ((unpackedParams.get(ApiConstants.PAGE) == null) && (unpackedParams.get(ApiConstants.PAGE_SIZE) != null)) { + Object pageSizeObj = unpackedParams.get(ApiConstants.PAGE_SIZE); + Long pageSize = null; + if (pageSizeObj != null) { + pageSize = Long.valueOf((String)pageSizeObj); + } + + if ((unpackedParams.get(ApiConstants.PAGE) == null) && (pageSize != null && pageSize != BaseListCmd.PAGESIZE_UNLIMITED)) { throw new ServerApiException(BaseCmd.PARAM_ERROR, "\"page\" parameter is required when \"pagesize\" is specified"); - } else if ((unpackedParams.get(ApiConstants.PAGE_SIZE) == null) && (unpackedParams.get(ApiConstants.PAGE) != null)) { + } else if (pageSize == null && (unpackedParams.get(ApiConstants.PAGE) != null)) { throw new ServerApiException(BaseCmd.PARAM_ERROR, "\"pagesize\" parameter is required when \"page\" is specified"); } }