...
The webapp can be run from a bundled instance of jetty. The application will listen on port 8080 by default
Code Block |
---|
$ cd fcrepo-webapp $ MAVEN_OPTS="-Xmx512m" mvn jetty:run [...] TRACE 10:50:43.845 (SessionProvider) Returning new InjectableSession... DEBUG 10:50:43.845 (InjectableSession) Initializing an InjectableSession with SessionFactory org.fcrepo.session.SessionFactory@5a3c8525. TRACE 10:50:43.846 (SessionProvider) Returning new InjectableSession... DEBUG 10:50:43.846 (InjectableSession) Initializing an InjectableSession with SessionFactory org.fcrepo.session.SessionFactory@5a3c8525. 2013-07-01 10:50:44.027:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080 [INFO] Started Jetty Server [INFO] Starting scanner at interval of 2 seconds. |
There's a nice, friendly HTML interface waiting for you at http://localhost:8080/rest/
REST API Examples
Code Block |
---|
$ curl "http://localhost:8080/rest/" @prefix dc: <http://purl.org/dc/terms/> . @prefix nt: <http://www.jcp.org/jcr/nt/1.0> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix test: <info:fedora/test/> . @prefix fedora-internal: <info:fedora/fedora-system:def/internal#> . @prefix image: <http://www.modeshape.org/images/1.0> . @prefix xs: <http://www.w3.org/2001/XMLSchema> . @prefix xml: <http://www.w3.org/XML/1998/namespace> . @prefix fedorarelsext: <info:fedora/fedora-system:def/relations-external#> . @prefix mix: <http://www.jcp.org/jcr/mix/1.0> . @prefix mode: <http://www.modeshape.org/1.0> . @prefix sv: <http://www.jcp.org/jcr/sv/1.0> . @prefix xsi: <http://www.w3.org/2001/XMLSchema-instance> . @prefix fedora: <info:fedora/> . <http://localhost:8080/rest/> <http://microformats.org/wiki/rel-sitemap> <http://localhost:8080/rest/sitemap> ; <http://www.whatwg.org/specs/web-apps/current-work/#link-type-search> <http://localhost:8080/rest/fcr:search> ; fedora:exportsAs <http://localhost:8080/rest//fcr:export?format=jcr/xml> ; fedora-internal:clusterCacheMode "LOCAL" ; fedora-internal:clusterMembers "local" ; fedora-internal:clusterName "ISPN" ; fedora-internal:clusterNodeAddress "local" ; fedora-internal:clusterNodeView "Unknown" ; fedora-internal:clusterPhysicalAddress ... |
The REST API supports a variety of RDF serialization formats, including:
Code Block |
---|
$ curl http://localhost:8080/rest/ -H "Accept: application/rdf+xml" <rdf:RDF xmlns:fedora="info:fedora/" xmlns:fedora-internal="info:fedora/fedora-system:def/internal#" xmlns:image="http://www.modeshape.org/images/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:test="info:fedora/test/" xmlns:fedorarelsext="info:fedora/fedora-system:def/relations-external#" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:mode="http://www.modeshape.org/1.0" xmlns:j.0="info:fedora/fedora-system:def/internal#repository/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:j.1="http://microformats.org/wiki/" xmlns:dc="http://purl.org/dc/terms/" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:j.2="http://www.whatwg.org/specs/web-apps/current-work/#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" > <rdf:Description rdf:about="http://localhost:8080/rest//fcr:export?format=jcr/xml"> <rdfs:label>jcr/xml</rdfs:label> </rdf:Description> <rdf:Description rdf:about="http://localhost:8080/rest/"> <fedora-internal:numberOfChildren rdf:datatype="http://www.w3.org/2001/XMLSchema#long">0</fedora-internal:numberOfChildren> <fedora-internal:hasNodeType>nt:unstructured</fedora-internal:hasNodeType> <j.0:jcr.specification.version>2.0</j.0:jcr.specification.version> <j.0:option.unfiled.content.supported>false</j.0:option.unfiled.content.supported> <fedora-internal:clusterNodeAddress>local</fedora-internal:clusterNodeAddress> <fedora-internal:hasNodeType>mix:referenceable</fedora-internal:hasNodeType> <j.0:node.type.management.update.in.use.suported>true</j.0:node.type.management.update.in.use.suported> <j.0:query.xpath.doc.order>false</j.0:query.xpath.doc.order> <j.0:level.2.supported>true</j.0:level.2.supported> <fedora-internal:hasNodeType>nt:resource</fedora-internal:hasNodeType> <fedora-internal:hasNodeType>fedora:datastream</fedora-internal:hasNodeType> |
or
Code Block |
---|
$ curl http://localhost:8080/rest/ -H "Accept: application/n-triples" <http://localhost:8080/rest/> <info:fedora/fedora-system:def/internal#numberOfChildren> "0"^^<http://www.w3.org/2001/XMLSchema#long> . <http://localhost:8080/rest/> <info:fedora/fedora-system:def/internal#hasNodeType> "nt:unstructured" . <http://localhost:8080/rest/> <info:fedora/fedora-system:def/internal#repository/jcr.specification.version> "2.0" . <http://localhost:8080/rest/> <info:fedora/fedora-system:def/internal#repository/option.unfiled.content.supported> "false" . <http://localhost:8080/rest/> <info:fedora/fedora-system:def/internal#clusterNodeAddress> "local" . <http://localhost:8080/rest/> <info:fedora/fedora-system:def/internal#hasNodeType> "mix:referenceable" . <http://localhost:8080/rest/> <info:fedora/fedora-system:def/internal#repository/node.type.management.update.in.use.suported> "true" . <http://localhost:8080/rest/> <info:fedora/fedora-system:def/internal#repository/query.xpath.doc.order> "false" . <http://localhost:8080/rest/> <info:fedora/fedora-system:def/internal#repository/level.2.supported> "true" . <http://localhost:8080/rest/> <info:fedora/fedora-system:def/internal#hasNodeType> "nt:resource" . |
Create a new object
Code Block |
---|
$ curl http://localhost:8080/rest/fcr:new -X POST -v * About to connect() to localhost port 8080 (#0) * Trying ::1... * connected * Connected to localhost (::1) port 8080 (#0) > POST /rest/fcr:new HTTP/1.1 > User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5 > Host: localhost:8080 > Accept: */* > < HTTP/1.1 201 Created < Location: http://localhost:8080/rest/7f/50/8e/82/7f508e82-15f7-48de-92a3-2575a1b749cf < Content-Type: text/plain < Transfer-Encoding: chunked < Server: Jetty(8.1.11.v20130520) $ curl http://localhost:8080/rest/7f/50/8e/82/7f508e82-15f7-48de-92a3-2575a1b749cf <http://localhost:8080/rest/7f/50/8e/82/7f508e82-15f7-48de-92a3-2575a1b749cf> fedora:exportsAs <http://localhost:8080/rest/7f/50/8e/82/7f508e82-15f7-48de-92a3-2575a1b749cf/fcr:export?format=jcr/xml> ; fedora-internal:baseVersion <info:fedora/jcr:system/jcr:versionStorage/0e/4e/11/0e4e11e565da7612554b06b092ee5e6e5fc1abec/jcr:rootVersion> ; fedora-internal:created "2013-07-01T17:52:51.406Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ; fedora-internal:createdBy "<anonymous>" ; fedora-internal:createdby "<anonymous>" ; fedora-internal:hasParent <http://localhost:8080/rest/7f/50/8e/82> ; |
Delete an object
Code Block |
---|
$ curl -X DELETE http://localhost:8080/rest/7f/50/8e/82/7f508e82-15f7-48de-92a3-2575a1b749cf |
Fedora 3: Tutorial 2 - Creating Fedora Objects