Old Release

This documentation covers an old version of Fedora. Looking for another version? See all documentation.

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

Compare with Current View Page History

« Previous Version 19 Next »


 A Note on Versionable Resources

The following documented API calls are based on the assumption that the resource located at /path/to/some/resource was created as a versionable resource. You can make a resource verisonable by simply adding the following link header to your PUT or POST commands when creating or updating your resource.

Link: <http://mementoweb.org/ns#OriginalResource>; rel="type"

Examples: 

#PUT 
curl -X PUT -H "Link: <http://mementoweb.org/ns#OriginalResource>; rel=\"type\"" http://localhost:8080/rest/path/to/resource


#POST 
curl -X PUT -H "Link: <http://mementoweb.org/ns#OriginalResource>; rel=\"type\"" -H "Slug: resource" http://localhost:8080/rest/path/to

 

Request URI: /path/to/some/resource/fcr:versions

Methods: GET, POST, PATCH

 


GET Get a list of the available versions of an object

Request Headers:

ACCEPT  application/ld+json, application/link-format, application/n-triples, application/rdf+xml, application/x-turtle, application/xhtml+xml, application/xml, text/html, text/n3, text/plain, text/rdf+n3, text/turtle

Example:

curl -H "Accept: text/turtle" http://localhost:8080/rest/path/to/resource/fcr:versions

Response:

Status: HTTP/1.1 200 OK


Headers:
	 ETag: W/"671df2a47622331ffb6b70b6156526a67e5ab760"
	 Last-Modified: Wed, 30 May 2018 21:03:54 GMT
	 Link: <http://www.w3.org/ns/ldp#Resource>;rel="type"
	 Link: <http://www.w3.org/ns/ldp#RDFSource>;rel="type"
	 Link: <http://localhost:8080/rest/path/to/resource/fcr:versions/fcr:acl>; rel="acl"
	 Link: <http://mementoweb.org/ns#TimeMap>; rel="type"
	 Link: <http://localhost:8080/rest/path/to/resource>; rel="original"
	 Link: <http://localhost:8080/rest/path/to/resource>; rel="timegate"
	 Link: <http://localhost:8080/rest/path/to/resource/fcr:versions>; rel="timemap"
	 Vary-Post: Memento-Datetime
	 Allow: POST,HEAD,GET,OPTIONS,DELETE
	 Preference-Applied: return=representation
	 Vary: Prefer
	 Vary: Accept
	 Vary: Range
	 Vary: Accept-Encoding
	 Vary: Accept-Language
	 Content-Type: text/turtle;charset=utf-8
	 Content-Length: 1944


Body: 


@prefix memento:  <http://mementoweb.org/ns#> .
@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix fedora:  <http://fedora.info/definitions/v4/repository#> .
@prefix ldp:  <http://www.w3.org/ns/ldp#> .

<http://localhost:8080/rest/path/to/resource/fcr:versions>
        rdf:type               fedora:TimeMap ;
        rdf:type               fedora:Resource ;
        fedora:lastModifiedBy  "bypassAdmin" ;
        fedora:createdBy       "bypassAdmin" ;
        fedora:created         "2018-05-30T21:00:48.169Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
        fedora:lastModified    "2018-05-30T21:03:54.88Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
        memento:original       <http://localhost:8080/rest/path/to/resource> ;
        rdf:type               ldp:RDFSource ;
        fedora:writable        true ;
        ldp:contains           <http://localhost:8080/rest/path/to/resource/fcr:versions/20180530210300> ;
        ldp:contains           <http://localhost:8080/rest/path/to/resource/fcr:versions/20180530210354> .

Status:

200 OK

404 Not Found: This resource is not versioned or this resource is not exist.

Response: The requested resource is not available.

 



GET Get a previous version of an object

Request Headers:

ACCEPT  application/ld+json, application/n-triples, application/rdf+xml, application/x-turtle, application/xhtml+xml, application/xml, text/html, text/n3, text/plain, text/rdf+n3, text/turtle

Example:

curl http://localhost:8080/rest/resource/fcr:versions/<timestamp>

Response:

Status: HTTP/1.1 200 OK

