Contents
Overview
The following examples are meant to demonstrate the OSLC AM 2.0 specification, and should not be considered a part of the definition of the specification. Readers should not imply anything to be part of the specification from these samples alone.
Service Provider Document Samples
Service Catalog
The following is a sample service provider catalog resource. This sample resource exposes two contexts (projects) that provide OSLC AM services. This sample also references a sub-catalog document.
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dcterms="http://purl.org/dc/terms"
xmlns:oslc="http://open-services.net/ns/core#">
<oslc:ServiceProviderCatalog rdf:about="http://example.com/am-provider">
<dcterms:title>Architecture Management Service Provider Catalog</dcterms:title>
<dcterms:description>Project hosted on this server with OSLC AM services</dcterms:description>
<dcterms:publisher>
<oslc:Publisher>
<dcterms:title>Acme AM Providers</dcterms:title>
<oslc:label>Acme</oslc:label>
<dcterms:identifier>urn:inet:example.com:oslcam</dcterms:identifier>
<oslc:icon rdf:resource="http://example.com/icons/acme.png" />
</oslc:Publisher>
</dcterms:publisher>
<oslc:domain rdf:resource="http://open-services.net/ns/am#" />
<oslc:oauthConfiguration>
<oslc:OAuthConfiguration>
<oslc:oauthRequestTokenURI
rdf:resource="http://example.com/am-provider/request-token" />
<oslc:authorizationURI
rdf:resource="http://example.com/am-provider/authorization" />
<oslc:oauthAccessTokenURI
rdf:resource="http://example.com/am-provider/accessToken" />
</oslc:OAuthConfiguration>
</oslc:oauthConfiguration>
<oslc:ServiceProvider rdf:resource="http://example.com/am-provider/Project+X" />
<oslc:ServiceProvider rdf:resource="http://example.com/am-provider/Project+Y" />
<oslc:ServiceProviderCatalog rdf:resource="http://example.com/am-provider/Project+Y/subproject1" />
</oslc:ServiceProviderCatalog>
</rdf:RDF>
Service Document
The following sample is a service document for one of the context’s referenced in the catalog example above.
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dcterms="http://purl.org/dc/terms"
xmlns:oslc="http://open-services.net/ns/core#">
<oslc:ServiceProvider rdf:about="http://example.com/am-provider/Project+X">
<dcterms:title>Project X AM Provider</dcterms:title>
<dcterms:description>Example AM Provider for Project X</dcterms:description>
<dcterms:publisher>
<oslc:Publisher>
<dcterms:title>Acme AM Providers - Project X</dcterms:title>
<oslc:label>Acme - Project X</oslc:label>
<dcterms:identifier>urn:inet:example.com:oslcam/Project+X</dcterms:identifier>
<oslc:icon rdf:resource="http://example.com/icons/icon1.png" />
</oslc:Publisher>
</dcterms:publisher>
<oslc:prefixDefinition>
<oslc:PrefixDefinition>
<oslc:prefix>rdf</oslc:prefix>
<oslc:prefixBase rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#" />
</oslc:PrefixDefinition>
</oslc:prefixDefinition>
<oslc:prefixDefinition>
<oslc:PrefixDefinition>
<oslc:prefix>dcterms</oslc:prefix>
<oslc:prefixBase rdf:resource="http://purl.org/dc/terms" />
</oslc:PrefixDefinition>
</oslc:prefixDefinition>
<oslc:prefixDefinition>
<oslc:PrefixDefinition>
<oslc:prefix>oslc</oslc:prefix>
<oslc:prefixBase rdf:resource="http://open-services.net/ns/core#" />
</oslc:PrefixDefinition>
</oslc:prefixDefinition>
<oslc:prefixDefinition>
<oslc:PrefixDefinition>
<oslc:prefix>foaf</oslc:prefix>
<oslc:prefixBase rdf:resource="http://http://xmlns.com/foaf/0.1/" />
</oslc:PrefixDefinition>
</oslc:prefixDefinition>
<oslc:service>
<oslc:Service>
<oslc:domain rdf:resource="http://open-services.net/ns/am#" />
<oslc:creationFactory>
<oslc:CreationFactory>
<dcterms:title>Creation Factory for OSLC AM Resources</dcterms:title>
<oslc:label>OSLC AM Resource Creation Factory</oslc:label>
<oslc:creation
rdf:resource="http://example.com/am-provider/Project+X/oslc-factory" />
<oslc:resourceShape
rdf:resource="http://example.com/am-provider/shapes/am/resource" />
<oslc:resourceType rdf:resource="http://open-services.net/ns/am#Resource"/>
<oslc:usage rdf:resource="http://open-services.net/ns/core#default" />
</oslc:CreationFactory>
</oslc:creationFactory>
<oslc:creationFactory>
<oslc:CreationFactory>
<dcterms:title>Creation Factory for AM Resources
</dcterms:title>
<oslc:label>AM Resource Creation Factory</oslc:label>
<oslc:creation rdf:resource="http://example.com/am-provider/Project+X/factory" />
<oslc:resourceShape
rdf:resource="http://example.com/am-provider/shapes/am/resource" />
<oslc:resourceType rdf:resource="http://open-services.net/ns/am#Resource"/>
<oslc:usage rdf:resource="http://vendor.com/ns/usage/nonrdf" />
</oslc:CreationFactory>
</oslc:creationFactory>
<oslc:queryCapability>
<oslc:QueryCapability>
<dcterms:title>Resource Query Service</dcterms:title>
<oslc:label>AM Query Service</oslc:label>
<oslc:queryBase rdf:resource="http://example.com/am-provider/Project+X/query" />
<oslc:resourceType rdf:resource="http://open-services.net/ns/am#Resource"/>
<oslc:resourceShape rdf:resource="http://example.com/am-provider/shapes/am/resource" />
</oslc:QueryCapability>
</oslc:queryCapability>
<oslc:queryCapability>
<oslc:QueryCapability>
<dcterms:title>Link Type Query Service</dcterms:title>
<oslc:label>Link Type Query</oslc:label>
<oslc:queryBase rdf:resource="http://example.com/am-provider/Project+X/linktypes" />
<oslc:resourceType rdf:resource="http://open-services.net/ns/am#LinkType"/>
<oslc:resourceShape rdf:resource="http://example.com/am-provider/shapes/am/linktype" />
</oslc:QueryCapability>
</oslc:queryCapability>
<oslc:selectionDialog>
<oslc:Dialog>
<dcterms:title>OSLC AM Resource Selector</dcterms:title>
<oslc:label>AM Picker</oslc:label>
<oslc:dialog
rdf:resource="https://example.com/am-provider/resourcePicker?projectId=Project X" />
<oslc:hintWidth>400px</oslc:hintWidth>
<oslc:hintHeight>500px</oslc:hintHeight>
<oslc:resourceType rdf:resource="http://open-services.net/ns/am#resource" />
<oslc:usage rdf:resource="http://open-services.net/ns/core#default" />
</oslc:Dialog>
</oslc:selectionDialog>
<oslc:creationDialog>
<oslc:Dialog>
<dcterms:title>OSLC AM Resource Creation UI</dcterms:title>
<oslc:label>AM Creator</oslc:label>
<oslc:dialog
rdf:resource="https://example.com/am-provider/resourceCreator?projectId=Project X" />
<oslc:hintWidth>400px</oslc:hintWidth>
<oslc:hintHeight>500px</oslc:hintHeight>
<oslc:resourceType rdf:resource="http://open-services.net/ns/am#resource" />
<oslc:usage rdf:resource="http://open-services.net/ns/core#default" />
</oslc:Dialog>
</oslc:creationDialog>
</oslc:Service>
</oslc:service>
</oslc:ServiceProvider>
</rdf:RDF>
Minimal AMR
The following sample is a minimal AMR resource returned by the service provider. It includes only the required properties of all AMR resources.
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:oslc="http://open-services.net/ns/core#"
xmlns:oslc_am="http://open-services.net/ns/am#"
xmlns:dcterms="http://purl.org/dc/terms/">
<oslc_am:Resource rdf:about="https://acme.com/resources/res1">
<dcterms:title>Service Interface</dcterms:title>
<dcterms:identifier>1</dcterms:identifier>
<oslc:serviceProvider rdf:resource="http://open-services.net/ns/am#"/>
</oslc_am:Resource>
</rdf:RDF>
Alternatively the following form is equivalent to the above sample. In the following the main element is an rdf:Description
, and the typing of the resource is explicitly done with a rdf:type
element. These two document forms are equivalent in RDF terms.
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:oslc="http://open-services.net/ns/core#"
xmlns:dcterms="http://purl.org/dc/terms/">
<rdf:Description rdf:about="https://acme.com/resources/res1">
<dcterms:title>Service Interface</dcterms:title>
<dcterms:identifier>urn:oslc_am:res1</dcterms:identifier>
<rdf:type rdf:resource="http://open-services.net/ns/am#Resource" />
<oslc:serviceProvider rdf:resource="http://open-services.net/ns/am#"/>
</rdf:Description>
</rdf:RDF>
AMR with foaf:Person identities, additional properties and links
The following AMR sample includes foaf:Person
values for dcterms:creator
and dcterms:contributor
. It also includes additional non-OSLC defined properties, two of which can be considered links. One of these links includes additional properties on the link itself.
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:oslc="http://open-services.net/ns/core#"
xmlns:oslc_am="http://open-services.net/ns/am#"
xmlns:acme="http://acme.com/"
xml:base="https://acme.com/resources/res1">
<oslc_am:Resource rdf:about="https://acme.com/resources/res1">
<dcterms:title>ServiceInterface</dcterms:title>
<dcterms:identifier>urn:oslc_am:res1</dcterms:identifier>
<dcterms:description>This may come from the model element's documentation properties.</dcterms:description>
<rdf:type rdf:resource="http://www.eclipse.org/uml2/3.0.0/UML/Interface" />
<dcterms:type>UML Interface</dcterms:type>
<dcterms:source rdf:resource="https://acme.com/resources/source/res1"/>
<oslc:serviceProvider rdf:resource="http://open-services.net/ns/am#"/>
<oslc:instanceShape rdf:resource="https://acme.com/am/resource"/>
<dcterms:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2009-10-20T19:49:47-04:00</dcterms:created>
<dcterms:creator>
<foaf:Person>
<foaf:name>Dan Designer</foaf:name>
<foaf:mbox rdf:resource="mailto:dan@acme.com" />
<foaf:img rdf:resource="https://acme.com/users/photo/dan" />
</foaf:Person>
</dcterms:creator>
<dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2009-11-03T08:53:00-04:00</dcterms:modified>
<dcterms:contributor>
<foaf:Person>
<foaf:name>Ana Analyst</foaf:name>
<foaf:mbox rdf:resource="mailto:ana@acme.com" />
<foaf:img rdf:resource="https://acme.com/users/photo/ana" />
</foaf:Person>
</dcterms:contributor>
<!-- Other properties not defined by the OSLC specification. These include
relationships to other resources (links) -->
<acme:accountCode>CUST123</acme:accountCode>
<acme:elaborates rdf:resource="https://req.acme.com/reqs/req1"/>
<dcterms:requires rdf:ID="id1"
rdf:resource="https://acme.com/resources/res42"/>
</oslc_am:Resource>
<rdf:Description rdf:about="#id1">
<acme:status>approved</acme:status>
<dcterms:description>
Use of the referenced library has been approved by legal dept.
</dcterms:description>
</rdf:Description>
</rdf:RDF>
Simple Link Type
The following example resource is a Link Type resource with minimal properties specified. It provides a description of the link type http://purl.org/terms/requires, which is term defined in the Dublin Core vocabulary. In this vocabulary this term’s definition is “A related resource that is required by the described resource to support its function, delivery, or coherence.” When registered with a OSLC AM service provider, the original definition can be used, or a more localized one can be used.
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:terms="http://purl.org/dc/terms/"
xmlns:oslc_am="http://open-services.net/ns/am#"
xmlns:rdfschema="http://www.w3.org/2000/01/rdf-schema#">
<!-- The properties on this resource are used by the provider to manage the properties on
the link type URI. Clients permitted to update this description do so by editing
this resource. -->
<oslc_am:LinkType rdf:about="http://acme.com/linktype/1">
<terms:identifier>1</terms:identifier>
<terms:contributor rdf:resource="http://acme.com/user/jim" />
<terms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2011-03-21T15:41:39.296-04:00
</terms:modified>
<terms:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2011-03-21T15:41:39.328-04:00
</terms:created>
<terms:creator rdf:resource="http://acme.com/user/jim" />
</oslc_am:LinkType>
<!-- The following associates properties with the link type uri -->
<rdf:Description rdf:about="http://example.com/type#Sample">
<rdfschema:label>Sample</rdfschema:label>
<rdfschema:comments>Sample link type.</rdfschema:comments>
</rdf:Description>
</rdf:RDF>
REST Service Samples
POST new OSLC Formatted Resource
In this example the service provider permits AM resource creation and is familiar with and supports the creation of resources of this MIME type.
The client POSTs a new resource to the AMR Factory URI, which is specified in the Service Description Document. Upon successful creation the service provider returns a 201 Created response with a Location and ETag header that the client can use to manage the newly created resource. The HTTP specifcation for POST says that services SHOULD provide a response body that contains “an entity which describes the status of the request and refers to the new resource”. In this sample the service provider returns the created resource, complete with server generated identifier and URI.
Request:
POST http://example.com/am-provider/Project+X/oslc-factory
Content-Type: application/rdf+xml
OSLC-Core-Version: 2.0
Body:
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:uml="http://uml/types/">
xmlns:oslc_am="http://open-services.net/ns/am#"
xmlns:dcterms="http://purl.org/dc/terms/">
<oslc_am:Resource rdf:about="">
<dcterms:title>Service Interface</dcterms:title>
<rdf:type rdf:resource="http://www.eclipse.org/uml2/3.0.0/UML/Interface" />
<uml:specializes rdf:resource="http://am.acme.com/resources/res29"/>
</oslc_am:Resource>
</rdf:RDF>
Response:
201 Created
OSLC-Core-Version: 2.0
Content-Type: application/rdf+xml
Location: <http://am.acme.com/resources/res55>
ETag: "_28ce9abbf723s7fac993"
Body:
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:uml="http://uml/types/">
xmlns:oslc_am="http://open-services.net/ns/am#"
xmlns:dcterms="http://purl.org/dc/terms/">
<oslc_am:Resource rdf:about="http://am.acme.com/resources/res55">
<dcterms:title>Service Interface</dcterms:title>
<dcterms:identifier>55</dcterms:identifier>
<rdf:type rdf:resource="http://www.eclipse.org/uml2/3.0.0/UML/Interface" />
<uml:specializes rdf:resource="http://am.acme.com/resources/res29"/>
</oslc_am:Resource>
</rdf:RDF>
Service provider denies POST of resource
The service provider denies the AM resource creation for the given content type.
The client POSTs a new resource to the AMR Factory URI, which is specified in the Service Description Document. The service does not support this content type, or does not support the creation of new elements of this type.
The service returns a 415 Media Unsupported response.
Request:
POST http://example.com/am-provider/Project+X/oslc-factory
Content-Type: application/x-uml+xml
OSLC-Core-Version: 2.0
Body:
<uml:Class xmlns:uml="http://open-services.net/am/uml/1.0#">
<uml:name>Class1</uml:name>
<uml:abstract>true</uml:abstract>
</uml:Class>
Response:
415 Media Unsupported
OSLC-Core-Version: 2.0
Content-Type: application/rdf+xml
Body:
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:oslc="http://open-services.net/ns/core#">
<oslc:Error>
<oslc:statusCode>415</oslc:statusCode>
<oslc:message>This server does not support resources of this media type</oslc:message>
</oslc:Error>
</rdf:RDF>
POST non-OSLC resource format
The service provider permits AM resource creation and is familiar with and supports the creation of resources of this MIME type.
The client POSTs a new resource to the AMR Factory URI, which is specified in the Service Description Document. Upon successful creation the service provider returns a 201 Created response with a Location and ETag header that the client can use to manage the newly created resource.
Request:
POST http://example.com/am-provider/Project+X/factory
Content-Type: application/x-model
OSLC-Core-Version: 2.0
Body: (binary stream)
Response:
201 Created
Location: <http://am.acme.com/resources/res55>
Content-Type: application/rdf+xml
ETag: "_3928jd7sh722js7a7a7a233A"
OSLC-Core-Version: 2.0
Body:
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:vendor="http://vendor.com/ns#/">
xmlns:oslc_am="http://open-services.net/ns/am#"
xmlns:dcterms="http://purl.org/dc/terms/">
<oslc_am:Resource rdf:about="http://am.acme.com/resources/res55">
<dcterms:title>Component Map</dcterms:title>
<dcterms:identifier>55</dcterms:identifier>
<rdf:type rdf:resource="http://vendor.com/component" />
<vendor:sampleProperty>value1</vendor:sampleProperty>
<vendor:sampleRelationship rdf:resource="http://am.acme.com/resources/res8237"/>
</oslc_am:Resource>
</rdf:RDF>
Getting Link Types
In this example the client wants to get a list of all the link types supported by the service provider (in this project). The URL is discovered by looking for the query capability whose rdf:type
is oslc_am:LinkType
. Using the service provider resource above, the query base URL is http://example.com/am-provider/Project+X/linktypes
. A client can do a simple GET on this URL, and the service provider will by default return with all the link types.
Request:
GET http://example.com/am-provider/Project+X/linktypes
Accept: application/rdf+xml
OSLC-Core-Version: 2.0
Response:
GET http://example.com/am-provider/Project+X/linktypes
Content-Type: application/rdf+xml
OSLC-Core-Version: 2.0
Body:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:oslc="http://open-services.net/ns/core#"
xmlns:oslc_am="http://open-services.net/ns/am#">
<oslc:ResponseInfo
rdf:about="http://am.acme.com/query?oslc.searchText="Service"&oslc;.select=dcterms:title">
<dcterms:title>AM query results</dcterms:title>
<oslc:totalCount>3</oslc:totalCount>
</oslc:ResponseInfo>
<oslc_am:LinkTypeQuery
rdf:about="http://example.com/am-provider/Project+X/linktypes">
<oslc_am:LinkType rdf:about="http://purl.org/dc/terms/requires">
<dcterms:title>Requires</dcterms:title>
<dcterms:identifier>1234</dcterms:identifier>
<dcterms:description>The resource requires the referenced resource.</dcterms:description>
</oslc_am:LinkType>
<oslc_am:LinkType rdf:about="http://acme.com/types#implements">
<dcterms:title>Implements</dcterms:title>
<dcterms:identifier>5678</dcterms:identifier>
</oslc_am:LinkType>
<oslc_am:LinkType rdf:about="http://acme.com/types#elaborates">
<dcterms:title>Elaborates</dcterms:title>
<dcterms:identifier>90</dcterms:identifier>
</oslc_am:LinkType>
</oslc_am:ResourceQuery>
</rdf:RDF>
Simple Query Samples
Modifed past a given date
The client wants all the resources that have been modified since April 1, 2010. Note that this example assumes that xsd is a registered prefix (as reported in the service provider documents).
.../query?oslc.where=dcterms:created>"2008-04-01T12:00:00"^^xsd:dateTime
With a name and type
The client wants all the resources with the name ICustomer that are a UML interface.
.../query?oslc.where=dcterms:title="ICustomer" and rdf:type=<http://www.eclipse.org/uml2/3.0.0/UML/Interface>
With a custom property
The client wants all the resources with that have the custom property “status” equal to “red”. The namespace of this property must be specified with the oslc.prefix
parameter.
.../query?oslc.prefix=acme=<http://acme.com/ns/>&oslc;.where=acme:status="red"
Query for all resources that have a link (property) of any type to a given resource URI
The client wants all the resources with that have any type of “link” to the resource http://acme.req.com/requirements/req123
. Since we are just interested in the list of AM resources, we limit the result to just the one dcterms:title
property.
.../query?oslc.where=*=<http://acme.req.com/requirements/req123>&oslc;.select=dcterms:title
Selecting return properties
The client wants all the resources that contain the text “Service”, but only return the dcterms:title
property.
.../query?oslc.searchText="Service"&oslc;.select=dcterms:title,rdf:type
The response might look like (note the rdf:about is not URL encoded for clarity):
200 OK
OSLC-Core-Version: 2.0
Response Body:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:oslc="http://open-services.net/ns/core#"
xmlns:oslc_am="http://open-services.net/ns/am#">
<oslc:ResponseInfo
rdf:about="http://am.acme.com/query?oslc.searchText="Service"&oslc;.select=dcterms:title,rdf:type">
<dcterms:title>AM query results</dcterms:title>
<oslc:totalCount>4</oslc:totalCount>
</oslc:ResponseInfo>
<rdf:Description
rdf:about="http://am.acme.com/query">
<oslc_am:Resource rdf:about="http://am.acme.com/resources/res42">
<dcterms:title>Service Interface</dcterms:title>
<rdf:type rdf:resource="http://open-services.net/ns/am#Resource"/>
<rdf:type rdf:resource="http://www.eclipse.org/uml2/3.0.0/UML/Interface"/>
</oslc_am:Resource>
<oslc_am:Resource rdf:about="http://am.acme.com/resources/res55">
<dcterms:title>Main</dcterms:title>
<rdf:type rdf:resource="http://open-services.net/ns/am#Resource"/>
<rdf:type rdf:resource="http://www.eclipse.org/uml2/3.0.0/UML/Diagram"/>
</oslc_am:Resource>
<oslc_am:Resource rdf:about="http://am.acme.com/resources/res123">
<dcterms:title>Overview Diagram</dcterms:title>
<rdf:type rdf:resource="http://open-services.net/ns/am#Resource"/>
<rdf:type rdf:resource="http://www.eclipse.org/uml2/3.0.0/UML/Diagram"/>
</oslc_am:Resource>
<oslc_am:Resource rdf:about="http://am.acme.com/resources/res96">
<dcterms:title>MyComponent</dcterms:title>
<rdf:type rdf:resource="http://open-services.net/ns/am#Resource"/>
<rdf:type rdf:resource="http://www.eclipse.org/uml2/3.0.0/UML/Component"/>
</oslc_am:Resource>
<!-- etc. etc. -->
</rdf:Description>
</rdf:RDF>