@@ -146,71 +146,62 @@ public void processParameters(final BaseCmd cmd, final Map params) {
146146 final CommandType fieldType = parameterAnnotation .type ();
147147
148148 if (checkAccess != null ) {
149- // Verify that caller can perform actions in behalf of vm owner
150- //acumulate all Controlled Entities together.
149+ // Verify that caller can perform actions in behalf of vm
150+ // owner acumulate all Controlled Entities together.
151+ // parse the array of resource types and in case of map
152+ // check access on key or value or both as specified in @acl
153+ // implement external dao for classes that need findByName
154+ // for maps, specify access to be checkd on key or value.
155+ // Find the controlled entity DBid by uuid
151156
152- //parse the array of resource types and in case of map check access on key or value or both as specified in @acl
153- //implement external dao for classes that need findByName
154- //for maps, specify access to be checkd on key or value.
155-
156- // find the controlled entity DBid by uuid
157157 if (parameterAnnotation .entityType () != null ) {
158158 final Class <?>[] entityList = parameterAnnotation .entityType ()[0 ].getAnnotation (EntityReference .class ).value ();
159159
160- for ( final Class entity : entityList ) {
161- // Check if the parameter type is a single
162- // Id or list of id's/name's
163- switch ( fieldType ) {
164- case LIST :
165- final CommandType listType = parameterAnnotation . collectionType ();
166- switch ( listType ) {
167- case LONG :
168- case UUID :
169- final List < Long > listParam = ( List < Long >) field . get ( cmd );
170- for (final Long entityId : listParam ) {
160+ // Check if the parameter type is a single
161+ // Id or list of id's/name's
162+ switch ( fieldType ) {
163+ case LIST :
164+ final CommandType listType = parameterAnnotation . collectionType ();
165+ switch ( listType ) {
166+ case LONG :
167+ case UUID :
168+ final List < Long > listParam = ( List < Long >) field . get ( cmd );
169+ for ( final Long entityId : listParam ) {
170+ for (final Class entity : entityList ) {
171171 final Object entityObj = _entityMgr .findById (entity , entityId );
172- entitiesToAccess .put (entityObj , checkAccess .accessType ());
172+ if (entityObj != null ){
173+ entitiesToAccess .put (entityObj , checkAccess .accessType ());
174+ break ;
175+ }
173176 }
174- break ;
175- /*
176- * case STRING: List<String> listParam =
177- * new ArrayList<String>(); listParam =
178- * (List)field.get(cmd); for(String
179- * entityName: listParam){
180- * ControlledEntity entityObj =
181- * (ControlledEntity
182- * )daoClassInstance(entityId);
183- * entitiesToAccess.add(entityObj); }
184- * break;
185- */
186- default :
187- break ;
188- }
189- break ;
190- case LONG :
191- case UUID :
192- final Object entityObj = _entityMgr .findById (entity , (Long )field .get (cmd ));
193- entitiesToAccess .put (entityObj , checkAccess .accessType ());
194- break ;
195- default :
196- break ;
197- }
198-
199- if (ControlledEntity .class .isAssignableFrom (entity )) {
200- if (s_logger .isDebugEnabled ()) {
201- s_logger .debug ("ControlledEntity name is:" + entity .getName ());
177+ }
178+ break ;
179+ /*
180+ * case STRING: List<String> listParam = new
181+ * ArrayList<String>(); listParam =
182+ * (List)field.get(cmd); for(String entityName:
183+ * listParam){ ControlledEntity entityObj =
184+ * (ControlledEntity )daoClassInstance(entityId);
185+ * entitiesToAccess.add(entityObj); } break;
186+ */
187+ default :
188+ break ;
202189 }
203- }
204-
205- if (InfrastructureEntity .class .isAssignableFrom (entity )) {
206- if (s_logger .isDebugEnabled ()) {
207- s_logger .debug ("InfrastructureEntity name is:" + entity .getName ());
190+ break ;
191+ case LONG :
192+ case UUID :
193+ for (final Class entity : entityList ) {
194+ final Object entityObj = _entityMgr .findById (entity , (Long ) field .get (cmd ));
195+ if (entityObj != null ){
196+ entitiesToAccess .put (entityObj , checkAccess .accessType ());
197+ break ;
198+ }
208199 }
209- }
200+ break ;
201+ default :
202+ break ;
210203 }
211-
212204 }
213-
214205 }
215206
216207 } catch (final IllegalArgumentException e ) {
0 commit comments