Skip to content

Commit

Permalink
Add options to Write strategy for configure the creation of SipId fol…
Browse files Browse the repository at this point in the history
…der inside ZIP
  • Loading branch information
hmiguim committed Nov 15, 2024
1 parent 34bb2c1 commit fee73f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public Path write(Map<String, ZipEntryInfo> entries, SIP sip, String fileNameWit
return dirPath;
}

@Override
public Path write(Map<String, ZipEntryInfo> entries, SIP sip, String fileNameWithoutExtension, String fallbackName,
boolean createSipIdFolder, boolean deleteExisting) throws IPException, InterruptedException {
throw new UnsupportedOperationException("Method not implemented");
}

private void writeToPath(final Map<String, ZipEntryInfo> entries, final Path path, String checksumAlgorithm)
throws IPException, InterruptedException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ public interface WriteStrategy {
Path write(Map<String, ZipEntryInfo> entries, SIP sip, String fileNameWithoutExtension, String fallbackName,
boolean deleteExisting) throws IPException, InterruptedException;

Path write(Map<String, ZipEntryInfo> entries, SIP sip, String fileNameWithoutExtension, String fallbackName,
boolean createSipIdFolder, boolean deleteExisting) throws IPException, InterruptedException;

Path getDestinationPath();
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ public void setup(Path destinationPath) {
@Override
public Path write(Map<String, ZipEntryInfo> entries, SIP sip, String fileNameWithoutExtension, String fallbackName,
boolean deleteExisting) throws IPException, InterruptedException {
return write(entries, sip, fileNameWithoutExtension, fallbackName, true, deleteExisting);
}

@Override
public Path write(Map<String, ZipEntryInfo> entries, SIP sip, String fileNameWithoutExtension, String fallbackName,
boolean createSipIdFolder, boolean deleteExisting) throws IPException, InterruptedException {
Path zipPath = getZipPath(destinationPath, fileNameWithoutExtension, fallbackName);

try {
ZIPUtils.zip(entries, Files.newOutputStream(zipPath), sip, true, true);
ZIPUtils.zip(entries, Files.newOutputStream(zipPath), sip, createSipIdFolder, true);
} catch (ClosedByInterruptException e) {
throw new InterruptedException();
} catch (IOException e) {
Expand Down

0 comments on commit fee73f5

Please sign in to comment.