diff options
author | 2021-11-26 14:40:29 +0000 | |
---|---|---|
committer | 2021-11-29 14:36:12 +0000 | |
commit | 6c32cbc7343bd56f62007451071c4b26c875382f (patch) | |
tree | fa3250eb24d518e5f15cb629bdb462b96be769c5 /openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java | |
parent | e9171113772c0c7dc3f7514ffd0660d1e0f8ef02 (diff) |
Add VNFD to NSD when using S3 storage
Change-Id: I8eb810fadfe54b335647e71e21115514963b4be7
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Issue-ID: SDC-3792
Diffstat (limited to 'openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java')
-rw-r--r-- | openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java index 60ff1c172a..d6df24e4c2 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/file/FileUtils.java @@ -30,12 +30,12 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.function.Function; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.onap.sdc.tosca.services.YamlUtil; import org.openecomp.core.utilities.json.JsonUtil; -import org.openecomp.sdc.common.zip.ZipUtils; -import org.openecomp.sdc.common.zip.exception.ZipException; /** * The type File utils. @@ -206,20 +206,24 @@ public class FileUtils { /** * Gets file content map from zip. * - * @param zipData the zip data + * @param inputStream the zip data * @return the file content map from zip - * @throws ZipException when an error occurs while extracting zip files + * @throws IOException when an error occurs while extracting zip files */ - public static FileContentHandler getFileContentMapFromZip(byte[] zipData) throws ZipException { - final Map<String, byte[]> zipFileAndByteMap = ZipUtils.readZip(zipData, true); - final FileContentHandler fileContentHandler = new FileContentHandler(); - zipFileAndByteMap.forEach((path, bytes) -> { - if (bytes == null) { - fileContentHandler.addFolder(path); + public static FileContentHandler getFileContentMapFromZip(final InputStream inputStream) throws IOException { + + final var zipInputStream = new ZipInputStream(inputStream); + ZipEntry zipEntry; + final var fileContentHandler = new FileContentHandler(); + while ((zipEntry = zipInputStream.getNextEntry()) != null) { + final var entryName = zipEntry.getName(); + if (zipEntry.isDirectory()) { + fileContentHandler.addFolder(entryName); } else { - fileContentHandler.addFile(path, bytes); + fileContentHandler.addFile(entryName, zipInputStream.readAllBytes()); } - }); + + } return fileContentHandler; } |