Created
December 4, 2015 21:29
-
-
Save awead/875c853e50fd131a96a4 to your computer and use it in GitHub Desktop.
Fedora versioning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FCREPO=http://fedoraAdmin:fedoraAdmin@localhost:8983/fedora/rest | |
FURL="curl --user fedoraAdmin:fedoraAdmin" | |
# Clear out existing resources | |
$FURL -X DELETE $FCREPO/sample/ | |
$FURL -X DELETE $FCREPO/sample/fcr:tombstone | |
# Create container | |
$FURL -X PUT -H "Content-Type: text/turtle" $FCREPO/sample/ | |
# Create first version | |
$FURL -X PUT --data-binary "content" $FCREPO/sample/content | |
$FURL -X PATCH -H"Content-type: application/sparql-update" -d "insert { <http://localhost:8983/fedora/rest/sample/content> <http://www.loc.gov/premis/rdf/v1#hasDateCreatedByApplication> '1111-11-11T11:11:11Z' } where {}" $FCREPO/sample/content/fcr:metadata | |
$FURL -X POST -H "Slug: ver1" $FCREPO/sample/content/fcr:versions | |
# Create second version | |
$FURL -X PUT --data-binary "updated content" $FCREPO/sample/content | |
$FURL -X PATCH -H"Content-type: application/sparql-update" -d "DELETE WHERE { ?s <http://www.loc.gov/premis/rdf/v1#hasDateCreatedByApplication> ?o }" $FCREPO/sample/content/fcr:metadata | |
$FURL -X PATCH -H"Content-type: application/sparql-update" -d "insert { <http://localhost:8983/fedora/rest/sample/content> <http://www.loc.gov/premis/rdf/v1#hasDateCreatedByApplication> '2222-22-22T22:22:22Z' } where {}" $FCREPO/sample/content/fcr:metadata | |
$FURL -X POST -H "Slug: ver2" $FCREPO/sample/content/fcr:versions | |
echo | |
echo "With version2...." | |
$FURL -s -X GET $FCREPO/sample/content/fcr:metadata | grep "hasDateCreatedByApplication" | |
# Restore first version | |
$FURL -X PATCH $FCREPO/sample/content/fcr:versions/ver1 | |
echo | |
echo "With restored version1...." | |
$FURL -s -X GET $FCREPO/sample/content/fcr:metadata | grep "hasDateCreatedByApplication" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment