summaryrefslogtreecommitdiffstats
path: root/openecomp-be/tools/zusammen-tools
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/tools/zusammen-tools')
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/ZipUtils.java48
1 files changed, 4 insertions, 44 deletions
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/ZipUtils.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/ZipUtils.java
index e0fd1a7535..96c7f17084 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/ZipUtils.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/util/ZipUtils.java
@@ -12,10 +12,6 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.Objects;
-import java.util.Scanner;
-import java.util.Set;
-import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
@@ -24,6 +20,10 @@ public class ZipUtils {
private static final Logger logger = LoggerFactory.getLogger(ZipUtils.class);
+ private ZipUtils() {
+ // prevent instantiation
+ }
+
public static void createZip(String zipFileName, Path dir) throws IOException {
File dirObj = dir.toFile();
Path zippedFile = Files.createFile(Paths.get(zipFileName));
@@ -41,46 +41,6 @@ public class ZipUtils {
}
}
- public static final Set<String> cleanStr(Set<String> inFilterStrs) {
- return inFilterStrs.stream().map(inFilterStr -> {
- if (Objects.isNull(inFilterStr)) {
- return inFilterStr;
- }
- Scanner scan = new Scanner(inFilterStr);
- while (scan.hasNextLine()) {
- inFilterStr = scan.nextLine().replaceAll("[^a-zA-Z0-9]", "");
- }
- return inFilterStr;
- }
- ).collect(Collectors.toSet());
- }
-
- static void addDir(File dirObj, ZipOutputStream out, String root, Set<String> filterItem) throws IOException {
- File[] files = dirObj.listFiles();
- filterItem = cleanStr(filterItem);
-
- for (int i = 0; i < files.length; i++) {
- if (files[i].isDirectory()) {
- addDir(files[i], out, root, filterItem);
- String filePath = files[i].getAbsolutePath().replace(root + File.separator, "") + File.separator;
- out.putNextEntry(new ZipEntry(filePath));
- continue;
- }
- try (FileInputStream in = new FileInputStream((files[i].getAbsolutePath()))) {
- String filePath = files[i].getAbsolutePath().replace(root + File.separator, "");
- if (filterItem.isEmpty() || filterItem.stream().anyMatch(s -> filePath.contains(s))) {
- out.putNextEntry(new ZipEntry(filePath));
- try {
- ByteStreams.copy(in, out);
- } finally {
- out.closeEntry();
- }
- }
-
- }
- }
- }
-
public static void unzip(Path zipFile, Path outputFolder) throws IOException {
if (zipFile == null || outputFolder == null) {
return;