You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

JyFedoREST is a Jython package for creating and managing objects in a Fedora Repository. It is a minimal Jython wrapper around V3.2.1 of the Fedora REST API as documented at http://www.fedora-commons.org/confluence/display/FCR30/REST+API.

The source code for this product is available from the Fedora Commons SVN at https://fedora-commons.svn.sourceforge.net/svnroot/fedora-commons/incubator/kepler/trunk/jython/fcrepo

In order to use this package, you must install Jython and also have the org.apache.commons.httpclient jar in your JAVA class path.

JyFedoREST was written by Rick Moore for Fedora Commons and the Cornell University Library. Funding for this project was provided under a grant from the Mellon Foundation.

Product components

FCRepoRestAPI class

usage: from fcrepo.http.restapi import FCRepoRestAPI

This pure Python class contains a one-to-one implementation of each method documented in Version 3.2.1 of the Fedora Repository REST API. It is the only class you need import into your application.

  • All methods are named as documented on the wiki.
  • Required arguments are expected in the order listed in the documentation.
  • Optional arguments are acquired using Python's builtin argument dictionary syntax where each optional argument is passed as a name=value pair.
    • EXCEPTION : for the ingest() method, pid is defaulted to 'new' in the Python implementation.
  • Methods documented as "Not implemented" exist in the code but return a Python NotImplementedError exception.
  • All REST API methods return an instance of the FCRepoResponse class descibed below.

FCRepoRequestFactory class

usage: from fcrepo.http.RequestFactory import FCRepoRequestFactory

This is a support class that supplies HTTP connections and services to instances of FCRepoRestAPI. It implements GET, PUT, POST and DELETE methods in a very simple Jython wrapper around the same org.apache.commons.httpclient Java libraries used in the standard Fedora installation. The GET, PUT, POST and DELETE methods (and, thus, the FCRepoRestAPI class methods that use them) each return an instance of the FCRepoResponse class.

FCRepoResponse class

usage: from fcrepo.http.RequestFactory import FCRepoResponse

This is a support class that provides a Pythonic interface to elements of a response to an HTTP request. It implements the following methods:

  • getBody()
    • Returns the body content returned by the request.
  • getFooter(name, default=None)
    • Returns the value of the request footer specified in name.
    • If the footer does not exist, the value specified in default is returned.
  • getFooters()
    • Returns all footers from the request as a Python dictionary.
  • getHeader(name, default=None)
    • Returns the value of the request header specified in name.
    • If the header does not exist, the value specified in default is returned.
  • getHeaders()
    • Returns all headers from the request as a Python dictionary.
  • getStatus()
    • Returns the status code returned by the request.
  • getRequestMethod()
    • Returns the name of the HTTP method in the request.
    • One of GET, PUT, POST or DELETE.
  • getRequestURI()
    • Returns the URI representation of the request.
  • No labels