|
14 | 14 | public class Compression { |
15 | 15 | private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(Compression.class); |
16 | 16 |
|
17 | | - private String path; |
18 | | - private String format; |
| 17 | + private String absolutePath; |
19 | 18 | private GXBaseCollection<SdtMessages_Message>[] messages; |
20 | 19 | private ArrayList<String> filesToCompress; |
21 | 20 |
|
22 | 21 | public Compression() {} |
23 | 22 |
|
24 | | - public Compression(String path, String format, GXBaseCollection<SdtMessages_Message>[] messages) { |
25 | | - this.path = path; |
26 | | - this.format = format; |
| 23 | + public Compression(String absolutePath, GXBaseCollection<SdtMessages_Message>[] messages) { |
| 24 | + this.absolutePath = absolutePath; |
27 | 25 | this.messages = messages; |
28 | 26 | filesToCompress = new ArrayList<>(); |
29 | 27 | } |
30 | 28 |
|
31 | | - public void setPath(String path) { |
32 | | - this.path = path; |
| 29 | + public void setAbsolutePath(String path) { |
| 30 | + this.absolutePath = path; |
33 | 31 | } |
34 | 32 |
|
35 | | - public void setFormat(String format) { |
36 | | - this.format = format; |
37 | | - } |
38 | | - |
39 | | - public void addFile(String filePath) { |
| 33 | + public void addElement(String filePath) { |
40 | 34 | filesToCompress.add(filePath); |
41 | 35 | } |
42 | 36 |
|
43 | | - public void addFolder(String folderPath) { |
44 | | - Path path = Paths.get(folderPath); |
45 | | - try (Stream<Path> stream = Files.walk(path)) { |
46 | | - stream.filter(Files::isRegularFile) |
47 | | - .forEach(p -> addFile(p.toAbsolutePath().toString())); |
48 | | - } catch (IOException e) { |
49 | | - log.error("Failed to process directory: {}", folderPath, e); |
50 | | - } |
51 | | - } |
52 | | - |
53 | 37 | public Boolean save() { |
54 | | - return GXCompressor.compressFiles(filesToCompress, path, format, messages); |
| 38 | + return GXCompressor.compress(filesToCompress, absolutePath, messages); |
55 | 39 | } |
56 | 40 |
|
57 | 41 | public void clear() { |
58 | | - path = ""; |
59 | | - format = ""; |
| 42 | + absolutePath = ""; |
60 | 43 | filesToCompress = new ArrayList<>(); |
61 | 44 | } |
62 | 45 | } |
0 commit comments