Repository navigation
Notes on using the Fedora API
Reference: https://wiki.lyrasis.org/display/FEDORA6x/RESTful+HTTP+API+-+Containers
Auto versioning = False
curl -i -u fedoraAdmin:fedoraAdmin -X POST "http://localhost:8080/fcrepo/rest/"
-
Container id : Creates A new container with a random time based id (memento?). It returns http status code 201 and the id in the location header
HTTP/1.1 201
Location: http://localhost:8080/fcrepo/rest/336b2af3-bdc5-416a-bf37-d3842fab792a -
OCFL store : The OCFL object id is the sha 256 of the above id
$ echo -n "info:fedora/336b2af3-bdc5-416a-bf37-d3842fab792a" | sha256sum4635bd63b7c075bcf1a5c685fbe0a2dac3eefd940be84e20062ceff6924c0d2d
# tree structure # tree -a 463/ 463/ └── 5bd └── 63b └── 4635bd63b7c075bcf1a5c685fbe0a2dac3eefd940be84e20062ceff6924c0d2d ├── 0=ocfl_object_1.0 ├── extensions │ └── 0005-mutable-head │ ├── head │ │ ├── content │ │ │ └── r1 │ │ │ ├── fcr-container.nt │ │ │ └── .fcrepo │ │ │ └── fcr-root.json │ │ ├── inventory.json │ │ └── inventory.json.sha512 │ ├── revisions │ │ └── r1 │ └── root-inventory.json.sha512 ├── inventory.json ├── inventory.json.sha512 └── v1 ├── inventory.json └── inventory.json.sha512 11 directories, 11 files -
Notes : We are seeing revisions used in the data structure, as auto versioning is set to false.
curl -i -u fedoraAdmin:fedoraAdmin -X POST -H "Slug: my-archival-group" -H "Link: <http://fedora.info/definitions/v4/repository#ArchivalGroup>;rel=\"type\"" http://localhost:8080/fcrepo/rest
-
Creates a new container with a deterministic name (sha 256 of info:feodra/my-archival-group)
echo -n "info:fedora/my-archival-group" | sha256sum 502bb2403dfb33624cf5b3cbf8e200fff81237fad89f0734b331ea35bd6a08c5 - -
Container id : http://localhost:8080/fcrepo/rest/my-archival-group
-
OCFL store : The directory starting with "502"
# tree -a 502/ 502/ └── bb2 └── 403 └── 502bb2403dfb33624cf5b3cbf8e200fff81237fad89f0734b331ea35bd6a08c5 ├── 0=ocfl_object_1.0 ├── extensions │ └── 0005-mutable-head │ ├── head │ │ ├── content │ │ │ └── r1 │ │ │ ├── fcr-container.nt │ │ │ └── .fcrepo │ │ │ └── fcr-root.json │ │ ├── inventory.json │ │ └── inventory.json.sha512 │ ├── revisions │ │ └── r1 │ └── root-inventory.json.sha512 ├── inventory.json ├── inventory.json.sha512 └── v1 ├── inventory.json └── inventory.json.sha512 11 directories, 11 files -
Notes : Seeing revisions as above. No changes to the other containers (looking at timestamps)
curl -i -u fedoraAdmin:fedoraAdmin -X POST -H "Slug:parent" "http://localhost:8080/fcrepo/rest/"
-
Creates a new "parent"
-
Container id : http://localhost:8080/fcrepo/rest/parent
-
OCFL store: :
$ echo -n "info:fedora/parent" | sha256sum 08e6daa2abafd21a180ee802725d17db2ba1310883d3803bc70c6cdabeab00ab - # tree -a 08e 08e └── 6da └── a2a └── 08e6daa2abafd21a180ee802725d17db2ba1310883d3803bc70c6cdabeab00ab ├── 0=ocfl_object_1.0 ├── extensions │ └── 0005-mutable-head │ ├── head │ │ ├── content │ │ │ └── r1 │ │ │ ├── fcr-container.nt │ │ │ └── .fcrepo │ │ │ └── fcr-root.json │ │ ├── inventory.json │ │ └── inventory.json.sha512 │ ├── revisions │ │ └── r1 │ └── root-inventory.json.sha512 ├── inventory.json ├── inventory.json.sha512 └── v1 ├── inventory.json └── inventory.json.sha512 11 directories, 11 files -
Notes : Created a container with the correct path of "parent". This name is given in the "slug" header as explained in https://wiki.lyrasis.org/display/FEDORA6x/RESTful+HTTP+API+-+Containers#RESTfulHTTPAPIContainers-BluePOSTCreatenewresourceswithinaLDPcontainer
- Note that apparently the slug header can be ignored (e.g. if duplicate?)
-
Now we have a container to upload a file to (example 4).
- Notes : Not our use case.
curl -i -u fedoraAdmin:fedoraAdmin -X POST --data-binary "@/home/nraja/Pictures/Zoom.logo_-696x464.jpg" -H"digest: sha=1c2a111bbe7d77bc4eb7ea571a8354486bdefcd2" "http://localhost:8080/fcrepo/rest/parent"
-
Container id : http://localhost:8080/fcrepo/rest/parent/e3cd7428-b0c1-4475-a055-9ec809743ae0
-
OCFL store :
$ echo -n "info:fedora/parent/e3cd7428-b0c1-4475-a055-9ec809743ae0" | sha256sum 16e0c7b16ec77e24ebe49d0dbf6d728d154b5635ce26a10c6025d8aa15a0a329 - # tree -a 16e/ 16e/ └── 0c7 └── b16 └── 16e0c7b16ec77e24ebe49d0dbf6d728d154b5635ce26a10c6025d8aa15a0a329 ├── 0=ocfl_object_1.0 ├── extensions │ └── 0005-mutable-head │ ├── head │ │ ├── content │ │ │ └── r1 │ │ │ ├── e3cd7428-b0c1-4475-a055-9ec809743ae0 │ │ │ ├── e3cd7428-b0c1-4475-a055-9ec809743ae0~fcr-desc.nt │ │ │ └── .fcrepo │ │ │ ├── fcr-root~fcr-desc.json │ │ │ └── fcr-root.json │ │ ├── inventory.json │ │ └── inventory.json.sha512 │ ├── revisions │ │ └── r1 │ └── root-inventory.json.sha512 ├── inventory.json ├── inventory.json.sha512 └── v1 ├── inventory.json └── inventory.json.sha512 11 directories, 13 files -
Notes : File successfully uploaded. However, file not saved under its own name, but some other long string.
curl -i -u fedoraAdmin:fedoraAdmin -X POST --data-binary "@/home/nraja/Pictures/Zoom.logo_-696x464.jpg" -H"digest: sha=1c2a111bbe7d77bc4eb7ea571a8354486bdefcd2, sha-256=5eaa38347588bb8fb074526863850f31353fcd8dee4e352aa704129954bea3f1" "http://localhost:8080/fcrepo/rest/parent"
-
Container id : http://localhost:8080/fcrepo/rest/parent/63e55bc3-7af8-4f57-b723-d5289a23a9a3
-
OCFL store :
$ echo -n "info:fedora/parent/63e55bc3-7af8-4f57-b723-d5289a23a9a3" | sha256sum bac9993fd85d9268e847e4cc8e2909ffec146b769682094fd8ca8fcd31c283f7 - # tree -a bac bac └── 999 └── 3fd └── bac9993fd85d9268e847e4cc8e2909ffec146b769682094fd8ca8fcd31c283f7 ├── 0=ocfl_object_1.0 ├── extensions │ └── 0005-mutable-head │ ├── head │ │ ├── content │ │ │ └── r1 │ │ │ ├── 63e55bc3-7af8-4f57-b723-d5289a23a9a3 │ │ │ ├── 63e55bc3-7af8-4f57-b723-d5289a23a9a3~fcr-desc.nt │ │ │ └── .fcrepo │ │ │ ├── fcr-root~fcr-desc.json │ │ │ └── fcr-root.json │ │ ├── inventory.json │ │ └── inventory.json.sha512 │ ├── revisions │ │ └── r1 │ └── root-inventory.json.sha512 ├── inventory.json ├── inventory.json.sha512 └── v1 ├── inventory.json └── inventory.json.sha512 11 directories, 13 files -
Notes : The sha information is stored under the .fcrepo/fcr-root.json file above.
curl -i -u fedoraAdmin:fedoraAdmin -X POST --data-binary "@/home/nraja/Pictures/Zoom.logo_-696x464.jpg" -H "Content-Disposition: attachment; filename=\"picture.jpg\"" "http://localhost:8080/fcrepo/rest/parent"
-
Container id : http://localhost:8080/fcrepo/rest/parent/8203bae8-3e9e-4925-9a1d-782ffd685a93
-
OCFL store :
$ echo -n "info:fedora/parent/8203bae8-3e9e-4925-9a1d-782ffd685a93" | sha256sum ae6f669de41514afb9a2dea1c8eabf010f929d54e302c5849a674a41ca09de05 - # tree -a ae6/ ae6/ └── f66 └── 9de └── ae6f669de41514afb9a2dea1c8eabf010f929d54e302c5849a674a41ca09de05 ├── 0=ocfl_object_1.0 ├── extensions │ └── 0005-mutable-head │ ├── head │ │ ├── content │ │ │ └── r1 │ │ │ ├── 8203bae8-3e9e-4925-9a1d-782ffd685a93 │ │ │ ├── 8203bae8-3e9e-4925-9a1d-782ffd685a93~fcr-desc.nt │ │ │ └── .fcrepo │ │ │ ├── fcr-root~fcr-desc.json │ │ │ └── fcr-root.json │ │ ├── inventory.json │ │ └── inventory.json.sha512 │ ├── revisions │ │ └── r1 │ └── root-inventory.json.sha512 ├── inventory.json ├── inventory.json.sha512 └── v1 ├── inventory.json └── inventory.json.sha512 11 directories, 13 files -
Notes : The filename "picture.jpg" is again stored in .fcrepo/fcr-root.json
- Notes : Not in current use case
- Notes : Not in current use case
curl -i -u fedoraAdmin:fedoraAdmin -X PUT "http://localhost:8080/fcrepo/rest/parent"
-
Container id : Nothing new. The parent container in Example 2 was updated (204 was returned)
-
OCFL store : NULL
-
Notes : The curl command and its output are below. No change to the OCFL object store.
$ curl -i -u fedoraAdmin:fedoraAdmin -X PUT "http://localhost:8080/fcrepo/rest/parent" HTTP/1.1 204 Cache-Control: private Set-Cookie: JSESSIONID=916AAFFA0BAF6C3C2592797F00179F37; Path=/fcrepo; HttpOnly Set-Cookie: rememberMe=deleteMe; Path=/fcrepo; Max-Age=0; Expires=Mon, 21-Nov-2022 23:29:29 GMT; SameSite=lax ETag: W/"2ED9204542E4ED76BE01E700D50E8689" X-State-Token: 63E347690AA0786C2DA68C64EC1BAF01 Last-Modified: Tue, 22 Nov 2022 23:29:29 GMT Link: <http://localhost:8080/fcrepo/rest/parent>; rel="timegate" Link: <http://localhost:8080/fcrepo/rest/parent>; rel="original" Link: <http://localhost:8080/fcrepo/rest/parent/fcr:versions>; rel="timemap" Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel="type" Link: <http://www.w3.org/ns/ldp#Resource>; rel="type" Link: <http://fedora.info/definitions/v4/repository#Resource>; rel="type" Link: <http://mementoweb.org/ns#OriginalResource>; rel="type" Link: <http://mementoweb.org/ns#TimeGate>; rel="type" Link: <http://www.w3.org/ns/ldp#RDFSource>; rel="type" Link: <http://www.w3.org/ns/ldp#Container>; rel="type" Link: <http://fedora.info/definitions/v4/repository#Container>; rel="type" Link: <http://localhost:8080/fcrepo/rest/parent/fcr:acl>; rel="acl" Date: Tue, 22 Nov 2022 23:29:29 GMT
curl -i -u fedoraAdmin:fedoraAdmin -X PUT --upload-file /home/nraja/Pictures/Zoom.logo_-696x464.jpg -H"Content-Type: image/jpeg" -H"digest: sha=1c2a111bbe7d77bc4eb7ea571a8354486bdefcd2" "http://localhost:8080/fcrepo/rest/parent/image"
-
Container id : http://localhost:8080/fcrepo/rest/parent/image
-
OCFL store :
$ echo -n "info:fedora/parent/image" | sha256sum c4e2f838e4fe09eeb26fa86f8b5b794783a644998cd3798f34dc78fa807ecd7a - # tree -a c4e/ c4e/ └── 2f8 └── 38e └── c4e2f838e4fe09eeb26fa86f8b5b794783a644998cd3798f34dc78fa807ecd7a ├── 0=ocfl_object_1.0 ├── extensions │ └── 0005-mutable-head │ ├── head │ │ ├── content │ │ │ └── r1 │ │ │ ├── .fcrepo │ │ │ │ ├── fcr-root~fcr-desc.json │ │ │ │ └── fcr-root.json │ │ │ ├── image │ │ │ └── image~fcr-desc.nt │ │ ├── inventory.json │ │ └── inventory.json.sha512 │ ├── revisions │ │ └── r1 │ └── root-inventory.json.sha512 ├── inventory.json ├── inventory.json.sha512 └── v1 ├── inventory.json └── inventory.json.sha512 11 directories, 13 files -
Notes : The file is stored under the name "image" in the revision r1 above
- Notes : Not in current use case
curl -i -u fedoraAdmin:fedoraAdmin -X PATCH -H "Content-Type: application/sparql-update" --data-binary "@body.rdf" "http://localhost:8080/fcrepo/rest/parent/image"
-
Container id :
-
OCFL store :
-
Notes : On first attempt
Warning: Couldn't read data from file "body.rdf", this makes an empty POST. HTTP/1.1 404 Cache-Control: private Set-Cookie: JSESSIONID=2648EB502D480EF7F4D497E915129A9A; Path=/fcrepo; HttpOnly Set-Cookie: rememberMe=deleteMe; Path=/fcrepo; Max-Age=0; Expires=Mon, 21-Nov-2022 23:37:28 GMT; SameSite=lax Content-Type: text/plain Content-Length: 41 Date: Tue, 22 Nov 2022 23:37:28 GMT Error: Resource /parent/image not foundOn second attempt
Warning: Couldn't read data from file "body.rdf", this makes an empty POST. HTTP/1.1 400 Cache-Control: private Set-Cookie: JSESSIONID=D84E7B520681C5505044E22AAC486882; Path=/fcrepo; HttpOnly Set-Cookie: rememberMe=deleteMe; Path=/fcrepo; Max-Age=0; Expires=Mon, 21-Nov-2022 23:39:19 GMT; SameSite=lax Content-Type: text/plain;charset=utf-8 Content-Length: 54 Date: Tue, 22 Nov 2022 23:39:19 GMT Connection: close /parent/image is not a valid object to receive a PATCHEven after creating a valid body.rdf with the content below, I get the same error message
$ cat body.rdf PREFIX dc: <http://purl.org/dc/elements/1.1/> INSERT { <> dc:title "some-resource-title" . } WHERE { } [nraja@heplnlabc dps]$ [nraja@heplnlabc dps]$ curl -i -u fedoraAdmin:fedoraAdmin -X PATCH -H "Content-Type: application/sparql-update" --data-binary "@body.rdf" "http://localhost:8080/fcrepo/rest/parent/image" HTTP/1.1 400 Cache-Control: private Set-Cookie: JSESSIONID=657A07201A39E46B6DCC96A9210F1495; Path=/fcrepo; HttpOnly Set-Cookie: rememberMe=deleteMe; Path=/fcrepo; Max-Age=0; Expires=Mon, 21-Nov-2022 23:45:19 GMT; SameSite=lax Content-Type: text/plain;charset=utf-8 Content-Length: 54 Date: Tue, 22 Nov 2022 23:45:19 GMT Connection: close /parent/image is not a valid object to receive a PATCH
curl -i -u fedoraAdmin:fedoraAdmin -X DELETE "http://localhost:8080/fcrepo/rest/parent"
-
Container id : None
-
OCFL store : None?
-
Notes :
HTTP/1.1 204 Cache-Control: private Set-Cookie: JSESSIONID=8D1FDEA47CB8F366C41DA44AAA0992D7; Path=/fcrepo; HttpOnly Set-Cookie: rememberMe=deleteMe; Path=/fcrepo; Max-Age=0; Expires=Mon, 21-Nov-2022 23:45:57 GMT; SameSite=lax Date: Tue, 22 Nov 2022 23:45:57 GMTOn deleting it again, we get the following (shows the tombstone explicitly this time!)
Cache-Control: private Set-Cookie: JSESSIONID=F6B96BCAB591021A94E19482F9133234; Path=/fcrepo; HttpOnly Set-Cookie: rememberMe=deleteMe; Path=/fcrepo; Max-Age=0; Expires=Mon, 21-Nov-2022 23:46:43 GMT; SameSite=lax Link: <http://localhost:8080/fcrepo/rest/parent/fcr:tombstone>; rel="hasTombstone" Content-Type: text/plain Content-Length: 82 Date: Tue, 22 Nov 2022 23:46:43 GMT Discovered tombstone resource at /parent, departed at: 2022-11-22T23:45:57.774456ZAnd the parent tree now looks like
# tree -a 08e/ 08e/ └── 6da └── a2a └── 08e6daa2abafd21a180ee802725d17db2ba1310883d3803bc70c6cdabeab00ab ├── 0=ocfl_object_1.0 ├── extensions ├── inventory.json ├── inventory.json.sha512 ├── v1 │ ├── inventory.json │ └── inventory.json.sha512 └── v2 ├── content │ ├── r2 │ └── r3 │ └── .fcrepo │ └── fcr-root.json ├── inventory.json └── inventory.json.sha512 10 directories, 8 files
curl -X GET ``"http://localhost:8080/rest/some/deleted/resource"
-
Container id : None
-
OCFL store : None
-
Notes : This resource does not exist anyway. So, get an appropriate message
<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/9.0.65</h3></body></html>
curl -i -u fedoraAdmin:fedoraAdmin -X DELETE "http://localhost:8080/fcrepo/rest/parent/fcr:tombstone"
-
Notes : This really deletes the resource. We now get the following information from curl
HTTP/1.1 204 Cache-Control: private Set-Cookie: JSESSIONID=2F1B7C4E794AA049844B78377FB8D304; Path=/fcrepo; HttpOnly Set-Cookie: rememberMe=deleteMe; Path=/fcrepo; Max-Age=0; Expires=Mon, 21-Nov-2022 23:53:52 GMT; SameSite=lax Date: Tue, 22 Nov 2022 23:53:52 GMTAnd when we look at OCFL, the resource has been removed
# tree -a 08e/ 08e/ [error opening dir] 0 directories, 0 files # ls -l total 92 -rw-r----- 1 root root 11540 Nov 21 21:14 0004-hashed-n-tuple-storage-layout.md -rw-r----- 1 root root 9 Nov 21 21:14 '0=ocfl_1.0' drwxr-x--- 1 root root 6 Nov 21 21:14 141 drwxr-x--- 1 root root 6 Nov 21 21:15 463 drwxr-x--- 1 root root 6 Nov 22 22:46 502 drwxr-x--- 1 root root 68 Nov 21 21:14 extensions -rw-r----- 1 root root 61244 Nov 21 21:14 ocfl_1.0.txt -rw-r----- 1 root root 10148 Nov 21 21:14 ocfl_extensions_1.0.md -rw-r----- 1 root root 273 Nov 21 21:14 ocfl_layout.jsonIn fact, all the resources under "parent" have gone. Only the archival node (502) and the original child node (463) remain.
At this point, the URL "http://localhost:8080/fcrepo/rest/parent" returns "Error: Resource /parent not found"
curl -i -u fedoraAdmin:fedoraAdmin -X HEAD "http://localhost:8080/fcrepo/rest/parent"
-
Container id :
-
OCFL store :
-
Notes :
$ curl -i -u fedoraAdmin:fedoraAdmin -X HEAD "http://localhost:8080/fcrepo/rest/parent" Warning: Setting custom HTTP method to HEAD with -X/--request may not work the Warning: way you want. Consider using -I/--head instead. HTTP/1.1 404 Cache-Control: private Set-Cookie: JSESSIONID=8BC85486F56D39FC3877CD11B28C9A6C; Path=/fcrepo; HttpOnly Set-Cookie: rememberMe=deleteMe; Path=/fcrepo; Max-Age=0; Expires=Mon, 21-Nov-2022 23:55:34 GMT; SameSite=lax Content-Type: text/turtle;charset=utf-8 Content-Length: 33 Date: Tue, 22 Nov 2022 23:55:34 GMT curl: (18) transfer closed with 33 bytes remaining to readAs suggested by curl if we use "-I" instead of "-X HEAD", the errors above go away.
$ curl -i -u fedoraAdmin:fedoraAdmin -I "http://localhost:8080/fcrepo/rest/parent" HTTP/1.1 404 Cache-Control: private Set-Cookie: JSESSIONID=553F413D761182644D7331B19A6E2BE0; Path=/fcrepo; HttpOnly Set-Cookie: rememberMe=deleteMe; Path=/fcrepo; Max-Age=0; Expires=Mon, 21-Nov-2022 23:57:14 GMT; SameSite=lax Content-Type: text/turtle;charset=utf-8 Content-Length: 33 Date: Tue, 22 Nov 2022 23:57:14 GMT