From 56dc4eeeb259871e6306833377cb843969f88a55 Mon Sep 17 00:00:00 2001 From: Jordan Padams Date: Thu, 1 Dec 2022 08:47:34 -0800 Subject: [PATCH 1/2] Skip checksum handling if no checksum check is possible If we know there is no checksum manifest or a checksum in the label, we don't need to handle any checksums. Previous functionality would continue through this method and generate a checksum, significantly slowing down execution (especially for very large files). --- .../tools/validate/rule/pds4/FileReferenceValidationRule.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/gov/nasa/pds/tools/validate/rule/pds4/FileReferenceValidationRule.java b/src/main/java/gov/nasa/pds/tools/validate/rule/pds4/FileReferenceValidationRule.java index 2a67eab94..d7a00c545 100644 --- a/src/main/java/gov/nasa/pds/tools/validate/rule/pds4/FileReferenceValidationRule.java +++ b/src/main/java/gov/nasa/pds/tools/validate/rule/pds4/FileReferenceValidationRule.java @@ -504,6 +504,10 @@ private void handleChecksum(ValidationTarget target, URL urlRef, TinyNodeImpl fi if (checksumManifest.isEmpty() && (checksumInLabel == null || checksumInLabel.isEmpty())) { String message = "No checksum found in the manifest for '" + urlRef + "'"; LOG.debug("handleChecksum:" + message); + + // If there is no checksumManifest and no checksum in the label, we don't need to do anything + // with a checksum for this urlRef + return; } String generatedChecksum = MD5Checksum.getMD5Checksum(urlRef); From f51e856f8199e7e17340e8e183dfc600e50ef1ec Mon Sep 17 00:00:00 2001 From: al-niessner <1130658+al-niessner@users.noreply.github.com> Date: Thu, 1 Dec 2022 10:26:43 -0800 Subject: [PATCH 2/2] Update FileReferenceValidationRule.java conditional matches statement in message --- .../tools/validate/rule/pds4/FileReferenceValidationRule.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/gov/nasa/pds/tools/validate/rule/pds4/FileReferenceValidationRule.java b/src/main/java/gov/nasa/pds/tools/validate/rule/pds4/FileReferenceValidationRule.java index d7a00c545..a5cda8ef0 100644 --- a/src/main/java/gov/nasa/pds/tools/validate/rule/pds4/FileReferenceValidationRule.java +++ b/src/main/java/gov/nasa/pds/tools/validate/rule/pds4/FileReferenceValidationRule.java @@ -501,8 +501,8 @@ private void handleChecksum(ValidationTarget target, URL urlRef, TinyNodeImpl fi String checksumInLabel) throws Exception { LOG.debug("handleChecksum:target,urlRef,checksumInLabel {},{},{}", target, urlRef, checksumInLabel); - if (checksumManifest.isEmpty() && (checksumInLabel == null || checksumInLabel.isEmpty())) { - String message = "No checksum found in the manifest for '" + urlRef + "'"; + if (!checksumManifest.containsKey(urlRef) && (checksumInLabel == null || checksumInLabel.isEmpty())) { + String message = "No checksum found in the manifest for '" + urlRef + "' and not checksum label in product"; LOG.debug("handleChecksum:" + message); // If there is no checksumManifest and no checksum in the label, we don't need to do anything