lower code smells
[appc.git] / appc-inbound / appc-interfaces-service / bundle / src / main / java / org / onap / appc / interfaces / service / executorImpl / ServiceExecutorImpl.java
index 67b9c6f..405dfcf 100644 (file)
@@ -6,6 +6,8 @@
  * ================================================================================
  * Modifications Copyright (C) 2019 Ericsson
  * ================================================================================
+ * Modifications Copyright (C) 2019 IBM
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -31,8 +33,8 @@ import java.util.Map;
 import org.onap.appc.aai.client.aai.AaiService;
 import org.onap.appc.interfaces.service.data.Request;
 import org.onap.appc.interfaces.service.data.ScopeOverlap;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.onap.ccsdk.sli.adaptors.aai.AAIClient;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
@@ -90,8 +92,8 @@ public class ServiceExecutorImpl {
 
         AaiService aaiService = getAaiService(aaiClient);
         SvcLogicContext ctx = getSvcLogicContext();
-        Map<String, String> params = new HashMap<String, String>();
-        List<String> inProgressVServerIds = new ArrayList<String>();
+        Map<String, String> params = new HashMap<>();
+        List<String> inProgressVServerIds = new ArrayList<>();
         String currentVnfcVserverId = new String();
         String currentRequestVnfcName = scopeOverlap.getCurrentRequest().getActionIdentifiers().getVnfcName();
         String currentRequestVServerId = scopeOverlap.getCurrentRequest().getActionIdentifiers().getvServerId();
@@ -99,27 +101,31 @@ public class ServiceExecutorImpl {
         params.put("vnfId", scopeOverlap.getVnfId());
         try {
             aaiService.getGenericVnfInfo(params, ctx);
-            int vm_count = Integer.parseInt(ctx.getAttribute("vm-count"));
+            int vmCount = Integer.parseInt(ctx.getAttribute("vm-count"));
                 for(Request inprogressRequest:inProgressRequests){
                     if(inprogressRequest.getActionIdentifiers().getVnfcName() != null){
-                    for (int i = 0; i < vm_count; i++) {
-                        if (ctx.getAttribute("vm[" + i + "].vnfc-name") != null && ctx.getAttribute("vm[" + i + "].vnfc-name")
-                        .equals(inprogressRequest.getActionIdentifiers().getVnfcName()))
-                            inProgressVServerIds.add(ctx.getAttribute("vm[" + i + "].vserver-id"));
-                        log.debug("Received vserver-id from AAI: " + inProgressVServerIds);
+                        for (int i = 0; i < vmCount; i++) {
+                            if (ctx.getAttribute("vm[" + i + "].vnfc-name") != null && ctx.getAttribute("vm[" + i + "].vnfc-name")
+                                    .equals(inprogressRequest.getActionIdentifiers().getVnfcName())) {
+                                String newInProgressVserverId = ctx.getAttribute("vm[" + i + "].vserver-id");
+                                inProgressVServerIds.add(newInProgressVserverId);
+                                log.debug("Received vserver-id from AAI: " + newInProgressVserverId);
+                            }
+                        }
                     }
-                }
             }
             for(Request inProgVserverIds:inProgressRequests)
                 if(inProgVserverIds.getActionIdentifiers().getvServerId() != null)
                     inProgressVServerIds.add(inProgVserverIds.getActionIdentifiers().getvServerId());
             if(currentRequestVnfcName != null){
-                for (int i = 0; i < vm_count; i++)
+                for (int i = 0; i < vmCount; i++) {
                     if (ctx.getAttribute("vm[" + i + "].vnfc-name") != null && ctx.getAttribute("vm[" + i + "].vnfc-name")
-                            .equals(currentRequestVnfcName))
-                 currentVnfcVserverId = ctx.getAttribute("vm[" + i + "].vserver-id");
-                log.debug("Received vserver-id from AAI: " + currentVnfcVserverId);
-                return inProgressVServerIds.contains(currentVnfcVserverId);
+                            .equals(currentRequestVnfcName)) {
+                        currentVnfcVserverId = ctx.getAttribute("vm[" + i + "].vserver-id");
+                        log.debug("Received vserver-id from AAI: " + currentVnfcVserverId);
+                        return inProgressVServerIds.contains(currentVnfcVserverId);
+                    }
+                }
             }
             for (Request request : inProgressRequests) {
                 if(!Strings.isNullOrEmpty(currentRequestVServerId)  && currentRequestVServerId.equalsIgnoreCase(request.getActionIdentifiers().getvServerId()))
@@ -130,7 +136,6 @@ public class ServiceExecutorImpl {
             }
             return Boolean.FALSE;
         } catch (Exception e) {
-            e.printStackTrace();
             log.debug(e.getMessage());
             throw e;
         }