Changeset Protocol

From n² wiki

Jump to: navigation, search

Nearby: Guides and Tutorials, Changesets

The Changeset Protocol for RDF describes the behaviour of a service capable of processing RDF descriptions of Changesets and processing their application to an underlying RDF store. The protocol specifies two operations versioned_update and unversioned_update.

A service implementing the protocol may expose either or both of the update operations, and so may function in two modes:

  • versioned_update - the changes detailed by the Changeset should be applied to the underlying RDF Store and the Changeset description itself stored in the same RDF store
  • unversioned_update - the changes detailed by the Changeset should be applied to the underlying RDF Store, the Changeset description itself should then be discarded


Contents

[edit] Common Behaviour

The following is the expected behaviour of both types of changeset service.

  • The removals and additions described by the changeset are applied to the underlying model - no checking is done to ensure that the rdf:subject of the reified statements match the Changeset's cs:subjectOfChange
  • The response code from POSTing a RDF/XML document containing two changesets with the same subject of change is 400
  • The response code from POSTing a RDF/XML document containing two changesets with different subjects of change is 400
  • A POSTed changeset will only be applied if all the removal statements exist in the model. Failure will be indicated with HTTP status code 409

[edit] Versioned Update

The following is the expected behaviour of a Changeset versioned changeset service. Names in brackets after each behaviour is the name of the corresponding acceptance test in the test suite.

  • Look for any preceding changesets with the same cs:subjectOfChange, if found the URI of the most recent will be set as the value of the cs:precedingChangeset property for the new changeset.
  • The information about the changeset itself is added to the underlying model - this includes the reified forms of the changesets's additions/removals.
  • A triple of the form <subjectOfChange> dir:etag "xyz" . should be created as a consequence of a successful request. The value of the etag should be unique.
  • The response body from POSTing a valid changeset contains the stored changeset
  • The response headers from POSTing a valid changeset includes a Location header containing the URI of the stored changeset
  • The response code from POSTing a valid changeset is 201
  • The response code from POSTing a changeset without a change reason is 400
  • The response code from POSTing a changeset without a creator is 400
  • The changeset returned in the response body includes a created date property if none was specified in the POSTed data
  • The changeset returned in the response body replaces the created date property if it was specified in the POSTed data
  • POSTing a changeset with a blank node as the cs:subjectOfChange replaces that blank node with a generated URI. The changes in the changeset are applied to this URI
  • The response code from POSTing a RDF/XML document containing two changesets with the same cs:subjectOfChange is 400
  • The response code from POSTing a RDF/XML document containing two changesets with different cs:subjectsOfChange is 400

[edit] Unversioned Update

The following is the expected behaviour of the unversioned changeset service.

  • The response code from POSTing a valid changeset is 204
  • The response body from POSTing a valid changeset is empty
  • POSTing a changeset with a blank node as the cs:subjectOfChange replaces that blank node with a generated URI. The changes in the changeset are applied to this URI.


[edit] Summary of HTTP Behaviour

Mimetype URIResponse Code (on success)ChangeSet EnactedPosted Document Saved in Store
application/rdf+xml /meta204NOYES
application/vnd.talis.changeset+xml /meta 204YESNO
application/vnd.talis.changeset+xml /meta/changesets 201YESYES
application/rdf+xml /graphs/private 204NOYES
application/vnd.talis.changeset+xml /graphs/private 204YESNO
application/vnd.talis.changeset+xml /graphs/private/changesets 201YESYES

[edit] Examples of Using the Protocol

[edit] Using cURL

Unsecured changeset:

curl -H "content-type:application/vnd.talis.changeset+xml" --data @file.rdf http://api.talis.com/stores/mystore/meta

Secured:

curl --basic -u "user:password"  -H "content-type:application/vnd.talis.changeset+xml" --data @file.rdf http://api.talis.com/stores/mystore/meta

[edit] Using PHP

    $poster = curl_init("http://api.talis.com/stores/mystore/meta");

    $headers = array();
    $headers['Content-type'] = 'application/vnd.talis.changeset+xml';

    curl_setopt($poster, CURLOPT_RETURNTRANSFER,1); 
    curl_setopt($poster, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($poster, CURLOPT_CONNECTTIMEOUT, 2);
    curl_setopt($poster, CURLOPT_TIMEOUT, 4);
    curl_setopt($poster, CURLOPT_HTTPHEADER, headers  );
    curl_setopt($poster, CURLOPT_HEADER, 1);

    curl_setopt($poster, CURLOPT_CUSTOMREQUEST, 'POST' ); 
    curl_setopt($poster, CURLOPT_POSTFIELDS, $changeset );

    $response = curl_exec($poster);
Personal tools