Skip to content

Commit eba3530

Browse files
minchen07yadvr
authored andcommitted
api_refactoring: Fix build issue with api_refactoring branch.
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
1 parent 3d04bfc commit eba3530

3 files changed

Lines changed: 60 additions & 53 deletions

File tree

api/src/com/cloud/api/response/UserVmResponse.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ public void setSecurityGroupList(Set<SecurityGroupResponse> securityGroups) {
336336
this.securityGroupList = securityGroups;
337337
}
338338

339+
public void addSecurityGroup(SecurityGroupResponse securityGroup){
340+
this.securityGroupList.add(securityGroup);
341+
}
342+
339343
public void setProjectId(String projectId) {
340344
this.projectId = projectId;
341345
}

server/src/com/cloud/api/ApiDispatcher.java

Lines changed: 55 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -473,58 +473,61 @@ public static void setupParameters(BaseCmd cmd, Map<String, String> params, List
473473
//for maps, specify access to be checkd on key or value.
474474

475475
if(parameterAnnotation.resourceType() != null){
476-
Class<?>[] entity = parameterAnnotation.resourceType();
477-
478-
if(ControlledEntity.class.isAssignableFrom(entity)){
479-
if (s_logger.isDebugEnabled()) {
480-
s_logger.debug("entity name is:" + entity.getName());
481-
}
482-
483-
if(s_instance._daoNameMap.containsKey(entity.getName())){
484-
Class<? extends GenericDao> daoClass = s_instance._daoNameMap.get(entity.getName());
485-
GenericDao daoClassInstance = s_instance._locator.getDao(daoClass);
486-
487-
//Check if the parameter type is a single Id or list of id's/name's
488-
switch (fieldType) {
489-
case LIST:
490-
CommandType listType = parameterAnnotation.collectionType();
491-
switch (listType) {
492-
case LONG:
493-
List<Long> listParam = new ArrayList<Long>();
494-
listParam = (List)field.get(cmd);
495-
496-
for(Long entityId : listParam){
497-
ControlledEntity entityObj = (ControlledEntity)daoClassInstance.findById(entityId);
498-
entitiesToAccess.add(entityObj);
499-
}
500-
break;
501-
/*case STRING:
502-
List<String> listParam = new ArrayList<String>();
503-
listParam = (List)field.get(cmd);
504-
for(String entityName: listParam){
505-
ControlledEntity entityObj = (ControlledEntity)daoClassInstance(entityId);
506-
entitiesToAccess.add(entityObj);
507-
}
508-
break;
509-
*/
510-
default:
511-
break;
512-
}
513-
break;
514-
case LONG:
515-
Long entityId = (Long)field.get(cmd);
516-
ControlledEntity entityObj = (ControlledEntity)daoClassInstance.findById(entityId);
517-
entitiesToAccess.add(entityObj);
518-
break;
519-
default:
520-
break;
521-
}
522-
523-
524-
}
525-
526-
}
527-
476+
Class<?>[] entityList = parameterAnnotation.resourceType();
477+
for (Class entity : entityList){
478+
if (ControlledEntity.class.isAssignableFrom(entity)) {
479+
if (s_logger.isDebugEnabled()) {
480+
s_logger.debug("entity name is:" + entity.getName());
481+
}
482+
483+
if (s_instance._daoNameMap.containsKey(entity.getName())) {
484+
Class<? extends GenericDao> daoClass = s_instance._daoNameMap.get(entity.getName());
485+
GenericDao daoClassInstance = s_instance._locator.getDao(daoClass);
486+
487+
// Check if the parameter type is a single
488+
// Id or list of id's/name's
489+
switch (fieldType) {
490+
case LIST:
491+
CommandType listType = parameterAnnotation.collectionType();
492+
switch (listType) {
493+
case LONG:
494+
List<Long> listParam = new ArrayList<Long>();
495+
listParam = (List) field.get(cmd);
496+
497+
for (Long entityId : listParam) {
498+
ControlledEntity entityObj = (ControlledEntity) daoClassInstance.findById(entityId);
499+
entitiesToAccess.add(entityObj);
500+
}
501+
break;
502+
/*
503+
* case STRING: List<String> listParam =
504+
* new ArrayList<String>(); listParam =
505+
* (List)field.get(cmd); for(String
506+
* entityName: listParam){
507+
* ControlledEntity entityObj =
508+
* (ControlledEntity
509+
* )daoClassInstance(entityId);
510+
* entitiesToAccess.add(entityObj); }
511+
* break;
512+
*/
513+
default:
514+
break;
515+
}
516+
break;
517+
case LONG:
518+
Long entityId = (Long) field.get(cmd);
519+
ControlledEntity entityObj = (ControlledEntity) daoClassInstance.findById(entityId);
520+
entitiesToAccess.add(entityObj);
521+
break;
522+
default:
523+
break;
524+
}
525+
526+
}
527+
528+
}
529+
}
530+
528531
}
529532

530533
}

server/src/com/cloud/network/as/AutoScaleManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public AutoScaleVmProfile createAutoScaleVmProfile(CreateAutoScaleVmProfileCmd c
353353
* For ex. if projectId is given as a string instead of an long value, this
354354
* will be throwing an error.
355355
*/
356-
ApiDispatcher.setupParameters(new DeployVMCmd(), deployParams);
356+
ApiDispatcher.setupParameters(new DeployVMCmd(), deployParams, new ArrayList<ControlledEntity>());
357357

358358
if (autoscaleUserId == null) {
359359
autoscaleUserId = UserContext.current().getCallerUserId();

0 commit comments

Comments
 (0)