server: Make ApiDispatcher backward compatible to not throw error on incorrect 
params

Incorrect params are silently ignored in 4.0 and before. The fix would log the 
error
in debug log, but will continue processing. In case of an issue with uuid or 
param
an empty response is sent, for ex. in case of deleted entities as well.

Signed-off-by: Rohit Yadav <[email protected]>


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

Branch: refs/heads/api_refactoring
Commit: 98d5719b57e34b5852fb9e27ea939361a75a2099
Parents: 223bfc0
Author: Rohit Yadav <[email protected]>
Authored: Thu Jan 3 17:17:21 2013 -0800
Committer: Rohit Yadav <[email protected]>
Committed: Thu Jan 3 22:32:46 2013 -0800

----------------------------------------------------------------------
 server/src/com/cloud/api/ApiDispatcher.java |   13 +++----------
 1 files changed, 3 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/98d5719b/server/src/com/cloud/api/ApiDispatcher.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDispatcher.java 
b/server/src/com/cloud/api/ApiDispatcher.java
index b81e070..0f7f092 100755
--- a/server/src/com/cloud/api/ApiDispatcher.java
+++ b/server/src/com/cloud/api/ApiDispatcher.java
@@ -582,6 +582,9 @@ public class ApiDispatcher {
             if (internalId != null)
                 break;
         }
+        if (internalId == null && s_logger.isDebugEnabled()) {
+            s_logger.debug("Object entity with uuid=" + uuid + " does not 
exist in the database.");
+        }
         return internalId;
     }
 
@@ -655,11 +658,6 @@ public class ApiDispatcher {
                                 if (token.isEmpty())
                                     break;
                                 Long internalId = 
translateUuidToInternalId(token, annotation);
-                                // If id is null, entity with the uuid was not 
found, throw exception
-                                if (internalId == null) {
-                                    throw new 
InvalidParameterValueException("No entity with " + field.getName() + "(uuid)="
-                                            + paramObj.toString() + " was 
found in the database.");
-                                }
                                 listParam.add(internalId);
                                 break;
                             case LONG: {
@@ -679,11 +677,6 @@ public class ApiDispatcher {
                 if (paramObj.toString().isEmpty())
                     break;
                 Long internalId = 
translateUuidToInternalId(paramObj.toString(), annotation);
-                // If id is null, entity with the uuid was not found, throw 
exception
-                if (internalId == null) {
-                    throw new InvalidParameterValueException("Object entity 
with " + field.getName() + "(uuid)="
-                            + paramObj.toString() + " was not found.");
-                }
                 field.set(cmdObj, internalId);
                 break;
             case LONG:

Reply via email to