Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This document will walk you through getting the code, building the webapp, and exercising the REST API. 

Prerequisites

Fedora 4 requires Java 7 8 and Maven 3 (only for building the project). Check that you have them installed before proceeding:

Code Block
$ java -version
java version "1.78.0_12-ea73"
Java(TM) SE Runtime Environment (build 1.78.0_1273-ea-b08b02)
Java HotSpot(TM) 64-Bit Server VM (build 2425.073-b28b02, mixed mode)
 
$ mvn -version
Apache Maven 3.03.39 (r1075438bb52d8502b132ec0a5a3f4c09453c07478323dc5; 20112015-0211-28 0910T10:3141:0947-080006:00)
Maven home: /Users/usrkford1/sharePrograms/apache-maven-3.3.9
Java version: 1.78.0_12-ea73, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.78.0_1273.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.813.36", arch: "x86_64", family: "mac"

Building Fedora

...

You can download pre-compiled binaries and run Fedora 4 in an existing Tomcat or Jetty instance. or pre-packaged Jetty instances, or build Fedora 4 from source (it's not difficult or too time consuming).

Clone the latest code from Github:

...

And build the project (the first time you build Fedora 4 may take some time and bandwidth to download all the development dependencies):

Code Block
$ MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m" mvn clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] fcrepo4Fedora Commons 4 :: Parent POM
[INFO] fcrepo-jcrFedora Commons 4
[INFO] fcrepo-metrics Fedora Repository BOM
[INFO] fcrepo-storage-policyFedora Repository JCR BOM
[INFO] fcrepo-kernel Fedora Repository BOMs
[INFO] fcrepo-audit Fedora Repository Kernel API
[INFO] fcrepo-jmsFedora Repository Configurations Module
[INFO] fcrepo-serializationFedora Repository Kernel Implementation (ModeShape)
[INFO] fcrepo-http-commons Fedora Event Serialization
[INFO] fcrepo-http-apiFedora Repository JMS Module
[INFO] fcrepo-generator-dc Fedora Repository HTTP Commons Module
[INFO] fcrepo-webapp
[INFO] fcrepo-rssFedora Repository Authorization Commons Module
[INFO] fcrepo-webhooks Fedora Repository HTTP API Module
[INFO] Fedora Repository WebAC Authorization Module
[INFO] Fedora Repository Deployable Web Application
[INFO] Fedora Repository LDP integration tests Module
[INFO] Fedora Repository RDF integration tests Module
[INFO]                                                      
[INFO] ---                   
[INFO] ------------------------------------------------------------------------
[INFO] Building fcrepo4Fedora Commons 4 :: Parent POM 5.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ fcrepo ---
[INFO] Deleting /Volumes/TempStorage/fedora4/fcrepo4/target
[INFO] 
[INFO] --- maven-enforcer-plugin:1.2:enforce (enforce-maven) @ fcrepo ---
[INFO] 
[INFO] --- maven-enforcer-plugin:1.2:enforce (default) @ fcrepo ---
[INFO] 
[INFO] --- jacoco-maven-plugin:0.6.3.201306030806:prepare-agent (pre-unit-test) @ fcrepo ---
[....]

Running the Fedora

...

webapp

The webapp can be run from a bundled instance of jetty. The application will listen on port 8080 by default.
If you would like to run the webapp on a different port, you can add the "jetty.port" option in your maven command (e.g. mvn -Djetty.port=8181 jetty:run)

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/  (the default username and password is fedoraAdmin)

REST API Examples

The REST API documentation provides a full listing of the features and functions of the REST API. Here are some examples to get you started:

Code Block
$ curl "http://localhost:8080/rest/" -ufedoraAdmin:fedoraAdmin
@prefix dcpremis:    <http://purlwww.loc.orggov/dcpremis/termsrdf/>v1#> .
@prefix nttest:  <info:fedora/test/> .
@prefix memento:  <http://wwwmementoweb.jcp.org/jcr/nt/1.0>ns#> .
@prefix foafrdfs:  <http://xmlnswww.w3.comorg/foaf2000/0.1/>01/rdf-schema#> .
@prefix testwebac:  <info<http://fedora.info/testdefinitions/v4/>webac#> .
@prefix fedora-internalacl:  <info:fedora/fedora-system:def/internal#><http://www.w3.org/ns/auth/acl#> .
@prefix imagens001:  <http://www.modeshape.org/images/1.0>localhost:8080/rest/ktest/> .
@prefix xsxsi:    <http://www.w3.org/2001/XMLSchema>XMLSchema-instance> .
@prefix xmlxmlns:   <http://www.w3.org/XML2000/1998xmlns/namespace>> .
@prefix fedorarelsextrdf: <info <http:fedora/fedora-system:def/relations-external#>/www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix mixfedora:   <http://wwwfedora.jcp.orginfo/jcrdefinitions/mixv4/1.0>repository#> .
@prefix modexml:  <http://www.modeshapew3.org/1.0>XML/1998/namespace> .
@prefix svebucore:    <http://www.jcpebu.orgch/metadata/jcrontologies/svebucore/1.0>ebucore#> .
@prefix xsildp:   <http://www.w3.org/2001ns/XMLSchema-instance>ldp#> .
@prefix fedoraxs: <info:fedora/> <http://www.w3.org/2001/XMLSchema> .
@prefix fedoraconfig:  <http://localhost:8080/rest/>
      fedora.info/definitions/v4/config#> .
@prefix foaf:  <http://xmlns.com/foaf/0.1/> .
@prefix dc:  <http://microformatspurl.org/wiki/rel-sitemap>dc/elements/1.1/> .

<http://localhost:8080/rest/>
        fedora:lastModified        <http    "2018-05-30T20:51:11.833Z"^^<http://localhost:8080/rest/sitemap>www.w3.org/2001/XMLSchema#dateTime> ;
        <http://www.whatwg.org/specs/web-apps/current-work/#link-type-search>
rdf:type                       <http://localhost:8080/rest/fcr:search>ldp:RDFSource ;
        fedora:exportsAsrdf:type                       <http://localhost:8080/rest//fcr:export?format=jcr/xml>ldp:Container ;
        fedora-internal:clusterCacheMode
rdf:type                       "LOCAL"ldp:BasicContainer ;
        fedora-internal:clusterMemberswritable  "local" ;
        fedora-internal:clusterName     "ISPN"true ;
        fedora-internal:clusterNodeAddress
rdf:type                "local" ;
        fedora-internal:clusterNodeViewRepositoryRoot ;
        rdf:type        "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 fedora:Resource ;
    xmlns:fedora="info:fedora/"
    rdf:type                       fedora:Container ;
        ldp:contains                   <http://localhost:8080/rest/ktest> ;
        ldp:contains                   <http://localhost:8080/rest/91/86/4c/e0/91864ce0-9ad2-49cd-b2c3-85b0c6b204e5> ;
        ldp:contains                   <http://localhost:8080/rest/examples> ;
        ldp:contains                   <http://localhost:8080/rest/t1> ;
        fedora:hasTransactionProvider  <http://localhost:8080/rest/fcr:tx> .

The REST API supports a variety of RDF serialization formats, including:

Code Block
$ curl http://localhost:8080/rest/ -H "Accept: application/rdf+xml" -ufedoraAdmin:fedoraAdmin
<rdf:RDF
    xmlns:rdfxmlns: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.whatwgw3.org/specs/web-apps/current-work/#1999/02/22-rdf-syntax-ns#"
    xmlns:rdfsacl="http://www.w3.org/2000ns/01auth/rdf-schema#acl#"
 > 
  <rdf:Description rdf:aboutxmlns:ldp="http://localhost:8080/rest//fcr:export?format=jcr/xml">www.w3.org/ns/ldp#"
    <rdfs:label>jcr/xml</rdfs:label>
  </rdf:Description>
  <rdf:Description rdf:aboutxmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:rdfs="http://localhost:8080/rest/">www.w3.org/2000/01/rdf-schema#"
    <fedora-internal:numberOfChildren rdf:datatypexmlns:webac="http://www.w3.org/2001/XMLSchema#long">0</fedora-internal:numberOfChildren>
    <fedora-internal:hasNodeType>nt:unstructured</fedora-internal:hasNodeType>fedora.info/definitions/v4/webac#"
    xmlns:ns001="http://localhost:8080/rest/ktest/"
    <j.0:jcr.specification.version>2.0</j.0:jcr.specification.version>xmlns:dc="http://purl.org/dc/elements/1.1/"
    <j.0:option.unfiled.content.supported>false</j.0:option.unfiled.content.supported>xmlns:ebucore="http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#"
    <fedora-internal:clusterNodeAddress>local</fedora-internal:clusterNodeAddress>xmlns:premis="http://www.loc.gov/premis/rdf/v1#"
    <fedora-internal:hasNodeType>mix:referenceable</fedora-internal:hasNodeType>xmlns:test="info:fedora/test/"
    <j.0:node.type.management.update.in.use.suported>true</j.0:node.type.management.update.in.use.suported>xmlns:fedora="http://fedora.info/definitions/v4/repository#"
    <j.0:query.xpath.doc.order>false</j.0:query.xpath.doc.order>xmlns:memento="http://mementoweb.org/ns#"
    <j.0:level.2.supported>true</j.0:level.2.supported>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <fedora-internal:hasNodeType>nt:resource</fedora-internal:hasNodeType>xmlns:foaf="http://xmlns.com/foaf/0.1/"
    <fedora-internal:hasNodeType>fedora:datastream</fedora-internal:hasNodeType>

or

Code Block
$ curl xmlns:fedoraconfig="http://fedora.info/definitions/v4/config#" > 
  <rdf:Description rdf:about="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">
    <rdf:type rdf:resource="http://fedora.info/definitions/v4/repository#Resource"/>
    <ldp:contains rdf:resource="http://localhost:8080/rest/examples"/>
 <info:fedora/fedora-system:def/internal#hasNodeType> "nt:unstructured" .
<http   <ldp:contains rdf:resource="http://localhost:8080/rest/91/86/4c/e0/91864ce0-9ad2-49cd-b2c3-85b0c6b204e5"/> <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
    <fedora:hasTransactionProvider rdf:resource="http://localhost:8080/rest/fcr:tx"/>
    <ldp:contains rdf:resource="http://localhost:8080/rest/ktest"/>
    <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 <fedora:lastModified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2018-05-30T20:51:11.833Z</fedora:lastModified>
    <fedora:writable rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</fedora:writable>
    <rdf:type rdf:resource="http://www.w3.org/ns/ldp#RDFSource"/>
    <rdf:type rdf:resource="http://fedora.info/definitions/v4/repository#RepositoryRoot"/>
    <rdf:type rdf:resource="http://www.w3.org/ns/ldp#Container"/>
    <ldp:contains rdf:resource="http://localhost:8080/rest/t1"/>
    <rdf:type rdf:resource="http://fedora.info/definitions/v4/repository#Container"/>
    <rdf:type rdf:resource="http://www.w3.org/ns/ldp#BasicContainer"/>
  </rdf:Description>
</rdf:RDF>

or

Code Block
$ curl http://localhost:8080/rest/ -H "Accept: application/n-triples" -ufedoraAdmin:fedoraAdmin
<http://localhost:8080/rest/> <http://fedora.info/definitions/v4/repository#lastModified> "2018-05-30T20:51:11.833Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<http: -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/> <http:/7f/50/8e/82/7f508e82-15f7-48de-92a3-2575a1b749cf
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Server: Jetty(8.1.11.v20130520)
 
$ curl httpwww.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/ldp#RDFSource> .
<http://localhost:8080/rest/> <http:/7f/50/8e/82/7f508e82-15f7-48de-92a3-2575a1b749cfwww.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/ldp#Container> .
<http://localhost:8080/rest/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/ldp#BasicContainer> .
<http://localhost:8080/rest/> <http://fedora.info/definitions/v4/repository#writable> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .
<http://localhost:8080/rest/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://fedora.info/definitions/v4/repository#RepositoryRoot> .
<http://localhost:8080/rest/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://fedora.info/definitions/v4/repository#Resource> .
<http://localhost:8080/rest/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://fedora.info/definitions/v4/repository#Container> .
<http://localhost:8080/rest/> <http://www.w3.org/ns/ldp#contains> <http://localhost:8080/rest/ktest> .
<http://localhost:8080/rest/> <http://www.w3.org/ns/ldp#contains> <http://localhost:8080/rest/91/86/4c/e0/91864ce0-9ad2-49cd-b2c3-85b0c6b204e5> .
<http://localhost:8080/rest/> <http://www.w3.org/ns/ldp#contains> <http://localhost:8080/rest/examples> .
<http://localhost:8080/rest/> <http://www.w3.org/ns/ldp#contains> <http://localhost:8080/rest/t1> .
<http://localhost:8080/rest/> <http://fedora.info/definitions/v4/repository#hasTransactionProvider> <http://localhost:8080/rest/fcr:tx> .

Create a new object

Code Block
$ curl http://localhost:8080/rest/ -X POST -v -ufedoraAdmin:fedoraAdmin
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
* Server auth using Basic with user 'fedoraAdmin'
> POST /rest/ HTTP/1.1
> Host: localhost:8080
> Authorization: Basic ZmVkb3JhQWRtaW46ZmVkb3JhQWRtaW4=
> User-Agent: curl/7.60.0
> Accept: */*
> 
< HTTP/1.1 201 Created
< Date: Thu, 02 Aug 2018 14:50:46 GMT
< Set-Cookie: JSESSIONID=1aftnonavsnvk1q6ln4jtleda4;Path=/
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Set-Cookie: rememberMe=deleteMe; Path=/; Max-Age=0; Expires=Wed, 01-Aug-2018 14:50:46 GMT
< ETag: W/"187414816f9004f45508769998bec981ca90bea4"
< Last-Modified: Thu, 02 Aug 2018 14:50:46 GMT
< Link: <http://localhost:8080/static/constraints/ContainerConstraints.rdf>; rel="http://www.w3.org/ns/ldp#constrainedBy"
< Link: <http://localhost:8080/rest/39965e35-4cad-4b96-b826-0c8612f773d5/fcr:acl>; rel="acl"
< Location: http://localhost:8080/rest/39965e35-4cad-4b96-b826-0c8612f773d5
< Content-Type: text/plain
< Content-Length: 63
< Server: Jetty(9.3.1.v20150714)
< 
* Connection #0 to host localhost left intact
http://localhost:8080/rest/39965e35-4cad-4b96-b826-0c8612f773d5
 
$ curl http://localhost:8080/rest/7f/50/8e/82/7f508e82-15f7-48de-92a3-2575a1b749cf -ufedoraAdmin:fedoraAdmin
@prefix premis:  <http://www.loc.gov/premis/rdf/v1#> .
@prefix test:  <info:fedora/test/> .
@prefix memento:  <http://mementoweb.org/ns#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix webac:  <http://fedora.info/definitions/v4/webac#> .
@prefix acl:  <http://www.w3.org/ns/auth/acl#> .
@prefix ns001:  <http://localhost:8080/rest/ktest/> .
@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 dc:  <http://purl.org/dc/elements/1.1/> .

<http://localhost:8080/rest/39965e35-4cad-4b96-b826-0c8612f773d5>
        rdf:type               fedora:Container ;
        rdf:type               fedora:Resource ;
        rdf:type               ldp:BasicContainer ;
        fedora:lastModifiedBy  "fedoraAdmin" ;7f/50/8e/82/7f508e82-15f7-48de-92a3-2575a1b749cf>
        fedora:exportsAscreatedBy       "fedoraAdmin" ;
        <http://localhost:8080/rest/7f/50/8e/82/7f508e82-15f7-48de-92a3-2575a1b749cf/fcr:export?format=jcr/xml> ;
fedora:created         fedora-internal:baseVersion     <info:fedora/jcr:system/jcr:versionStorage/0e/4e/11/0e4e11e565da7612554b06b092ee5e6e5fc1abec/jcr:rootVersion>"2018-08-02T14:50:46.121Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
        fedora-internal:created lastModified        "20132018-0708-01T1702T14:5250:5146.406Z121Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
        rdf:type        fedora-internal:createdBy       ldp:RDFSource ;
       "<anonymous>" ;
 rdf:type        fedora-internal:createdby       "<anonymous>"ldp:Container ;
        fedora-internal:hasParentwritable        <http://localhost:8080/rest/7f/50/8e/82> ;true .

Delete an object

Code Block
$ curl -X DELETE http://localhost:8080/rest/7f/50/8e/82/7f508e82-15f7-48de-92a3-2575a1b749cf
 
39965e35-4cad-4b96-b826-0c8612f773d5 -ufedoraAdmin:fedoraAdmin