Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #250 #261

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/java/org/roda_project/commons_ip/model/IP.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public abstract class IP implements IPInterface {
private List<IPFile> documentation;

private Map<String, ZipEntryInfo> zipEntries;
private String checksumAlgorithm;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck> reported by reviewdog 🐶
Missing a Javadoc comment.


private ValidationReport validationReport;

Expand All @@ -61,6 +62,7 @@ public IP() {
this.ancestors = new ArrayList<>();

this.description = "";
this.checksumAlgorithm = "SHA-256";

this.descriptiveMetadata = new ArrayList<>();
this.preservationMetadata = new ArrayList<>();
Expand Down Expand Up @@ -92,6 +94,13 @@ public IP setId(String id) {
this.ids = Arrays.asList(id);
return this;
}
public void setChecksum(final String checksum) {
this.checksumAlgorithm = checksum;
}
public String getChecksum() {
return this.checksumAlgorithm;
}


@Override
public String getId() {
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/roda_project/commons_ip/utils/ZIPUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static void zip(Map<String, ZipEntryInfo> files, OutputStream out, SIP si
}

Set<String> nonMetsChecksumAlgorithms = new TreeSet<>();
nonMetsChecksumAlgorithms.add(IPConstants.CHECKSUM_ALGORITHM);
nonMetsChecksumAlgorithms.add(sip.getChecksum());
Set<String> metsChecksumAlgorithms = new TreeSet<>();
metsChecksumAlgorithms.addAll(nonMetsChecksumAlgorithms);
metsChecksumAlgorithms.addAll(sip.getExtraChecksumAlgorithms());
Expand All @@ -126,6 +126,7 @@ public static void zip(Map<String, ZipEntryInfo> files, OutputStream out, SIP si
throw new InterruptedException();
}

file.setChecksum(sip.getChecksum());
file.prepareEntryforZipping();

LOGGER.debug("Zipping file {}", file.getFilePath());
Expand All @@ -150,8 +151,8 @@ public static void zip(Map<String, ZipEntryInfo> files, OutputStream out, SIP si
}

LOGGER.debug("Done zipping file");
String checksum = checksums.get(IPConstants.CHECKSUM_ALGORITHM);
String checksumType = IPConstants.CHECKSUM_ALGORITHM;
String checksum = checksums.get(sip.getChecksum());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [checkstyle] <com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck> reported by reviewdog 🐶
Variable 'checksum' should be declared final.

String checksumType = sip.getChecksum();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [checkstyle] <com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck> reported by reviewdog 🐶
Variable 'checksumType' should be declared final.

file.setChecksum(checksum);
file.setChecksumAlgorithm(checksumType);
if (file instanceof METSFileTypeZipEntryInfo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void prepareEntryforZipping() throws IPException {
if (!rootMETS && fileType != null) {
METSUtils.setFileBasicInformation(LOGGER, getFilePath(), fileType);

String checksumType = IPConstants.CHECKSUM_ALGORITHM;
String checksumType = this.getChecksum();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [checkstyle] <com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck> reported by reviewdog 🐶
Variable 'checksumType' should be declared final.

Set<String> checksumAlgorithms = new HashSet<>();
checksumAlgorithms.add(checksumType);
try (InputStream inputStream = Files.newInputStream(getFilePath())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ public static void zip(Map<String, ZipEntryInfo> files, OutputStream out, SIP si
throw new InterruptedException();
}

file.setChecksum(sip.getChecksum());
file.prepareEntryforZipping();


LOGGER.debug("Zipping file {}", file.getFilePath());
ZipEntry entry;
if (createSipIdFolder) {
Expand Down
Loading