Versions Compared

Key

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

...

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

Code Block
$ java -version
java version "1.7.0_12-ea"
Java(TM) SE Runtime Environment (build 1.7.0_12-ea-b08)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b28, mixed mode)
 
$ mvn -version
Apache Maven 3.0.3 (r1075438; 2011-02-28 09:31:09-0800)
Maven home: /usr/share/maven
Java version: 1.7.0_12-ea, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_12.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.8.3", arch: "x86_64", family: "mac"

Building Fedora 4

You can Downloads and Deploying Fedora 4 Complete Guide 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:

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

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] fcrepo4
[INFO] fcrepo-jcr
[INFO] fcrepo-metrics
[INFO] fcrepo-storage-policy
[INFO] fcrepo-kernel
[INFO] fcrepo-audit
[INFO] fcrepo-jms
[INFO] fcrepo-serialization
[INFO] fcrepo-http-commons
[INFO] fcrepo-http-api
[INFO] fcrepo-generator-dc
[INFO] fcrepo-webapp
[INFO] fcrepo-rss
[INFO] fcrepo-webhooks
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building fcrepo4 4.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 4 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/  

REST API Examples

The RESTful HTTP 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/"
@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/ -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