Fixed latest Sonar blocker issues 97/84797/7
authorr.bogacki <r.bogacki@samsung.com>
Wed, 10 Apr 2019 06:33:09 +0000 (08:33 +0200)
committerr.bogacki <r.bogacki@samsung.com>
Wed, 10 Apr 2019 14:18:57 +0000 (16:18 +0200)
Fixed blockers according to Sonar analysis.

Change-Id: I2c2d053b66019b74ee20b0a56fb7b93bf931bb61
Issue-ID: SO-1734
Signed-off-by: Robert Bogacki <r.bogacki@samsung.com>
Signed-off-by: Katsia Kazak <k.kazak@samsung.com>
adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java
vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/notifications/VnfInstantiationNotification.java
vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/notifications/VnfmAdapterCreationNotification.java
vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/notifications/VnfmAdapterDeletionNotification.java

index 045b980..32bc5ae 100644 (file)
@@ -2,6 +2,8 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
+ *  Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * 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
@@ -39,7 +41,11 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
-import java.util.*;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 import static com.google.common.base.Splitter.on;
@@ -48,11 +54,13 @@ import static com.google.common.io.ByteStreams.toByteArray;
 import static java.lang.String.format;
 import static org.apache.http.HttpHeaders.ACCEPT;
 import static org.apache.http.HttpHeaders.AUTHORIZATION;
-import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.*;
+import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.abortOperation;
+import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.child;
+import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.childElement;
+import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.children;
 import static org.slf4j.LoggerFactory.getLogger;
 import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE;
 
-
 @Component
 public class SdcPackageProvider {
     private static final String GET_PACKAGE_URL = "%s/catalog/resources/%s/toscaModel";
@@ -70,7 +78,6 @@ public class SdcPackageProvider {
     @Value("${sdc.endpoint}")
     private String baseUrl;
 
-
     public String getVnfdId(String csarId) {
         return getVnfNodeProperty(csarId, "descriptor_id");
     }
@@ -125,8 +132,7 @@ public class SdcPackageProvider {
 
     private byte[] getPackage(String csarId) {
         final String SERVICE_NAME = "vnfm-adapter";
-        try {
-            CloseableHttpClient client = HttpClients.createDefault();
+        try (CloseableHttpClient client = HttpClients.createDefault()) {
             HttpGet httpget = new HttpGet(format(GET_PACKAGE_URL, baseUrl, csarId));
             httpget.setHeader(ACCEPT, APPLICATION_OCTET_STREAM_VALUE);
             httpget.setHeader("X-ECOMP-InstanceID", SERVICE_NAME);
@@ -140,7 +146,6 @@ public class SdcPackageProvider {
             HttpEntity entity = response.getEntity();
             InputStream is = entity.getContent();
             byte[] bytes = toByteArray(is);
-            client.close();
             return bytes;
         } catch (Exception e) {
             throw abortOperation("Unable to download " + csarId + " package from SDC", e);
@@ -182,7 +187,6 @@ public class SdcPackageProvider {
         throw new NoSuchElementException("Unable to find the " + path + " in archive found: " + items);
     }
 
-
     public String getFlavourId(String csarId) {
         return getVnfNodeProperty(csarId, "flavour_id");
     }
index 896a8bd..22c4f95 100644 (file)
@@ -553,21 +553,22 @@ public class ServicePluginFactory {
 
         // Now we need to query terminal points from SP resourcemgr system.
         List<Object> locationTerminalPointList = queryTerminalPointsFromServiceProviderSystem(srcLocation, dstLocation);
-        Map<String, Object> tpInfoMap = (Map<String, Object>) locationTerminalPointList.get(0);
-
-        serviceRequestInputs.put("inner-src-access-provider-id", tpInfoMap.get("access-provider-id"));
-        serviceRequestInputs.put("inner-src-access-client-id", tpInfoMap.get("access-client-id"));
-        serviceRequestInputs.put("inner-src-access-topology-id", tpInfoMap.get("access-topology-id"));
-        serviceRequestInputs.put("inner-src-access-node-id", tpInfoMap.get("access-node-id"));
-        serviceRequestInputs.put("inner-src-access-ltp-id", tpInfoMap.get("access-ltp-id"));
-        tpInfoMap = (Map<String, Object>) locationTerminalPointList.get(1);
-
-        serviceRequestInputs.put("inner-dst-access-provider-id", tpInfoMap.get("access-provider-id"));
-        serviceRequestInputs.put("inner-dst-access-client-id", tpInfoMap.get("access-client-id"));
-        serviceRequestInputs.put("inner-dst-access-topology-id", tpInfoMap.get("access-topology-id"));
-        serviceRequestInputs.put("inner-dst-access-node-id", tpInfoMap.get("access-node-id"));
-        serviceRequestInputs.put("inner-dst-access-ltp-id", tpInfoMap.get("access-ltp-id"));
-
+        if (locationTerminalPointList != null) {
+            Map<String, Object> tpInfoMap = (Map<String, Object>) locationTerminalPointList.get(0);
+
+            serviceRequestInputs.put("inner-src-access-provider-id", tpInfoMap.get("access-provider-id"));
+            serviceRequestInputs.put("inner-src-access-client-id", tpInfoMap.get("access-client-id"));
+            serviceRequestInputs.put("inner-src-access-topology-id", tpInfoMap.get("access-topology-id"));
+            serviceRequestInputs.put("inner-src-access-node-id", tpInfoMap.get("access-node-id"));
+            serviceRequestInputs.put("inner-src-access-ltp-id", tpInfoMap.get("access-ltp-id"));
+            tpInfoMap = (Map<String, Object>) locationTerminalPointList.get(1);
+
+            serviceRequestInputs.put("inner-dst-access-provider-id", tpInfoMap.get("access-provider-id"));
+            serviceRequestInputs.put("inner-dst-access-client-id", tpInfoMap.get("access-client-id"));
+            serviceRequestInputs.put("inner-dst-access-topology-id", tpInfoMap.get("access-topology-id"));
+            serviceRequestInputs.put("inner-dst-access-node-id", tpInfoMap.get("access-node-id"));
+            serviceRequestInputs.put("inner-dst-access-ltp-id", tpInfoMap.get("access-ltp-id"));
+        }
         String newRequest = getJsonString(uuiObject);
         return newRequest;
     }
index 3bf3d60..153970b 100644 (file)
@@ -2,6 +2,8 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
+ *  Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * 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
@@ -37,6 +39,7 @@ public class VnfInstantiationNotification implements Runnable {
             Thread.sleep(10000);
         } catch (final InterruptedException e) {
             e.printStackTrace();
+            Thread.currentThread().interrupt();
         }
         System.out.println("Instantiation process finished");
     }
index 61d6f7e..ff299ce 100644 (file)
@@ -2,6 +2,8 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
+ *  Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * 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
@@ -33,6 +35,7 @@ public class VnfmAdapterCreationNotification implements Runnable {
             Thread.sleep(10000);
         } catch (final InterruptedException e) {
             e.printStackTrace();
+            Thread.currentThread().interrupt();
         }
         System.out.println("Call to VNFM Adapter-Create");
     }
index 0ad7365..f7a8eaa 100644 (file)
@@ -2,6 +2,8 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
+ *  Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * 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
@@ -33,6 +35,7 @@ public class VnfmAdapterDeletionNotification implements Runnable {
             Thread.sleep(10000);
         } catch (final InterruptedException e) {
             e.printStackTrace();
+            Thread.currentThread().interrupt();
         }
         System.out.println("Call to VNFM Adapter-Delete");
     }