fcrepo-exts / fcrepo-import-export

Apache License 2.0
15 stars 19 forks source link

Aligns external content handling in importer with the Fedora API Spec… #130

Closed dbernstein closed 5 years ago

dbernstein commented 5 years ago

… 1.0.

Resolves: https://jira.duraspace.org/browse/FCREPO-3017


With this PR, 5.x round-tripping of external content now works. I've created two new integration tests that cover both "redirect" and "proxy" handling methods for external content.

To test this manually:

  1. Start up a clean repo
  2. create a resource that references external content using the redirect method.
    
    curl -X PUT -u fedoraAdmin:fedoraAdmin http://localhost:8080/rest/redirect  -H "Link: <https://www.lyrasis.org/SiteAssets/lyrasis.png>; rel=\"http://fedora.info/definitions/fcrepo#ExternalContent\"; handling=\"redirect\"; type=\"image/png\""

curl -u fedoraAdmin:fedoraAdmin http://localhost:8080/rest/redirect -i curl -u fedoraAdmin:fedoraAdmin http://localhost:8080/rest/redirect/fcr:metadata -i

3. create a resource that references local external content using the proxy method.

create text file at /path/to/local/file/test.txt first

echo "test" > /tmp/test.txt

curl -X PUT -u fedoraAdmin:fedoraAdmin http://localhost:8080/rest/proxy-local -H "Link: <file:/tmp/test.txt>; rel=\"http://fedora.info/definitions/fcrepo#ExternalContent\"; handling=\"proxy\"; type=\"text/plain\"" -i

curl -u fedoraAdmin:fedoraAdmin http://localhost:8080/rest/proxy-local -i curl -u fedoraAdmin:fedoraAdmin http://localhost:8080/rest/proxy-local/fcr:metadata -i

4. create a resource that references remote external content using the proxy method.

curl -X PUT -u fedoraAdmin:fedoraAdmin http://localhost:8080/rest/proxy-remote -H "Link: https://www.lyrasis.org/SiteAssets/lyrasis.png; rel=\"http://fedora.info/definitions/fcrepo#ExternalContent\"; handling=\"proxy\"; type=\"image/png\"" -i

curl -u fedoraAdmin:fedoraAdmin http://localhost:8080/rest/proxy-remote -i curl -u fedoraAdmin:fedoraAdmin http://localhost:8080/rest/proxy-remote/fcr:metadata -i

5. do an export

java -jar ~/code/fcrepo-import-export/target/fcrepo-import-export-0.4.0-SNAPSHOT.jar --mode export --predicates "http://www.w3.org/ns/ldp#contains" --resource "http://localhost:8080/rest" --versions --binaries --rdfLang "text/turtle" --dir export-dir -u fedoraAdmin:fedoraAdmin

6. start a fresh repo
7. do an import

java -jar ~/code/fcrepo-import-export/target/fcrepo-import-export-0.4.0-SNAPSHOT.jar --mode import --predicates "http://www.w3.org/ns/ldp#contains" --resource "http://localhost:8080/rest" --versions --binaries --rdfLang "text/turtle" --dir export-dir -u fedoraAdmin:fedoraAdmin

8. verify that both resources are returning the same headers and bodies.

curl -u fedoraAdmin:fedoraAdmin http://localhost:8080/rest/redirect -i curl -u fedoraAdmin:fedoraAdmin http://localhost:8080/rest/redirect/fcr:metadata -i

curl -u fedoraAdmin:fedoraAdmin http://localhost:8080/rest/proxy-local -i curl -u fedoraAdmin:fedoraAdmin http://localhost:8080/rest/proxy-local/fcr:metadata -i

curl -u fedoraAdmin:fedoraAdmin http://localhost:8080/rest/proxy-remote -i curl -u fedoraAdmin:fedoraAdmin http://localhost:8080/rest/proxy-remote/fcr:metadata -i