qsac SAC implementation

[Interface as of 0.4.1, 2010 October 22]

qsac SAC implementation: A SAC is a Semantic Annotation Collection, which allows users or applications to store and share bookmarks, comments, and other annotations. This implementation is a prototype one, which may or may not become the project's main SAC implementation. There are other implementations (loosely) planned. See the project's 'vision' for the overall plan, and the list of user stories for the detailed functionality we expect to add in the future.

Resource list

/sac
The parent of all the SACs in the service. This returns an HTML page listing the available SACs.
/sac/{sacName}
An individual SAC
/sac/{sacName}/{submodelName}
A submodel which is included in the SAC; this will typically be an ontology of domain-specific knowledge. Queries over the SAC include the contents of the submodel as well as the claims.
/sac/{sacName}/_/{claimid}
An individual claim.
/version
Provide version information, including information about what functionality is compiled in.
/version/{component}
An individual component within the SAC software

Resource /sac

The parent of all the SACs in the service. This returns an HTML page listing the available SACs.

GET

/sac

Retrieve human-readable information about the SAC service. The content of the response is not otherwise specified, but it might include things such as the SACs that are available.

This part of the interface is only available in a 'multiSAC', which is a SAC which contains multiple separate SACs. In a standalone SAC this resource might not be nameable.

Response: 200

Retrieve type text/html
Text describing the SAC service

Resource /sac/{sacName}

{sacName}The name of the SAC to be operated on

An individual SAC

GET

/sac/{sacName}

?metadataIf the metadata query parameter is present, with any value, then return the SAC's metadata instead of its content.

Retrieve a SAC or, if the metadata query parameter is present, retrieve the SAC's metadata. The configuration metadata is discussed in the documentation for the PUT action.

The HTTP 'Accept' header may be present in the request, and if so should be one of the representations listed below as success responses.

Response: 200

Return a representation of the RDF content of the SAC.

Retrieve type application/rdf+xml
Retrieve type text/rdf+n3
Retrieve type text/turtle

Response: 404

Retrieve type text/html
The SAC does not exist. The content includes text explaining this.

Response: 406

Retrieve type text/html
The SAC (or its metadata, if that was requested) cannot be represented in an acceptable format. The content includes text explaining this.

GET

/sac/{sacName}

?queryA URL-encoded SPARQL query.

Make a SPARQL query against the SAC

The HTTP 'Accept' header may be present in the request, and if so should be one of the representations listed below as success responses.

See the POST SPARQL method for detailed discussion.

Response: 200

The results of the SPARQL query, in the appropriate MIME type for the query

Retrieve type application/rdf+xml
Retrieve type text/rdf+n3
Retrieve type text/turtle
Retrieve type text/plain
N-triples format (for SPARQL construct and describe queries); or the string 'yes' or 'no' for SPARQL ask queries; or an ascii-art table for SPARQL select queries
Retrieve type application/sparql-results+xml
SPARQL query result format (for SPARQL select and ask queries). See SPARQL query results spec
Retrieve type text/csv
Comma-separated-values (for SPARQL select queries)
Retrieve type text/tab-separated-values
Tab-separated-values (for SPARQL select queries)

Response: 400

Retrieve type text/html
Malformed SPARQL request

Response: 406

Retrieve type text/html
Unacceptable MIME type in Accept header

POST

/sac/{sacName}

Add a claim to the SAC: Post RDF to a SAC and get a claim back. The posted RDF – which must have as its content-type one of the request MIME types listed below – is parsed with the new claim URI as its base-URI, so it should refer to the claim itself with <> (in Turtle) or rdf:about="" (in RDF/XML). The claim URI is returned in the response's Location header. If there is no RDF in the request body, that is an error.

For example, the following RDF would be acceptable as a claim:

@prefix skua: <http://myskua.org/claimtypes/1.0/> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
<> a skua:bookmark;
   skua:ref [
     a skua:webpage;
     skua:url <http://n2.talis.com/wiki/SPARQL_Demo>;
     dc:title "SPARQL Demo - N2 wiki";
  ];
  skua:tag "semanticweb", "rdf", "sparql", "tutorial";
  skua:time "2008-01-21T18:11:58Z" .

Request

Upload type application/rdf+xml
Upload type text/rdf+n3
Upload type text/turtle

Response: 201

