CRUD: Read

From OSF Wiki
Jump to: navigation, search
CRUD: Read endpoint version:
1.1
2
3

The CRUD: Read Web service is used to get the description ("read") of a target instance record indexed in a dataset belonging to OSF's Web Services Framework.

Developers communicate with the CRUD: Read Web service using the HTTP GET method. You may request one of the following mime types: (1) text/xml, (2) application/rdf+xml or (3) application/rdf+n3. The content returned by the Web service will be serialized using the mime type requested and the data returned will depend on the parameters selected.

Version

This documentation page is used for the version 3 of this endpoint. Check at the top of this page to see the documentation pages for the other versions of this endpoint.

Usage

This Web service is intended to be used by any user that wants to get the description of an instance record.

Web Service Endpoint Information

This section describes all you permissions you need in the WSF (Web Service Framework) to send a query to this Web service endpoint, and it describes how to access it.

To access this Web service endpoint you need the proper CRUD (Create, Read, Update and Delete) permissions on a specific graph (dataset) of the WSF. Without the proper permissions on this graph you won't be able to send any queries to the endpoint.

Needed registered CRUD permission:
  • Create: False
  • Read: True
  • Update: False
  • Delete: False

As shown on the graph URI:

  • URI of the dataset where the instance record is indexed

Here is the information needed to communicate with this Web service's endpoint. Descriptions of the parameters are included below.

Note: if a parameter has a default value, the requester can omit it and the default value will be used. Also, some baseline Web services may not offer other values than the default.

HTTP Method:
  • GET
  • POST

Possible "Accept:" HTTP header field value:

  • text/xml (structXML)
  • application/json (structJSON)
  • application/rdf+xml (RDF+XML)
  • application/rdf+n3 (N3/Turtle)
  • application/iron+json (irJSON)
  • application/iron+csv (commON)

URI:

  • http://[...]/ws/crud/read/?uri=&dataset=&include_linksback=&include_reification=&include_attributes_list=&interface=&version=&lang=

URI dynamic parameters description:

