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

Missing referential integrity checks from browse products to others i… #440

Merged
merged 2 commits into from
Nov 12, 2021

Conversation

qchaupds
Copy link
Contributor

@qchaupds qchaupds commented Nov 9, 2021

…n the bundle

  1. Add test resources : src/test/resources/github432
  2. Add debug statements : src/main/java/gov/nasa/pds/tools/util/ReferentialIntegrityUtil.java
  3. Modify uppercase 'ERROR' to lowercase 'error' so as not to confuse the log file : src/main/java/gov/nasa/pds/tools/validate/rule/pds4/LabelValidationRule.java
  4. Add debug statements and printing of warning message when the exceptions.get(location) call returns null : src/main/java/gov/nasa/pds/validate/ValidateLauncher.java
  5. Add debug statements and checking for null-ness before calling toString() to avoid NullPointerException : src/main/java/gov/nasa/pds/validate/report/Report.java

Refs:

#432 Missing referential integrity checks from browse products to others in the bundle

Closes #432 Missing referential integrity checks from browse products to others in the bundle

It is important to use the rule "-R pds4.bundle" when validating a bundle. The rule gives guidance of what things are being required to run, including referential checks.
If the correct rule is not being used, only label or directory rules are applied based on the name of the target.

Note that the checking is done for references within a bundle only. As Jordan had indicated, this is another ticket to check for references outside of the bundle beyond the scope of this ticket.

Tested in DEV:

Test 1: Specify rule "-R pds4.bundle"
There should be 3 WARN messages:

% validate -R pds4.bundle -r report_github432_valid_via_rule_bundle.json   -s json -t  src/test/resources/github432/val308b/bundle-voyager1-pls-sat-1.0.xml  >& t1
% grep "Using " t1
t1:[main] INFO gov.nasa.pds.tools.label.LocationValidator - Using validation style 'PDS4 Bundle' for location file:/home/qchau/sandbox/validate/src/test/resources/github432/val308b/bundle-voyager1-pls-sat-1.0.xml


      "messages": [
          "message": "This file should reference 'urn:nasa:pds:vg1-pls-sat:data-ion-moments-96sec:nonexistentxxx' because its child product with LIDVID urn:nasa:pds:vg1-pls-sat:browse-ion-moments:ion-mom::1.0 references it."
          "message": "This file should reference 'urn:nasa:pds:mess-mag-kt17-model-residuals:document:xxxnoexistent' because its child product with LIDVID urn:nasa:pds:vg1-pls-sat:data-ion-moments-96sec:ion-mom::1.0 references it."
          "message": "This file should reference 'urn:nasa:pds:vg1-pls-sat:browse-ion-moments:ion-mom' because its child product with LIDVID urn:nasa:pds:vg1-pls-sat:data-ion-moments-96sec:ion-mom::1.0 references it."

Test 2: Specify rule "-R pds4.label" when validating bundle-voyager1-pls-sat-1.0.xml as a label.
There should be no warning messages.

% validate -R pds4.label -r report_github432_valid_via_rule_label.json   -s json -t  src/test/resources/github432/val308b/bundle-voyager1-pls-sat-1.0.xml  >& t2
% grep "Using " t2
t2:[main] INFO gov.nasa.pds.tools.label.LocationValidator - Using validation style 'PDS4 Label' for location file:/home/qchau/sandbox/validate/src/test/resources/github432/val308b/bundle-voyager1-pls-sat-1.0.xml

Test 3: Specify no rule. The default rule used by validate will be "PDS4 Directory"
There should be no warning messages.

% validate -r report_github432_valid_via_rule_directory.json   -s json -t  src/test/resources/github432/val308b  >& t3
% grep "Using " t3
t3:[main] INFO gov.nasa.pds.tools.label.LocationValidator - Using validation style 'PDS4 Directory' for location file:/home/qchau/sandbox/validate/src/test/resources/github432/val308b/

…n the bundle

1. Add test resources : src/test/resources/github432
2. Add debug statements : src/main/java/gov/nasa/pds/tools/util/ReferentialIntegrityUtil.java
3. Modify uppercase 'ERROR' to lowercase 'error' so as not to confuse the log file : src/main/java/gov/nasa/pds/tools/validate/rule/pds4/LabelValidationRule.java
4. Add debug statements and printing of warning message when the exceptions.get(location) call returns null : src/main/java/gov/nasa/pds/validate/ValidateLauncher.java
5. Add debug statements and checking for null-ness before calling toString() to avoid NullPointerException : src/main/java/gov/nasa/pds/validate/report/Report.java

Refs:

#432 Missing referential integrity checks from browse products to others in the bundle
@qchaupds qchaupds requested a review from a team as a code owner November 9, 2021 16:48
Copy link
Member

@jordanpadams jordanpadams left a comment

Choose a reason for hiding this comment

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

@qchaupds this unfortunately does not fix the issue identified here: #308 (comment)

This reference:

    <Reference_List>
        <Internal_Reference>
            <lid_reference>urn:nasa:pds:vg1-pls-sat:data-ion-moments-96sec:nonexistentxxx</lid_reference>  <!-- val308 should catch this -->
            <reference_type>browse_to_data</reference_type>
        </Internal_Reference>
    </Reference_List>

Per your #308 and PR #347, this should raise a warning.integrity.unreferenced_member error because the product urn:nasa:pds:vg1-pls-sat:data-ion-moments-96sec:nonexistentxxx is not a part of the urn:nasa:pds:vg1-pls-sat:data-ion-moments-96sec collection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants