Versioning in Fedora is composed of three specific types of resources - a versionable resource (a LDPRv), a versions container (a LDPCv), and the actual versioned resource (a LDPRm)- and a variety of strategies to interact with these resources. Each type of resource and the HTTP methods that can be used on them are discussed below.
Working with a versionable resource (a LDPRv)A versionable resource is a type of (regular) resource - see RESTful HTTP API - Containers - but it is created by invoking a specific Link header and the GET method has an additional interaction model beyond the GET scenarios when interacting with non-versioned resources. All of the headers and methods for regular resources are applicable to a versionable resource. A resource can be declared versionable when it is created originally. This is achieved by including the following link header to your PUT or POST commands when creating the resource. When a versionable resource is created, the versions container will be created at the same time.
Request URI: /path/to/resource Methods: GET, PUT, POST Retrieve the versioned resource from a specific point in time.For more details about Fedora's datetime negotiation behaviors, see Memento Datetime Negotiation Algorithm. Request Headers: ACCEPT-datetime An RFC-1123 Date. (E.g. "Wed, 30 May 2018 23:02:44 GMT") Example:
Response:
Status: 302 Found Bad Request: Accept-Datetime header not properly formatted per RFC-1123 Unacceptable: No appropriate versioned resource found for the supplied Accept-Datetime value Examples:
|
Working with a versions container (a LDPCv)Request URI: /path/to/resource/fcr:versions Methods: GET, POST, DELETE Get a list of the available versions of an objectRequest 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:
Response:
Status: OK Not Found: Versions container resource does not exist.
Create a new versioned resource (a new LDPRm)Versions can by created in one of two ways, with a Memento-Datetime header and request body or with neither. If the Memento-Datetime header is omitted, the current time will be used by default and the current state of the versionable resource will be preserved. Any specified body will be ignored. If, however, the Memento-Datetime header is included, the versioned resource will be stored at this time marker and the request body will be stored as the versioned resource. Request Headers MEMENTO-DATETIME (Optional) An RFC-1123 Date. (E.g. "Wed, 30 May 2018 23:02:44 GMT") Example 1 (Create a new version resource 'now.' Its state is that of the current versionable resource.):
Response:
Status: Created: if a new version is created successfully Not Found: if the version container resource does not exist Example 2 (Create a new versioned resource at the supplied time marker. Its state is supplied as the request body.):
Response:
Status: Created: if a new version is created successfully Bad Request: Request body was empty or invalid. Not Found: if the version container resource does not exist Conflict: if a version with the same timestamp already exists for this resource. Unsupported media type: If a Memento-Datetime is supplied without an accompanying Content-Type header to indicate the mime type. Remove the versions container and all versioned resources
Example:
Response:
Status: No Content: if the version is reverted successfully Not Found: if the version does not exist |
Working with a versioned resource (a LDPRm)Request URI: /path/to/resource/fcr:versions/<timestamp> Methods: GET, DELETE
Get a specific versioned resourceRequest 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:
Response:
Status: OK Not Found: Versions container resource does not exist. Remove a previous version of an objectExample:
Response:
Status: No Content: if the version was deleted successfully Not Found: if the version does not exist |