cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] rhtyd closed pull request #3108: Throw InvalidParameterValueException for failing ApiArgValidator
Date Mon, 24 Dec 2018 18:20:57 GMT
rhtyd closed pull request #3108: Throw InvalidParameterValueException for failing ApiArgValidator
URL: https://github.com/apache/cloudstack/pull/3108
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/server/src/main/java/com/cloud/api/dispatch/ParamProcessWorker.java b/server/src/main/java/com/cloud/api/dispatch/ParamProcessWorker.java
index f030209c9a5..970e62fd6ba 100644
--- a/server/src/main/java/com/cloud/api/dispatch/ParamProcessWorker.java
+++ b/server/src/main/java/com/cloud/api/dispatch/ParamProcessWorker.java
@@ -22,6 +22,7 @@
 import java.lang.reflect.Field;
 import java.text.DateFormat;
 import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
@@ -30,18 +31,15 @@
 import java.util.Map;
 import java.util.StringTokenizer;
 import java.util.regex.Matcher;
-import java.text.SimpleDateFormat;
 
 import javax.inject.Inject;
 
-import com.google.common.base.Strings;
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.acl.ControlledEntity;
 import org.apache.cloudstack.acl.InfrastructureEntity;
 import org.apache.cloudstack.acl.SecurityChecker;
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
 import org.apache.cloudstack.api.ACL;
+import org.apache.cloudstack.api.ApiArgValidator;
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCreateCmd;
 import org.apache.cloudstack.api.BaseCmd;
@@ -50,7 +48,6 @@
 import org.apache.cloudstack.api.InternalIdentity;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.ApiArgValidator;
 import org.apache.cloudstack.api.command.admin.resource.ArchiveAlertsCmd;
 import org.apache.cloudstack.api.command.admin.resource.DeleteAlertsCmd;
 import org.apache.cloudstack.api.command.admin.usage.GetUsageRecordsCmd;
@@ -58,6 +55,7 @@
 import org.apache.cloudstack.api.command.user.event.DeleteEventsCmd;
 import org.apache.cloudstack.api.command.user.event.ListEventsCmd;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.log4j.Logger;
 
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.user.Account;
@@ -65,6 +63,7 @@
 import com.cloud.utils.DateUtil;
 import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.exception.CloudRuntimeException;
+import com.google.common.base.Strings;
 
 public class ParamProcessWorker implements DispatchWorker {
 
@@ -96,7 +95,7 @@ public void handle(final DispatchTask task) {
 
     private void validateNonEmptyString(final Object param, final String argName) {
         if (param == null || Strings.isNullOrEmpty(param.toString())) {
-            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, String.format("Empty or
null value provided for API arg: %s", argName));
+            throw new InvalidParameterValueException(String.format("Empty or null value provided
for API arg: %s", argName));
         }
     }
 
@@ -108,7 +107,7 @@ private void validateNaturalNumber(final Object param, final String argName)
{
             value = Long.valueOf(param.toString());
         }
         if (value == null || value < 1L) {
-            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, String.format("Invalid
value provided for API arg: %s", argName));
+            throw new InvalidParameterValueException(String.format("Invalid value provided
for API arg: %s", argName));
         }
     }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message