diff options
Diffstat (limited to 'adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter')
-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"); } |