Created
December 4, 2015 21:34
-
-
Save awead/2cde5a2c35a24884c816 to your computer and use it in GitHub Desktop.
Fedora versions
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" | |
echo | |
echo "When was version1 created?" | |
$FURL -s -X GET $FCREPO/sample/content/fcr:versions/ver1/fcr:metadata | grep "hasDateCreatedByApplication" | |
echo "don't know, but if I restore version1" | |
# 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