Note: All parameters have to be URL-encoded

  • uri. URI of the instance record. Multiple URIs can be added to this parameter by splitting them with ";". That way, you can get more than one record description by query.
  • dataset. (optional) URI of the dataset where the instance record is indexed. If this parameter is omitted (empty), the web service will query all the datasets of the system, that can be read by the requester, to try to find a definition for this record URI. Multiple URIs can be added to this parameter by splitting them with ";".
  • include_linksback. One of:
    • True — Means that the reference to the other instance records referring to the target instance record will be added in the resultset
    • False (default) — No links-back will be added
  • include_reification. Include possible reification statements for a record. One of:
    • True
    • False (default)
  • include_attributes_list. (optional) A list of attribute URIs to include into the resultset. Sometime, you may be dealing with datasets where the description of the entities are composed of thousands of attributes/values. Since the Crud: Read web service endpoint returns the complete entities descriptions in its resultsets, this parameter enables you to restrict the attribute/values you want included in the resultset which considerably reduce the size of the resultset to transmit and manipulate. Multiple attribute URIs can be added to this parameter by splitting them with ";".
  • interface (optional). Source interface used for this web service query. The interface is a different way to process a query (different algorithms, different data management system, etc. The default interface is 'default'
  • version (optional). Version of the source interface that is compatible with this query. If this parameter is omitted, then the latest version of the source interface is used for this query.
  • lang. (default: en) Language of the records to be returned by the search endpoint. Only the textual information of the requested language will be returned to the user. If no textual information is available for a record, for a requested language, then only non-textual information will be returned about the record. The default is "en"; however, if the parameter is an empty string, then all the language strings for the record(s) will be returned.

Available Sources Interfaces

A source interface is a way to process a web service query. Different sources interfaces can be implemented for the same OSF Web Service endpoint. Each interface will process the query differently, but all the queries to the web service endpoint will be the same, at the exception of the interface parameter. Each interface shares the same API (the one defined by the web service endpoint), but their processing may differ (like using different algorithms, using different data management systems, etc.)

This is a list of the core interfaces for this endpoint. Organizations that hosts a OSF Web Service network could create their own interface and make it available to the users. However such private source interface won't be part of this list, but should be publicized by the organization.


Source Interface Name Description
default Default source interface for this OSF Web Service endpoint. This interface implements the default behavior of this OSF Web Service endpoint.

Versioning

A versioning system exists within OSF Web Service to ensure that distributed users are always accessing viable endpoints with expected behaviors. There are three different kind of versions at various levels within OSF Web Service:

  1. Version of the OSF Web Service software package
  2. Version of the OSF Web Service web service API endpoint
  3. Version of the different source interfaces available for each endpoint

The version of the OSF Web Service software package is only meaningful when a system administrator installs a new OSF Web Service network or when he wants to upgrade an existing OSF Web Service instance. This version has no meaning when it comes time to query any OSF Web Service endpoint.

The version of the OSF Web Service web service API endpoint is the version of the endpoint itself. It is what tracks the changes of the API: so, the changes in terms of parameters of the endpoint (new supported parameters, removed parameters, changes in behaviors for existing parameters). This version is used by the source interfaces to make sure that they are compatible with the web service endpoint's API.

The version of the source interface is the version that should most interest the users of these endpoints. When the user specifies a version for a query, he tells the web service endpoint that the query that is sent is supposed to be compatible with that version of the interface. If the version of the interface has somehow changed in the mean time, an error will be returned and the user will be notified that the query that he is sending is not compatible with the current version of the source interface he is trying to query.

There are five things that can happen with a OSF Web Service endpoint that warrants a change in the version of the endpoint, or one of its source interface:

  1. A bug gets fixed (and at least a behavior changes)
  2. The code gets refactored (and at least a behavior changes)
  3. A new parameter/feature is added to the endpoint (but at least another behavior changed)
  4. An existing parameter/feature gets changed, or
  5. An existing parameter/feature gets removed.

Example of Returned XML Document

This is an example of the XML document returned by this Web service endpoint for a given dataset URI.

This example returns the description of a dataset registered to a WSF.

Query:

"Accept:" HTTP header field value:

  • text/xml

Result:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE resultset PUBLIC "-//Structured Dynamics LLC//Crud Read DTD 0.1//EN" "http://[...]/ws/dtd/crud/crudRead.dtd">
  3. <resultset>
  4.    <prefix entity="rdf" uri="http://www.w3.org/1999/02/ 22-rdf-syntax-ns#"/>
  5.    <subject type="http://xmlns.com/foaf/0.1/Person" uri= "http://bknetwork.org/drupal/bkn/datasets/227/resource/Bob">
  6.       <predicate type="http://xmlns.com/foaf/0.1/name">
  7.          <object type="rdfs:Literal">Bob</object>
  8.       </predicate>
  9.       <predicate type="http://xmlns.com/foaf/0.1/family_name">
  10.          <object type="rdfs:Literal">Gratton</object>
  11.       </predicate>
  12.    </subject>
  13. </resultset>

Descriptions of the Types of XML Elements

The elements used to describe an instance record depend on the vocabularies (ontologies) used to describe the instance record in RDF when it was first indexed in the system. Usually more information can be found on the Web for each property and class by creating the full identifier of a property or a class by using the prefix(es) of the XML document.

Example of Returned RDF/XML Document

Here is an example of a RDF/XML document returned by this Web service endpoint for a given URI.

Query<:

"Accept:" HTTP header field value:

  • application/rdf+xml

Result:

  1. <?xml version="1.0"?>
  2. <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ns0="http://xmlns.com/foaf/0.1/">
  3.    <ns0:Person rdf:about="http://bknetwork.org/drupal/bkn/ datasets/227/resource/Bob">
  4.       <ns0:name>Bob</ns0:name>
  5.       <ns0:family_name>Gratton</ns0:family_name>
  6.    </ns0:Person>
  7. </rdf:RDF>

Example of Returned RDF/N3 Document

Here is an example of a RDF/N3 document returned by this Web service endpoint for a given URI.

Query:

"Accept:" HTTP header field value:

  • application/rdf+n3

Result:

  1. @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
  2. <http://bknetwork.org/drupal/bkn/datasets/227/resource/Bob> a <http://xmlns.com/foaf/0.1/Person> ;
  3. <http://xmlns.com/foaf/0.1/name> """Bob""" ;
  4. <http://xmlns.com/foaf/0.1/family_name> """Gratton""" .

HTTP Status Codes

Here are the possible HTTP status (error) codes returned by this Web service endpoint.

On error code and the specific error, a different message description can be issued (meaning a different error has been returned).


HTTP 200

Message Description
OK


HTTP 400

ID Level Name Description
WS-CRUD-READ-200 Warning No URI specified for any resource No record URI defined for this query
WS-CRUD-READ-201 Warning Missing Dataset URIs Not all dataset URIs have been defined for each requested record URI. Remember that each URI of the list of URIs have to have a matching dataset URI in the datasets list.
WS-CRUD-READ-202 Warning Record URI(s) not existing or not accessible The requested record URI(s) are not existing in this OSF instance, or are not accessible to the requester. This error is only sent when no data URI are defined.
WS-CRUD-READ-300 Warning This resource is not existing The target resource to be read is not existing in the system
WS-CRUD-READ-301 Warning You can't read more than 64 resources at once You are limited to read maximum 64 resources for each query to the CrudRead web service endpoint
WS-CRUD-READ-302 Fatal Can't get the description of the resource(s) An error occured when we tried to get the description of the resource(s)
WS-CRUD-READ-303 Fatal Can't get the links-to the resource(s) An error occured when we tried to get the links-to the resource(s)
WS-CRUD-READ-304 Fatal Can't get the reification statements for that resource(s) An error occured when we tried to get the reification statements of the resource(s)
WS-CRUD-READ-305 Fatal Requested source interface not existing The source interface you requested is not existing for this web service endpoint.
WS-CRUD-READ-306 Fatal Requested incompatible Source Interface version The version of the source interface you requested is not compatible with the version of the source interface currently hosted on the system. Please make sure that your tool get upgraded for using this current version of the endpoint.
WS-CRUD-READ-307 Fatal Source Interface's version not compatible with the web service endpoint's The version of the source interface you requested is not compatible with the one of the web service endpoint. Please contact the system administrator such that he updates the source interface to make it compatible with the new endpoint version.
WS-CRUD-READ-308 Fatal Language not supported by the endpoint The language you requested for you query is currently not supported by the endpoint. Please use another one and re-send your query.

HTTP 403

ID Level Name Description
WS-AUTH-VALIDATION-100 Fatal Unauthorized Request Your request cannot be authorized for this web service call
WS-AUTH-VALIDATION-101 Fatal Unauthorized Request Your request cannot be authorized for this web service call
WS-AUTH-VALIDATION-102 Fatal Couldn't authorize request An internal error occured when we tried to authorize this request
WS-AUTH-VALIDATION-103 Fatal Unauthorized Request Your request cannot be authorized for this user: "---", on this dataset: "---", using this web service endpoint: "---"


HTTP 406

Message Description
Not Acceptable Unacceptable mime type requested


HTTP 500

Message Description
Internal Error