Skip to content

Instantly share code, notes, and snippets.

@escowles
Last active January 13, 2018 12:48
Show Gist options
  • Save escowles/9e4f6b100c296c2d0c57ff8158028fe3 to your computer and use it in GitHub Desktop.
Save escowles/9e4f6b100c296c2d0c57ff8158028fe3 to your computer and use it in GitHub Desktop.
fcrepo-4.7.4: fixity and versioning

create a data file and calculate checksum

$ head -c 8192 /dev/zero > file1.dat
$ shasum file1.dat

0631457264ff7f8d5fb1edc2c0211992a67c73e6  file1.dat

transmission fixity failure

HTTP/1.1 100 Continue

HTTP/1.1 409 Conflict
Server: Apache-Coyote/1.1
Cache-Control: private
Expires: Thu, 01 Jan 1970 00:00:00 UTC
Content-Type: text/plain;charset=utf-8
Content-Length: 88
Date: Sat, 13 Jan 2018 12:36:11 GMT

Checksum Mismatch of urn:sha1:bad and urn:sha1:0631457264ff7f8d5fb1edc2c0211992a67c73e6

transmission fixity success

$ curl -i -u fedoraAdmin:secret3 -X PUT --data-binary @file1.dat -H "Digest: sha1=0631457264ff7f8d5fb1edc2c0211992a67c73e6" http://localhost:8080/fcrepo/rest/file1

HTTP/1.1 100 Continue

HTTP/1.1 201 Created
Server: Apache-Coyote/1.1
Cache-Control: private
Expires: Thu, 01 Jan 1970 00:00:00 UTC
ETag: "4a2cd452fee08d0b7dabb20c093daf154b822840"
Last-Modified: Sat, 13 Jan 2018 12:36:36 GMT
Link: <http://localhost:8080/fcrepo/rest/file1/fcr:metadata>; rel="describedby"; anchor="http://localhost:8080/fcrepo/rest/file1"
Location: http://localhost:8080/fcrepo/rest/file1
Content-Type: text/plain
Content-Length: 39
Date: Sat, 13 Jan 2018 12:36:36 GMT

http://localhost:8080/fcrepo/rest/file1

persistence fixity success

$ curl -i -u fedoraAdmin:secret3 http://localhost:8080/fcrepo/rest/file1/fcr:fixity

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Cache-Control: private
Expires: Thu, 01 Jan 1970 00:00:00 UTC
Link: <http://www.w3.org/ns/ldp#Resource>; rel="type"
Link: <http://www.w3.org/ns/ldp#RDFSource>; rel="type"
Content-Type: text/turtle;charset=utf-8
Content-Length: 1509
Date: Sat, 13 Jan 2018 12:36:56 GMT

@prefix premis:  <http://www.loc.gov/premis/rdf/v1#> .
@prefix test:  <info:fedora/test/> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsi:  <http://www.w3.org/2001/XMLSchema-instance> .
@prefix xmlns:  <http://www.w3.org/2000/xmlns/> .
@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix fedora:  <http://fedora.info/definitions/v4/repository#> .
@prefix xml:  <http://www.w3.org/XML/1998/namespace> .
@prefix ebucore:  <http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#> .
@prefix ldp:  <http://www.w3.org/ns/ldp#> .
@prefix xs:  <http://www.w3.org/2001/XMLSchema> .
@prefix fedoraconfig:  <http://fedora.info/definitions/v4/config#> .
@prefix foaf:  <http://xmlns.com/foaf/0.1/> .
@prefix authz:  <http://fedora.info/definitions/v4/authorization#> .
@prefix dc:  <http://purl.org/dc/elements/1.1/> .

<http://localhost:8080/fcrepo/rest/file1>
        premis:hasFixity  <http://localhost:8080/fcrepo/rest/file1#fixity/1515847016030> .

<http://localhost:8080/fcrepo/rest/file1#fixity/1515847016030>
        rdf:type                 premis:Fixity ;
        rdf:type                 premis:EventOutcomeDetail ;
        premis:hasEventOutcome   "SUCCESS"^^<http://www.w3.org/2001/XMLSchema#string> ;
        premis:hasMessageDigestAlgorithm  "SHA-1"^^<http://www.w3.org/2001/XMLSchema#string> ;
        premis:hasMessageDigest  <urn:sha1:0631457264ff7f8d5fb1edc2c0211992a67c73e6> ;
        premis:hasSize           "8192"^^<http://www.w3.org/2001/XMLSchema#long> .

extra credit: persistence fixity failure

corrupt the data file

$ vagrant ssh
vagrant$ sudo -s
root$ echo "corruption" > /var/lib/tomcat7/fcrepo4-data/fcrepo.binary.directory/06/31/45/0631457264ff7f8d5fb1edc2c0211992a67c73e6

check fixity again to see the failure

$ curl -i -u fedoraAdmin:secret3 http://localhost:8080/fcrepo/rest/file1/fcr:fixity

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Cache-Control: private
Expires: Thu, 01 Jan 1970 00:00:00 UTC
Link: <http://www.w3.org/ns/ldp#Resource>; rel="type"
Link: <http://www.w3.org/ns/ldp#RDFSource>; rel="type"
Content-Type: text/turtle;charset=utf-8
Content-Length: 1601
Date: Sat, 13 Jan 2018 12:41:15 GMT