Returns the ID of the created claim in a Location header

Retrieve type text/html
Location:The full URL of the newly-created claim

Response: 400

Retrieve type text/html
There was no RDF included in the request body, or else the posted RDF did not refer to the claim URI.

POST

/sac/{sacName}

Make a SPARQL query against the SAC. See the SPARQL spec for full documentation.

SPARQL CONSTRUCT and DESCRIBE queries produce RDF, and so if an Accept header is present it must be one of the RDF MIME types below, namely text/rdf+n3, application/rdf+xml, text/turtle or text/plain (N-triples).

SELECT queries produce a list of results, and so the result must be one of the list types below, namely application/sparql-results+xml, text/plain (ascii-art output), text/csv or text/tab-separated-values.

ASK queries can produce either of the types application/sparql-results+xml or text/plain (containing one of the strings yes or no), with a 200 status if the query succeeds, irrespective of whether the answer is true or false.

Request

Upload type application/sparql-query

Response: 200

The results of the SPARQL query, in the appropriate MIME type for the query

Retrieve type application/rdf+xml
Retrieve type text/rdf+n3
Retrieve type text/turtle
Retrieve type text/plain
N-triples format (for SPARQL construct queries)
Retrieve type application/sparql-results+xml
SPARQL query result format (for SPARQL select and ask queries). See SPARQL query results spec
Retrieve type text/csv
Comma-separated-values (for SPARQL select queries)
Retrieve type text/tab-separated-values
Tab-separated-values (for SPARQL select queries)

Response: 400

Retrieve type text/html
Malformed SPARQL request

Response: 406

Retrieve type text/html
Unacceptable MIME type in Accept header

POST

/sac/{sacName}

?metadataThe changeset can only (at present) be posted to the SAC's {sacName}?metadata URL.

Update the SAC metadata by posting to the {sacName}?metadata URL. The content of the post must abide by (a profile of) an unversioned update in the Talis Changeset Protocol, except that (currently) we may have only one ChangeSet per posting, and each addition and removal must have the subjectOfChange as its subject.

Request

Upload type application/vnd.talis.changeset+xml
The content must be RDF/XML. It is parsed with the sacName as its base URI.

Response: 204

Response: 400

Retrieve type text/html
If the changeset is in any way malformed, or the protocol's preconditions are not satisfied, return status 400.

PUT

/sac/{sacName}

Create a SAC: Create a SAC by PUTing metadata to what you have chosen as the new SAC URI -- that is, making a choice for the {sacName} in the URI. If the SAC already exists, you will receive the status code 409 Conflict.

The metadata can be anything, but might include for example Dublin Core information. The uploaded RDF is parsed with the new SAC name as its base URI, and so should refer to the SAC with <> (in Turtle) or rdf:about="" (in RDF/XML). The metadata can be retrieved at the URI which is the SAC's name, with a '?metadata' query suffixed (see above).

As well as documenting the SAC's purpose, the metadata can also be used to configure the SAC.

You must supply at least some metadata for the SAC, or else the SAC will response with an error 400 Bad Request.

For example, the SAC creation metadata might be as simple as the following

@prefix dc: <http://purl.org/dc/elements/1.1/>.
<> dc:description "My SAC";
   dc:creator "Norman".

Request

The RDF content of the SAC's metadata.

Upload unspecified type
If no Content-Type is supplied, then the SAC defaults to application/rdf+xml
Upload type application/rdf+xml
Upload type text/rdf+n3
Upload type text/turtle

Response: 201

Retrieve type text/html
Location:The URL of the newly-created SAC (which will be the same as the URL to which this request was posted).
Returns 201 (Created) if the SAC has been successfully created, and returns the URL of the SAC in a Location header.

Response: 400

Retrieve type text/html
No metadata was supplied, or the metadata did not refer to the resource <>, or the metadata could not be parsed as RDF.

Response: 409

Retrieve type text/html
You cannot create a SAC which already exists

DELETE

/sac/{sacName}

Delete the SAC

Response: 204

The SAC and its contents have been discarded.

Response: 404

Retrieve type text/html
Return 404 if the SAC can't be found

Resource /sac/{sacName}/{submodelName}

{sacName}The name of the SAC to be operated on
{submodelName}An identifier for a specific submodel.

A submodel which is included in the SAC; this will typically be an ontology of domain-specific knowledge. Queries over the SAC include the contents of the submodel as well as the claims.

