You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/07 16:59:27 UTC

[4/4] git commit: api_refactoring: Fix build issue with api_refactoring branch.

api_refactoring: Fix build issue with api_refactoring branch.

Signed-off-by: Rohit Yadav <bh...@apache.org>


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

Branch: refs/heads/api_refactoring
Commit: eba353099ec09da656a2944e481c74c190880589
Parents: 3d04bfc
Author: Min Chen <mi...@citrix.com>
Authored: Thu Dec 6 14:54:22 2012 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Thu Dec 6 15:00:48 2012 -0800

----------------------------------------------------------------------
 api/src/com/cloud/api/response/UserVmResponse.java |    4 +
 server/src/com/cloud/api/ApiDispatcher.java        |  107 ++++++++-------
 .../com/cloud/network/as/AutoScaleManagerImpl.java |    2 +-
 3 files changed, 60 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/eba35309/api/src/com/cloud/api/response/UserVmResponse.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/response/UserVmResponse.java b/api/src/com/cloud/api/response/UserVmResponse.java
index 572d4ed..0e0d5c6 100755
--- a/api/src/com/cloud/api/response/UserVmResponse.java
+++ b/api/src/com/cloud/api/response/UserVmResponse.java
@@ -336,6 +336,10 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp
         this.securityGroupList = securityGroups;
     }
 
+    public void addSecurityGroup(SecurityGroupResponse securityGroup){
+        this.securityGroupList.add(securityGroup);
+    }
+
     public void setProjectId(String projectId) {
         this.projectId = projectId;
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/eba35309/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 40847ea..fc2b625 100755
--- a/server/src/com/cloud/api/ApiDispatcher.java
+++ b/server/src/com/cloud/api/ApiDispatcher.java
@@ -473,58 +473,61 @@ public class ApiDispatcher {
 	            	//for maps, specify access to be checkd on key or value.
 	            	
 	            	if(parameterAnnotation.resourceType() != null){
-	            		 Class<?>[] entity = parameterAnnotation.resourceType();
-	            				 
-	            		 if(ControlledEntity.class.isAssignableFrom(entity)){
-	                         if (s_logger.isDebugEnabled()) {
-	                             s_logger.debug("entity name is:" + entity.getName());
-	                         }
-	                         
-	                         if(s_instance._daoNameMap.containsKey(entity.getName())){
-	                        	 Class<? extends GenericDao> daoClass = s_instance._daoNameMap.get(entity.getName());
-	                        	 GenericDao daoClassInstance =  s_instance._locator.getDao(daoClass);
-	                        	 
-	                        	 //Check if the parameter type is a single Id or list of id's/name's
-	                        	 switch (fieldType) {                        	 
-			                         case LIST:
-		                                 CommandType listType = parameterAnnotation.collectionType();
-		                                 switch (listType) {
-    		                                 case LONG: 
-    		                                	 List<Long> listParam = new ArrayList<Long>();
-     											 listParam = (List)field.get(cmd);
-    
-    		                                	 for(Long entityId : listParam){
-    			    	                        	 ControlledEntity entityObj = (ControlledEntity)daoClassInstance.findById(entityId);
-    			    	                        	 entitiesToAccess.add(entityObj);
-    		                                	 }
-    			    	                     break;
-    		                                 /*case STRING:
-    		                                	 List<String> listParam = new ArrayList<String>();
-    		                                	 listParam = (List)field.get(cmd);
-    		                                	 for(String entityName: listParam){
-    			    	                        	 ControlledEntity entityObj = (ControlledEntity)daoClassInstance(entityId);
-    			    	                        	 entitiesToAccess.add(entityObj);
-    		                                	 }
-    		                                     break;
-    		                                  */
-    		                                 default:
-    		                                 break;
-		                                 }
-			                             break;
-			                         case LONG:
-			                        	 Long entityId = (Long)field.get(cmd);
-			                        	 ControlledEntity entityObj = (ControlledEntity)daoClassInstance.findById(entityId);
-			                        	 entitiesToAccess.add(entityObj);
-			                        	 break;
-			                         default:
-			                        	 break;
-	                        	 }
-	                             
-	                        	 
-	                         }
-	            			 
-	            		 }
-	            		 
+				 Class<?>[] entityList = parameterAnnotation.resourceType();
+				 for (Class entity : entityList){
+                            if (ControlledEntity.class.isAssignableFrom(entity)) {
+                                if (s_logger.isDebugEnabled()) {
+                                    s_logger.debug("entity name is:" + entity.getName());
+                                }
+
+                                if (s_instance._daoNameMap.containsKey(entity.getName())) {
+                                    Class<? extends GenericDao> daoClass = s_instance._daoNameMap.get(entity.getName());
+                                    GenericDao daoClassInstance = s_instance._locator.getDao(daoClass);
+
+                                    // Check if the parameter type is a single
+                                    // Id or list of id's/name's
+                                    switch (fieldType) {
+                                    case LIST:
+                                        CommandType listType = parameterAnnotation.collectionType();
+                                        switch (listType) {
+                                        case LONG:
+                                            List<Long> listParam = new ArrayList<Long>();
+                                            listParam = (List) field.get(cmd);
+
+                                            for (Long entityId : listParam) {
+                                                ControlledEntity entityObj = (ControlledEntity) daoClassInstance.findById(entityId);
+                                                entitiesToAccess.add(entityObj);
+                                            }
+                                            break;
+                                        /*
+                                         * case STRING: List<String> listParam =
+                                         * new ArrayList<String>(); listParam =
+                                         * (List)field.get(cmd); for(String
+                                         * entityName: listParam){
+                                         * ControlledEntity entityObj =
+                                         * (ControlledEntity
+                                         * )daoClassInstance(entityId);
+                                         * entitiesToAccess.add(entityObj); }
+                                         * break;
+                                         */
+                                        default:
+                                            break;
+                                        }
+                                        break;
+                                    case LONG:
+                                        Long entityId = (Long) field.get(cmd);
+                                        ControlledEntity entityObj = (ControlledEntity) daoClassInstance.findById(entityId);
+                                        entitiesToAccess.add(entityObj);
+                                        break;
+                                    default:
+                                        break;
+                                    }
+
+                                }
+
+                            }
+                        }
+
 	            	}
 	            	
 	            }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/eba35309/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
index 5673c37..35b6c9b 100644
--- a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
+++ b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
@@ -353,7 +353,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleManager, AutoScaleSe
          * For ex. if projectId is given as a string instead of an long value, this
          * will be throwing an error.
          */
-        ApiDispatcher.setupParameters(new DeployVMCmd(), deployParams);
+        ApiDispatcher.setupParameters(new DeployVMCmd(), deployParams, new ArrayList<ControlledEntity>());
 
         if (autoscaleUserId == null) {
             autoscaleUserId = UserContext.current().getCallerUserId();