Page tree

Bleeding Edge

This documentation covers bleeding-edge updates to the 6.x version of Fedora. Looking for another version? See all documentation.

Skip to end of metadata
Go to start of metadata

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

Prerequisites

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

$ java -version
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.5+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.5+10, mixed mode)   

$ mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/opt/apache-maven-3.6.3
Java version: 11.0.5, vendor: AdoptOpenJDK, runtime: /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.6", arch: "x86_64", family: "mac"

Building Fedora

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

Clone the latest code from Github:

$ git clone https://github.com/fcrepo/fcrepo.git
Cloning into 'fcrepo'...
remote: Counting objects: 40152, done.
remote: Compressing objects: 100% (12759/12759), done.
Receiving objects:  14% (5622/40152), 3.68 MiB | 912 KiB/s  
[...]
 
$ cd fcrepo

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

Running mvn -Pfast-build clean install builds Fedora quickly by skipping all tests. Run mvn clean install if you want to run the tests.


$ mvn -Pfast-build clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Fedora Commons :: Parent POM                                       [pom]
[INFO] Fedora Commons                                                     [pom]
[INFO] Fedora Repository Common Module                                 [bundle]
[INFO] Fedora Repository Configurations Module                         [bundle]
[INFO] Fedora Repository Kernel API                                    [bundle]
[INFO] Fedora Repository Persistence API Module                        [bundle]
[INFO] Fedora Repository Persistence Common Module                     [bundle]
[INFO] Fedora Repository Kernel Implementation                         [bundle]
[INFO] Fedora Repository Search API                                    [bundle]
[INFO] Fedora Repository OCFL Persistence Impl                         [bundle]
[INFO] Fedora Repository Search Impl                                   [bundle]
[INFO] Fedora Repository HTTP Commons Module                           [bundle]
[INFO] Fedora Event Serialization                                      [bundle]
[INFO] Fedora Repository JMS Module                                    [bundle]
[INFO] Fedora Repository Authorization Commons Module                  [bundle]
[INFO] Fedora Repository HTTP API Module                               [bundle]
[INFO] Fedora Repository WebAC Authorization Module                    [bundle]
[INFO] Fedora Repository Deployable Web Application                       [war]
[INFO] Fedora Repository LDP integration tests Module                     [jar]
[INFO] Fedora Repository RDF integration tests Module                     [jar]
[INFO]
[INFO] ----------------------< org.fcrepo:fcrepo-parent >----------------------
[INFO] Building Fedora Commons :: Parent POM 6.0.0-SNAPSHOT              [1/20]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[....]

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)

$ cd fcrepo-webapp
$ mvn jetty:run
[...]
[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:

$ curl "http://localhost:8080/rest/" -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/>
        fedora:lastModified            "2018-05-30T20:51:11.833Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
        rdf:type                       ldp:RDFSource ;
        rdf:type                       ldp:Container ;
        rdf:type                       ldp:BasicContainer ;
        fedora:writable                true ;
        rdf:type                       fedora:RepositoryRoot ;
        rdf:type                       fedora:Resource ;
        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:

$ curl http://localhost:8080/rest/ -H "Accept: application/rdf+xml" -ufedoraAdmin:fedoraAdmin
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:acl="http://www.w3.org/ns/auth/acl#"
    xmlns:ldp="http://www.w3.org/ns/ldp#"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:webac="http://fedora.info/definitions/v4/webac#"
    xmlns:ns001="http://localhost:8080/rest/ktest/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:ebucore="http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#"
    xmlns:premis="http://www.loc.gov/premis/rdf/v1#"
    xmlns:test="info:fedora/test/"
    xmlns:fedora="http://fedora.info/definitions/v4/repository#"
    xmlns:memento="http://mementoweb.org/ns#"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:foaf="http://xmlns.com/foaf/0.1/"
    xmlns:fedoraconfig="http://fedora.info/definitions/v4/config#" > 
  <rdf:Description rdf:about="http://localhost:8080/rest/">
    <rdf:type rdf:resource="http://fedora.info/definitions/v4/repository#Resource"/>
    <ldp:contains rdf:resource="http://localhost:8080/rest/examples"/>
    <ldp:contains rdf:resource="http://localhost:8080/rest/91/86/4c/e0/91864ce0-9ad2-49cd-b2c3-85b0c6b204e5"/>
    <fedora:hasTransactionProvider rdf:resource="http://localhost:8080/rest/fcr:tx"/>
    <ldp:contains rdf:resource="http://localhost:8080/rest/ktest"/>
    <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

$ 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://localhost:8080/rest/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/ldp#RDFSource> .
<http://localhost:8080/rest/> <http://www.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

$ 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" ;
        fedora:createdBy       "fedoraAdmin" ;
        fedora:created         "2018-08-02T14:50:46.121Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
        fedora:lastModified    "2018-08-02T14:50:46.121Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
        rdf:type               ldp:RDFSource ;
        rdf:type               ldp:Container ;
        fedora:writable        true .

Delete an object

$ curl -X DELETE http://localhost:8080/rest/39965e35-4cad-4b96-b826-0c8612f773d5 -ufedoraAdmin:fedoraAdmin


  • No labels