@prefix premis:  <http://www.loc.gov/premis/rdf/v1#> .
@prefix test:  <info:fedora/test/> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsi:  <http://www.w3.org/2001/XMLSchema-instance> .
@prefix xmlns:  <http://www.w3.org/2000/xmlns/> .
@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix fedora:  <http://fedora.info/definitions/v4/repository#> .
@prefix xml:  <http://www.w3.org/XML/1998/namespace> .
@prefix ebucore:  <http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#> .
@prefix ldp:  <http://www.w3.org/ns/ldp#> .
@prefix xs:  <http://www.w3.org/2001/XMLSchema> .
@prefix fedoraconfig:  <http://fedora.info/definitions/v4/config#> .
@prefix foaf:  <http://xmlns.com/foaf/0.1/> .
@prefix authz:  <http://fedora.info/definitions/v4/authorization#> .
@prefix dc:  <http://purl.org/dc/elements/1.1/> .

<http://localhost:8080/fcrepo/rest/file1>
        premis:hasFixity  <http://localhost:8080/fcrepo/rest/file1#fixity/1515847275733> .

<http://localhost:8080/fcrepo/rest/file1#fixity/1515847275733>
        rdf:type                 premis:Fixity ;
        rdf:type                 premis:EventOutcomeDetail ;
        premis:hasEventOutcome   "BAD_CHECKSUM"^^<http://www.w3.org/2001/XMLSchema#string> ;
        premis:hasEventOutcome   "BAD_SIZE"^^<http://www.w3.org/2001/XMLSchema#string> ;
        premis:hasMessageDigestAlgorithm  "SHA-1"^^<http://www.w3.org/2001/XMLSchema#string> ;
        premis:hasMessageDigest  <urn:sha1:6a7bb2556144babe3899b25e5428123735bb1e27> ;
        premis:hasSize           "11"^^<http://www.w3.org/2001/XMLSchema#long> .

creating versions

$ curl -i -u fedoraAdmin:secret3 -X POST -H "Slug: v1" http://localhost:8080/fcrepo/rest/file1/fcr:versions

HTTP/1.1 201 Created
Server: Apache-Coyote/1.1
Location: http://localhost:8080/fcrepo/rest/file1/fcr:versions/v1/fcr:metadata
Content-Length: 0
Date: Sat, 13 Jan 2018 12:20:45 GMT

updating content

$ curl -i -u fedoraAdmin:secret3 -X PUT -d "updated stuff" http://localhost:8080/fcrepo/rest/file1

HTTP/1.1 204 No Content
Server: Apache-Coyote/1.1
Cache-Control: private
Expires: Thu, 01 Jan 1970 00:00:00 UTC
ETag: "147e62375f61627e5dcc6c68d25c8e17fd53749b"
Last-Modified: Sat, 13 Jan 2018 12:21:03 GMT
Link: <http://localhost:8080/fcrepo/rest/file1/fcr:metadata>; rel="describedby"
Date: Sat, 13 Jan 2018 12:21:03 GMT

discovering versions

$ curl -i -u fedoraAdmin:secret3 http://localhost:8080/fcrepo/rest/file1/fcr:versions

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Cache-Control: private
Expires: Thu, 01 Jan 1970 00:00:00 UTC
Link: <http://www.w3.org/ns/ldp#Resource>; rel="type"
Link: <http://www.w3.org/ns/ldp#RDFSource>; rel="type"
Content-Type: text/turtle;charset=utf-8
Content-Length: 1224
Date: Sat, 13 Jan 2018 12:21:21 GMT

@prefix premis:  <http://www.loc.gov/premis/rdf/v1#> .
@prefix test:  <info:fedora/test/> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsi:  <http://www.w3.org/2001/XMLSchema-instance> .
@prefix xmlns:  <http://www.w3.org/2000/xmlns/> .
@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix fedora:  <http://fedora.info/definitions/v4/repository#> .
@prefix xml:  <http://www.w3.org/XML/1998/namespace> .
@prefix ebucore:  <http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#> .
@prefix ldp:  <http://www.w3.org/ns/ldp#> .
@prefix xs:  <http://www.w3.org/2001/XMLSchema> .
@prefix fedoraconfig:  <http://fedora.info/definitions/v4/config#> .
@prefix foaf:  <http://xmlns.com/foaf/0.1/> .
@prefix authz:  <http://fedora.info/definitions/v4/authorization#> .
@prefix dc:  <http://purl.org/dc/elements/1.1/> .

<http://localhost:8080/fcrepo/rest/file1>
        fedora:hasVersion  <http://localhost:8080/fcrepo/rest/file1/fcr:versions/v1> .

<http://localhost:8080/fcrepo/rest/file1/fcr:versions/v1>
        fedora:hasVersionLabel  "v1"^^<http://www.w3.org/2001/XMLSchema#string> ;
        fedora:created          "2018-01-13T12:20:44.95Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .

retrieving previous versions

$ curl -i -u fedoraAdmin:secret3 http://localhost:8080/fcrepo/rest/file1/fcr:versions/v1

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Cache-Control: no-transform, must-revalidate, max-age=0
Expires: Thu, 01 Jan 1970 00:00:00 UTC
ETag: "068c0f4e0d350a930bb2ec0ee47f6ecfdff024b8"
Last-Modified: Sat, 13 Jan 2018 12:13:11 GMT
Accept-Ranges: bytes
Content-Disposition: attachment; filename=""; creation-date="Sat, 13 Jan 2018 12:13:11 GMT"; modification-date="Sat, 13 Jan 2018 12:13:11 GMT"; size=5
Link: <http://www.w3.org/ns/ldp#Resource>;rel="type"
Link: <http://www.w3.org/ns/ldp#NonRDFSource>;rel="type"
Link: <http://localhost:8080/fcrepo/rest/file1/fcr:versions/v1/fcr:metadata>; rel="describedby"
ETag: "068c0f4e0d350a930bb2ec0ee47f6ecfdff024b8"
Last-Modified: Sat, 13 Jan 2018 12:13:11 GMT
Content-Type: application/x-www-form-urlencoded
Content-Length: 5
Date: Sat, 13 Jan 2018 12:21:40 GMT

stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment