summaryrefslogtreecommitdiffstats
path: root/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main
diff options
context:
space:
mode:
authorr.bogacki <r.bogacki@samsung.com>2019-04-10 08:33:09 +0200
committerr.bogacki <r.bogacki@samsung.com>2019-04-10 16:18:57 +0200
commit565a0054e3b01ef4a730651b7b82102c021c0972 (patch)
treec936d7ba3d0b3d46b19b58a18eccf0186efeb9a0 /adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main
parented66a29ce8e0068740466e13fa6517791cce9aeb (diff)
Fixed latest Sonar blocker issues
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>
Diffstat (limited to 'adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main')
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java
index 045b98007d..32bc5ae3aa 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java
@@ -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");
}