diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java index 1ba61a4d6c4..c55d5642691 100644 --- a/server/src/com/cloud/api/ApiDispatcher.java +++ b/server/src/com/cloud/api/ApiDispatcher.java @@ -143,6 +143,14 @@ public class ApiDispatcher { public static void setupParameters(BaseCmd cmd, Map params){ Map unpackedParams = cmd.unpackParams(params); + if (cmd instanceof BaseListCmd) { + if ((unpackedParams.get(ApiConstants.PAGE) == null) && (unpackedParams.get(ApiConstants.PAGE_SIZE) != null)) { + 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)) { + throw new ServerApiException(BaseCmd.PARAM_ERROR, "\"pagesize\" parameter is required when \"page\" is specified"); + } + } + Field[] fields = cmd.getClass().getDeclaredFields(); Class superClass = cmd.getClass().getSuperclass(); while (BaseCmd.class.isAssignableFrom(superClass)) {