GET

/sac/{sacName}/{submodelName}

Retrieve the submodel

Response: 200

The RDF representing a submodel

Retrieve type text/turtle
Retrieve type application/rdf+xml
Retrieve type text/rdf+n3

Response: 404

Retrieve type text/html
Return 404 if the submodel cannot be found in the SAC

PUT

/sac/{sacName}/{submodelName}

Add or overwrite the existing submodel. The content of the message is parsed with the submodel URI as the base URI.

Request

Upload unspecified type
If no Content-Type is present, then default to application/rdf+xml
Upload type application/rdf+xml
Upload type text/turtle
Upload type text/rdf+n3

Response: 201

Response to PUTting a submodel. Return 201 (Created) if the submodel has been written (whether or not it existed before). Return 404 (Not Found) if the claim was not found.

Retrieve type text/html
The submodel has been successfully created or overwritten

Response: 404

Retrieve type text/html
The SAC that this purports to be a submodel of does not exist

DELETE

/sac/{sacName}/{submodelName}

Delete the submodel

Response: 204

The SAC and its contents have been discarded.

Response: 404

Retrieve type text/html
Return 404 if the SAC or the submodel can't be found

Resource /sac/{sacName}/_/{claimid}

{sacName}The name of the SAC to be operated on
{claimid}An identifier for a specific claim

An individual claim.

The structure of the claim URIs is described here only in order to document the methods which may be used on those URIs. However you should not rely on this structure, and a SAC service is free to mint claim URIs with a different structure. You do not need to generate claim URIs at any point, and should instead use only the URIs which are returned in the Location header when you create claims as described above.

GET

/sac/{sacName}/_/{claimid}

Retrieve the claim RDF

Response: 200

The RDF representing a claim

Retrieve type text/turtle
Retrieve type application/rdf+xml
Retrieve type text/rdf+n3

Response: 404

Retrieve type text/html
Return 404 if the claim cannot be found in the SAC

PUT

/sac/{sacName}/_/{claimid}

Overwrite the existing claim data. As when creating the claim (see above), you must refer to the claim itself in the updated claim RDF. You can do this by explicitly including the claim URI in the RDF, or more conveniently by referring to the claim with <> (in Turtle) or rdf:about="" (in RDF/XML).

Request

Upload unspecified type
If no Content-Type is present, then default to application/rdf+xml
Upload type application/rdf+xml
Upload type text/turtle
Upload type text/rdf+n3

Response: 204

Response to PUTting a claim. Return 204 (No Content) if the claim existed and has been successfully overwritten, 404 (Not Found) if the claim was not found, or 400 (Bad Request) if the updating RDF did not refer to the claim

Retrieveunspecified type
The claim has been successfully overwritten

Response: 400

Retrieve type text/html
The updating RDF did not refer to the claim

Response: 404

Retrieve type text/html
The claim was not found

DELETE

/sac/{sacName}/_/{claimid}

Delete the claim

Response: 204

The claim has been deleted

Response: 404

Retrieve type text/html
The claim does not exist

Resource /version

Provide version information, including information about what functionality is compiled in.

GET

/version

Response: 200

Retrieve type text/html
Text describing the versions available

Resource /version/{component}

An individual component within the SAC software

GET

/version/{component}

Response: 200

Retrieve type text/plain
The component is present, and has the given version number

Response: 204

The component is not present

Response: 404

Retrieve type text/html
The component is not recognised

Globally defined representations

application/rdf+xml

RDF/XML is the only RDF serialisation which has been fully standard by W3C. See the definition at http://www.w3.org/TR/rdf-syntax-grammar/.

text/turtle

Turtle is a well-established but still experimental text syntax for RDF. It's very closely related to Notation3, but without some of that syntax's non-RDF extensions. The MIME type is not yet registered, but text/turtle is being requested; Turtle has also been served with the MIME type application/x-turtle.

text/rdf+n3

Notation-3 is a well-known, but not fully formally specified serialisation for RDF. The application/n3 MIME type is recognised but deprecated (see W3 discussion), since its IANA registration was never completed; text/rdf+n3 is the preferred MIME type for Notation3.

application/sparql-query

The SPARQL query language for RDF is defined in http://www.w3.org/TR/rdf-sparql-protocol/.