fcrepo-exts / fcrepo-import-export

Apache License 2.0
15 stars 19 forks source link

Validate bags conform to bag profiles on import #139

Closed mikejritter closed 4 years ago

mikejritter commented 4 years ago

Resolves: https://jira.lyrasis.org/browse/FCREPO-3184


For testing:

  1. Start a clean fedora repository
  2. Create a binary resource in the new repository
  3. Create a bag-config.yml for use during export
    bag-info.txt:
    Source-Organization: fcrepo-import-export
    Organization-Address: localhost
    External-Description: Sample bag export for fcrepo-3208
  4. Run the exporter using the default profile and a directory of fcrepo-3184
    java -jar target/fcrepo-import-export-0.4.0-SNAPSHOT.jar --mode export --resource http://localhost:8080/fcrepo/rest --dir fcrepo-3184 --binaries --bag-profile default --bag-config bag-config.yml --user fedoraAdmin:secret3
  5. Make adjustments to the exported bag so that it will no longer pass profile validation
    [fcrepo-import-export] $ cd fcrepo-3184 
    [fcrepo-3184] $ cp bag-info.txt bag-info.txt.bak
    [fcrepo-3184] $ sed -i '/Source-Organization/d' bag-info.txt
    [fcrepo-3184] $ sha1sum bag-info.txt >> tagmanifest-sha1.txt 
    [fcrepo-3184] $ vim tagmanifest-sha1.txt # remove the old sha1 digest
    [fcrepo-3184] $ sha1sum -c tagmanifest-sha1.txt 
    bag-info.txt: OK
    bagit.txt: OK
  6. Start a fresh fedora repository
  7. Try to import the bag, expecting that the profile validation will fail:
    java -Dfcrepo.log.importexport=DEBUG -jar target/fcrepo-import-export-0.4.0-SNAPSHOT.jar --mode import -r http://localhost:8080/fcrepo/rest --dir fcrepo-3184 --binaries -g default -G bag-config.yml -u fedoraAdmin:secret3
  8. Move the original bag-info.txt back into place
    [fcrepo-import-export] $ cd fcrepo-3184 
    [fcrepo-3184] $ mv bag-info.txt.bak bag-info.txt
    [fcrepo-3184] $ sha1sum bag-info.txt >> tagmanifest-sha1.txt 
    [fcrepo-3184] $ vim tagmanifest-sha1.txt # remove the invalid sha1 digest
  9. Run the import again, this time succeeding
    java -Dfcrepo.log.importexport=DEBUG -jar target/fcrepo-import-export-0.4.0-SNAPSHOT.jar --mode import -r http://localhost:8080/fcrepo/rest --dir fcrepo-3184 --binaries -g default -G bag-config.yml -u fedoraAdmin:secret3