diff options
author | Seshu Kumar M <seshu.kumar.m@huawei.com> | 2019-04-11 06:46:05 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-04-11 06:46:05 +0000 |
commit | 27ea7c27fe1a01b4375552a1403c1e0b7a111f0b (patch) | |
tree | 59c6338383aa896c3a939b0a702f59a48dfc898c /adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java | |
parent | e44ce517546de531b5a74b7102a4d449a902f190 (diff) | |
parent | 565a0054e3b01ef4a730651b7b82102c021c0972 (diff) |
Merge "Fixed latest Sonar blocker issues"
Diffstat (limited to 'adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java')
-rw-r--r-- | adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java | 20 |
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"); } |