Headers:
	
	Date: Wed, 30 May 2018 21:11:01 GMT
 	ETag: W/"706475b002bad44f8e5d874b8e7c3b1d35ff9a1c"
 	Last-Modified: Wed, 30 May 2018 21:00:48 GMT
 	Link: <http://www.w3.org/ns/ldp#Resource>;rel="type"
 	Link: <http://www.w3.org/ns/ldp#Container>;rel="type"
 	Link: <http://www.w3.org/ns/ldp#BasicContainer>;rel="type"
	Memento-Datetime: Wed, 30 May 2018 21:03:54 GMT
	Link: <http://mementoweb.org/ns#Memento>; rel="type"
	Link: <http://localhost:8080/static/constraints/ContainerConstraints.rdf>; rel="http://www.w3.org/ns/ldp#constrainedBy"
	Link: <http://localhost:8080/rest/path/to/resource>; rel="timegate"
	Link: <http://localhost:8080/rest/path/to/resource>; rel="original"
	Link: <http://localhost:8080/rest/path/to/resource/fcr:versions>; rel="timemap"
	Allow: GET,HEAD,OPTIONS,DELETE
	Preference-Applied: return=representation
	Vary: Prefer
	Vary: Accept
	Vary: Range
	Vary: Accept-Encoding
	Vary: Accept-Language
	Content-Type: text/turtle;charset=utf-8
	Content-Length: 1793

Body:


@prefix memento: <http://mementoweb.org/ns#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix fedora: <http://fedora.info/definitions/v4/repository#> .

<http://localhost:8080/rest/path/to/resource/fcr:versions/20180530210354>
 rdf:type ldp:RDFSource ;
 rdf:type ldp:Container ;
 rdf:type fedora:Resource ;
 rdf:type ldp:BasicContainer ;
 rdf:type fedora:Container ;
 fedora:created "2018-05-30T21:00:48.169Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
 fedora:writable true ;
 fedora:lastModified "2018-05-30T21:00:48.169Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
 fedora:lastModifiedBy "bypassAdmin" ;
 fedora:createdBy "bypassAdmin" ;
 rdf:type ldp:RDFSource ;
 rdf:type ldp:Container ;
 fedora:writable true .
* Connection #0 to host localhost left intact

200 OKStatus:

404 Not Found: if the version or the resource does not exist

Response: The requested resource is not available.

 



POST Create a new version (memento) of an object.

Request Headers

MEMENTO-DATETIME (Optional) An RFC-1123 Date. (E.g. "Wed, 30 May 2018 23:02:44 GMT")


NB: Versions can by created in one of two ways. If the Memento-Datetime header is omitted, the current time will be used by default. You may supply a request body representing state of the resource to be versioned when the Memento-Datetime header is present. If no Memento-Datetime header is present, any specified body will be ignored. Instead, the current state of the resource will be used as the body for the memento.


Example:

# Create version from current state of the object 
curl -X POST http://localhost:8080/rest/path/to/resource/fcr:versions  


# Create version by supplying body and Memento-Datetime
curl -X GET http://localhost:8080/rest/path/to/resource > resource.ttl
curl -X POST -H "Memento-Datetime: Wed, 30 May 2018 23:02:44 GMT" -H "Content-Type: text/turtle" --data-binary "@resource.ttl"  http://localhost:8080/rest/path/to/resource/fcr:versions  

Response:

Status:  HTTP/1.1 201 Created

Headers: 

	Date: Wed, 30 May 2018 23:02:44 GMT
	ETag: W/"7a7cb9a13ca1cbd1794ef36292f682e0fd7675b0"
	Last-Modified: Wed, 30 May 2018 21:00:48 GMT
	Link: <http://localhost:8080/static/constraints/ContainerConstraints.rdf>; rel="http://www.w3.org/ns/ldp#constrainedBy"
	Link: <http://localhost:8080/rest/path/to/resource>; rel="timegate"
	Link: <http://localhost:8080/rest/path/to/resource>; rel="original"
	Link: <http://localhost:8080/rest/path/to/resource/fcr:versions>; rel="timemap"
	Memento-Datetime: Wed, 30 May 2018 23:02:44 GMT
	Link: <http://mementoweb.org/ns#Memento>; rel="type"
	Location: http://localhost:8080/rest/path/to/resource/fcr:versions/20180530230244
	Content-Type: text/plain
	Content-Length: 71

Body:
http://localhost:8080/rest/path/to/resource/fcr:versions/20180530230244

 

Status:

201 Created: if a new version is created successfully

404 Not Found: if the resource does not exist

409 Conflict: if a version with the same timestamp already exists for this resource.

415 Unsupported media type: If a Memento-Datetime is supplied without an accompanying Content-Type header to indicate the mime type.


Response:

Memento with provided datetime already exists.


Request URI: /path/to/some/resource/fcr:versions/<timestamp>

Methods: DELETE

DELETE Remove a previous version of an object

Example:

curl -X DELETE http://localhost:8080/rest/path/to/resource/fcr:versions/<timestamp>


Response:

Status: 204 No Content
Headers: 
	Date: Wed, 30 May 2018 23:58:28 GMT

Status:

204 No Content: if the version is reverted successfully

Response: Cannot remove current version

404 Not Found: if the version does not exist

Response: The requested resource is not available.

  • No labels