Skip to content

Instantly share code, notes, and snippets.

@awoods
Created November 4, 2020 18:40
Show Gist options
  • Save awoods/59eccb055821582176dfb10c5d0be027 to your computer and use it in GitHub Desktop.
Save awoods/59eccb055821582176dfb10c5d0be027 to your computer and use it in GitHub Desktop.
Creating test containers
#!/usr/bin/bash
###
# Create Direct and Indirect containers
###
echo -e '@prefix pcdm: <http://pcdm.org/models#>\n\n<> a pcdm:Object .' | curl http://localhost:8080/rest/objects -v -H "Content-Type: text/turtle" -X PUT --data-binary @-
echo -e '@prefix pcdm: <http://pcdm.org/models#>\n\n<> a pcdm:Object .' | curl http://localhost:8080/rest/objects/raven -v -H "Content-Type: text/turtle" -X PUT --data-binary @-
echo -e '@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n@prefix ldp: <http://www.w3.org/ns/ldp#>\n@prefix pcdm: <http://pcdm.org/models#>\n\n<> a pcdm:Object ;\nrdf:type <http://www.w3.org/ns/ldp#DirectContainer>;\n
ldp:membershipResource </rest/objects/raven/> ;\nldp:hasMemberRelation pcdm:hasMember .' | curl http://localhost:8080/rest/objects/raven/pages -v -H'Link: <http://www.w3.org/ns/ldp#DirectContainer>;rel="type"' -H "Content-Type: text/turtle" -X PUT --data-binary @-
echo -e '@prefix pcdm: <http://pcdm.org/models#>\n\n<> a pcdm:Object .' | curl http://localhost:8080/rest/objects/raven/pages/cover -v -H "Content-Type: text/turtle" -X PUT --data-binary @-
echo -e '@prefix pcdm: <http://pcdm.org/models#>\n\n<> a pcdm:Object .' | curl http://localhost:8080/rest/objects/raven/pages/page0 -v -H "Content-Type: text/turtle" -X PUT --data-binary @-
echo -e '@prefix pcdm: <http://pcdm.org/models#>\n\n<> a pcdm:Object .' | curl http://localhost:8080/rest/objects/raven/pages/page1 -v -H "Content-Type: text/turtle" -X PUT --data-binary @-
echo -e '@prefix ldp: <http://www.w3.org/ns/ldp#>\n@prefix pcdm: <http://pcdm.org/models#>\n\n<> a pcdm:Object ;\nldp:membershipResource </rest/objects/raven/pages/cover> ;\nldp:hasMemberRelation pcdm:hasFile .' | curl http://localhost:8080/rest/objects/raven/pages/cover/files -v -H'Link: <http://www.w3.org/ns/ldp#DirectContainer>;rel="type"' -H "Content-Type: text/turtle" -X PUT --data-binary @-
curl http://localhost:8080/rest/objects/raven/pages/cover/files/cover.txt -H "Link: <http://www.w3.org/ns/ldp#NonRDFSource>; rel=type" -v -H "Content-Type: text/plain" -X PUT --data-binary "This is a cover"
echo -e 'PREFIX pcdm: <http://pcdm.org/models#>\nINSERT {\n <> a pcdm:File\n} WHERE {\n}' | curl -i -XPATCH -H"Content-Type: application/sparql-update" http://localhost:8080/rest/objects/raven/pages/cover/files/cover.txt/fcr:metadata --data-binary @-
echo -e '@prefix pcdm: <http://pcdm.org/models#>\n\n<> a pcdm:Object .' | curl -i -XPUT -H"Content-Type: text/turtle" http://localhost:8080/rest/collections --data-binary @-
echo -e '@prefix pcdm: <http://pcdm.org/models#>\n\n<> a pcdm:Collection .' | curl -i -XPUT -H"Content-Type: text/turtle" http://localhost:8080/rest/collections/poe --data-binary @-
echo -e '@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n@prefix ldp: <http://www.w3.org/ns/ldp#>\n@prefix pcdm: <http://pcdm.org/models#>\n@prefix ore: <http://www.openarchives.org/ore/terms/>\n\n<> a pcdm:Object ;\nrdf:type <http://www.w3.org/ns/ldp#IndirectContainer>;\n
ldp:membershipResource </rest/collections/poe/> ;\nldp:hasMemberRelation pcdm:hasMember ;\nldp:insertedContentRelation ore:proxyFor .' | curl -i -XPUT -H"Content-Type: text/turtle" -H'Link: <http://www.w3.org/ns/ldp#IndirectContainer>;rel="type"' http://localhost:8080/rest/collections/poe/members --data-binary @-
echo -e '@prefix pcdm: <http://pcdm.org/models#>\n@prefix ore: <http://www.openarchives.org/ore/terms/>\n\n<> a pcdm:Object ;\nore:proxyFor </fcrepo/rest/objects/raven/> .' | curl -i -XPUT -H"Content-Type: text/turtle" http://localhost:8080/rest/collections/poe/members/ravenProxy --data-binary @-
###
# Create nested, versioned containers
###
curl -XPUT http://localhost:8080/rest/a
curl -XPOST http://localhost:8080/rest/a/fcr:versions -H"slug: v1"
echo -e 'PREFIX junk: <http://junk.org#>\nINSERT {\n <> junk:title "A title"\n} WHERE {\n}' | curl -i -XPATCH -H"Content-Type: application/sparql-update" http://localhost:8080/rest/a --data-binary @-
curl -XPOST http://localhost:8080/rest/a/fcr:versions -H"slug: v2"
curl -XPUT http://localhost:8080/rest/a/b
curl -XPOST http://localhost:8080/rest/a/b/fcr:versions -H"slug: v1"
echo -e 'PREFIX junk: <http://junk.org#>\nINSERT {\n <> junk:title "A title-b"\n} WHERE {\n}' | curl -i -XPATCH -H"Content-Type: application/sparql-update" http://localhost:8080/rest/a/b --data-binary @-
curl -XPOST http://localhost:8080/rest/a/b/fcr:versions -H"slug: v2"
curl -XPUT http://localhost:8080/rest/a/b/c
curl -XPOST http://localhost:8080/rest/a/b/c/fcr:versions -H"slug: v1"
echo -e 'PREFIX junk: <http://junk.org#>\nINSERT {\n <> junk:title "A title-c"\n} WHERE {\n}' | curl -i -XPATCH -H"Content-Type: application/sparql-update" http://localhost:8080/rest/a/b/c --data-binary @-
curl -XPOST http://localhost:8080/rest/a/b/c/fcr:versions -H"slug: v2"
###
# Create Binaries
###
echo -e 'hello world' | curl -i -XPUT -H"Content-Type: text/plain" http://localhost:8080/rest/a/b/c/binary --data-binary @-
curl -XPOST http://localhost:8080/rest/a/b/c/binary/fcr:versions -H"slug: v1"
echo -e 'PREFIX junk: <http://junk.org#>\nINSERT {\n <> junk:title "A title-binary"\n} WHERE {\n}' | curl -i -XPATCH -H"Content-Type: application/sparql-update" http://localhost:8080/rest/a/b/c/binary/fcr:metadata --data-binary @-
curl -XPOST http://localhost:8080/rest/a/b/c/binary/fcr:versions -H"slug: v2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment