Improvements in VfResourceStructure 25/89225/1
authorr.bogacki <r.bogacki@samsung.com>
Tue, 4 Jun 2019 10:30:05 +0000 (12:30 +0200)
committerr.bogacki <r.bogacki@samsung.com>
Tue, 4 Jun 2019 10:32:20 +0000 (12:32 +0200)
Improvements in VfResourceStructure according to the Sonar analyses.
-Removed unnecessary imports.
-Removed unnecessary exceptions.
-Improvements for possible NPE issues.

Issue-ID: SO-1983
Signed-off-by: Robert Bogacki <r.bogacki@samsung.com>
Change-Id: I014c5de19eca853cf1263b541e2c34b6e6db9b1d

asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java

index b29e856..5ae57e4 100644 (file)
@@ -25,7 +25,7 @@ package org.onap.so.asdc.installer;
 
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
-import java.util.HashMap;
+import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -81,6 +81,7 @@ public class VfResourceStructure extends ResourceStructure {
         super(notificationdata, resourceinstance);
         this.resourceType = ResourceType.VF_RESOURCE;
         vfModulesStructureList = new LinkedList<>();
+        vfModulesMetadataList = new ArrayList<>();
     }
 
     public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo,
@@ -106,7 +107,7 @@ public class VfResourceStructure extends ResourceStructure {
     }
 
     protected void addArtifactByType(IArtifactInfo artifactinfo, IDistributionClientDownloadResult clientResult,
-            VfModuleArtifact vfModuleArtifact) throws UnsupportedEncodingException {
+            VfModuleArtifact vfModuleArtifact) {
 
         switch (artifactinfo.getArtifactType()) {
             case ASDCConfiguration.HEAT:
@@ -133,7 +134,7 @@ public class VfResourceStructure extends ResourceStructure {
     public void createVfModuleStructures() throws ArtifactInstallerException {
 
         // for vender tosca VNF there is no VFModule in VF
-        if (vfModulesMetadataList == null) {
+        if (vfModulesMetadataList.isEmpty()) {
             logger.info(Strings.repeat("{} ", 4), MessageEnum.ASDC_GENERAL_INFO.toString(),
                     "There is no VF mudules in the VF.", "ASDC", "createVfModuleStructures");
             return;
@@ -148,6 +149,7 @@ public class VfResourceStructure extends ResourceStructure {
         return vfModulesStructureList;
     }
 
+    @Override
     public Map<String, VfModuleArtifact> getArtifactsMapByUUID() {
         return artifactsMapByUUID;
     }
@@ -204,6 +206,6 @@ public class VfResourceStructure extends ResourceStructure {
         } catch (IOException e) {
             logger.debug("IOException : ", e);
         }
-        return null;
+        return new ArrayList<>();
     }
 }