Asset Management 2.0 Specification Example
Contents
Scenario
Copied from the Use Case document ->
https://docs.google.com/document/d/1jdKioqtZ-ZvrRc63DVzR8WXcxue4o6eGu4_cdE3XRvw/edit#?hl=en
The account services development team is building a web application to help better process account management requests. Their project’s source code has been stored in a source control repository. The source depends on re-usable open source libraries stored in their asset management system.
The project is at the point where they would like to schedule a nightly automated build. Through the build system interface they will define their build process. The build system will run this process nightly to build their implementation and publish the result back to the Asset Management system.
Scenario
The account services development team is building a web application to help better process account management requests. Their project’s source code has been stored in a source control repository. The source depends on re-usable open source libraries stored in their asset management system.
The project is at the point where they would like to schedule a nightly automated build. Through the build system interface they will define their build process. The build system will run this process nightly to build their implementation and publish the result back to the Asset Management system.
Service Discovery
Prior to working with any OSLC REST services is the Service Provider Catalog. This location of this catalog is provided by the asset management product. More information of the Service Provider Catalog can be found in the
core.
Get the service provder catalog
Request: GET
https://example.com/oslc/assets/services Accept: application/rdf+xml
OSLC-Core-Version:2.0
Response: Status Code: 200 (OK)
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#" xmlnx:oslc=”http://open-services.net/ns/core#” xmlns:dcterms="http://purl.org/dc/terms/">
<oslc:ServiceProviderCatalog rdf:about="https://example.com/oslc/assets/services">
<dcterms:title>Asset Management Services</dcterms:title>
<dcterms:description>Asset Manager OSLC Services</dcterms:description>
<dcterms:publisher>
<dcterms:title>Asset Manager</dcterms:title>
<dcterms:identifier>com.myco.assets</dcterms:identifier>
<oslc:icon> https://example.com/assets/images/AssetManager.ico</oslc:icon>
</dcterms:publisher>
<!--? OAuth config ?-->
<oslc:serviceProvider rdf:resource=”https://example.com/oslc/assets/serviceProvider”/>
</oslc:ServiceProviderCatalog>
</rdf:RDF>
GET Service Provider
In the Service Provider four services are found:
- A creation factory to programtically create new assets on the system.
- A query capability used to programtically search for assets in the system.
- A selection dialog used to provide a delegated UI to interactivlly search for assets.
- A creation dialog used to provide a deledgated UI to interactivlly create asssets.
Request: GET
https://example.com/oslc/assets/serviceProvider Accept: application/rdf+xml
OSLC-Core-Version:2.0
Response: Status Code: 200 (OK)
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#" xmlnx:oslc=”http://open-services.net/ns/core#” xmlns:dcterms="http://purl.org/dc/terms/">
<oslc:ServiceProvider rdf:about="https://example.com/oslc/assets/serviceProvider">
<dcterms:title>Asset Manager REST Services</dcterms:title>
<oslc:service>
<oslc:domain rdf:resource=”http://open-services.net/ns/core#Asset”/>
<oslc:creationFactory>
<oslc:creation rdf:resource=”https://example.com/oslc/assets”/>
<dcterms:title>Default location for creation of assets</dcterms:title>
<oslc:resourceShape rdf:resource=”https://example.com/oslc/assets/defaultAssetShape”/>
<rdf:type rdf:resource="http://open-services.net/ns/asset#Asset" />
</oslc:creationFactory>
<oslc:queryCapability>
<oslc:queryBase rdf:resource=”https://example.com/oslc/simpleQuery”/>
<dcterms:title>Asset Queries</dcterms:title>
<oslc:resourceShape rdf:resource=”https://example.com/oslc/assets/defaultAssetShape”/>
<rdf:type rdf:resource="http://open-services.net/ns/asset#Asset" />
</oslc:queryCapability>
<oslc:selectionDialog>
<dcterms:title>Search for assets</dcterms:title>
<oslc:dialog rdf:resource=”https://example.com/oslc/searchDialog”/>
<rdf:type rdf:resource="http://open-services.net/ns/asset#Asset" />
</oslc:selectionDialog>
<oslc:creationDialog>
<dcterms:title>Asset creation dialog</dcterms:title>
<oslc:dialog rdf:resource=”https://example.com/oslc/createDialog”/>
<rdf:type rdf:resource="http://open-services.net/ns/asset#Asset" />
</oslc:creationDialog>
</oslc:service>
<!--?OSLC prefix definition?-->
<oslc:ServiceProvider>
</rdf:RDF>
Delegated Asset Search
While defining the build configuration, the user opens a delegated UI within the build system UI that allows the build engineer to search within the Asset Management system for versions of dependent tools (compilers, libraries, code generators, etc) to be used during the build.
Define search dialog
The build system embeds an iFrame that points to the selection dialog URL found in Service Provider and javascript methods to launch the dialog.
<iframe id=”assetSearchDialog” src=”rdf:resource=”https://example.com/oslc/searchDialog”/>
<script>
//Listen for response
window.addEventListener('message', launchSearchDialog , false);
function launchSearchDialog(event) {
var frame = document.getElementById(‘assetSearchDialog’);
if (event.source == frame.contentWindow && event.data.indexOf('oslc-response:') == 0) {
var response = event.data.sub str('oslc-response:'.length);
handleResponse(response);
}
}
</script>
Handle Search Response
Once launched the user interacts with the dialog from the asset management system. The result for the dialog is passed back to the handleResponse() method. The result comes back as a
results resource in JSON. The results resource contains a set of links selected in the delegated selection dialog.
value of the response
{
"oslc:results" : [{
"oslc:label": "Account Management Release [2.0]",
"rdf:resource": "https://example.com/oslc/assets/000-111/20”
}]
}
Use the javascript eval method to easily hydrate the resulting JSON into a javascript object to store the selected resource URLs in the build specification.
function handleResponse(response){
var release = eval(‘(‘ + response + ‘)’);
var url = release[‘oslc:results’][0][‘rdf:resource’];
//store the resulting resource URLs
}
Delegated Asset Creation
The build engineer uses a delegated asset creation UI to create a placeholder asset (with links to the required tools found from the search) where the candidate build will be made available on publish.
Define create dialog
The build system embeds an iFrame that points to the creation dialog URL found in Service Provider and javascript methods to launch the dialog.
//Listen for response
<iframe id=”assetCreateDialog” src=”rdf:resource=”https://example.com/oslc/createDialog”/>
<script>
window.addEventListener('message', launchCreateDialog , false);
function launchCreateDialog(event) {
var frame = document.getElementById(‘assetCreateDialog’);
if (event.source == frame.contentWindow && event.data.indexOf('oslc-response:') == 0) {
var response = event.data.sub str('oslc-response:'.length);
handleCreateResponse(response);
}
}
</script>
Handle Creation Response
Once launched the user interacts with the dialog from the asset management system. The result for the dialog is passed back to the handleResponse() method. The result comes back as a
results resource in JSON. The results resource contains a set of links created in the delegated creation dialog.
value of the response
{
"oslc:results" : [{
"oslc:label": "Account Management Implementation [2.0]",
"rdf:resource": "https://example.com/oslc/assets/000-112/2.0”
}]
}
Use the javascript eval method to easily hydrate the resulting JSON into a javascript object to store the selected resource URLs in the build specification.
function handleCreateResponse(response){
var release = eval(‘(‘ + response + ‘)’);
var url = release[‘oslc:results’][0][‘rdf:resource’];
//use it
}
Query Samples
Query Result as XML
System brings the information from SCM with information about the referenced library. From the source, the build process discovers a dependency on the latest Approved Log4j with a version greater than or equal to 1.2 and less than 1.3.
Request: GET
http://example.com/simpleQuery?oslc.where=dcterms.title="Apache Log4j" and oslc_asset.categorization=”/Software/Requirements/Operating System/Linux/Red Hat” and ras:id{ras:version}>="1.2" and ras:id{ras:version}<"1.3"&oslc.select=ras:id,dcterms:title
Accept: application/rdf+xml
OSLC-Core-Version:2.0
Response: Status Code: 200 (OK)
Content-Type: application/rdf+xml
ETag: xxx
Content-Length: nnn
Body:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:oslc_asset="http://open-services.net/ns/asset#" xmlns:oslc="http://open-services.net/ns/core#" xmlns:ras="http://www.omg.org/ras/v2.2">
<oslc:ResponseInfo rdf:about="http://example.com/query?oslc.where%3Ddcterms.title%3D%22Apache%20Log4j%22%20and%20oslc_asset.categorization%3D%26rdquo%3B%2FSoftware%2FRequirements%2FOperating%20System%2FLinux%2FRed%20Hat%26rdquo%3B%20and%20ras%3Aid%7Bras%3Aversion%7D%26gt%3B%3D%221.2%22%20and%20ras%3Aid%7Bras%3Aversion%7D%26lt%3B%221.3%22&oslc.select%3Dras%3Aid%2Cdcterms%3Atitl">
<dcterms:title>Asset query service</dcterms:title>
</oslc:ResponseInfo>
<rdf:Description rdf:about="http://example.com/query">
<rdfs:member>
<oslc_asset:Asset rdf:about="http://example.com/oslc/assets/813/1.2.1">
<ras:id>
<ras:GUID>813</ras:GUID>
<ras:version>1.2.1</ras:version>
</ras:id>
<dcterms:title>Apache Log4j</dcterms:title>
</oslc_asset:Asset>
</rdfs:member>
</rdf:Description>
</rdf:RDF>
Retrieve Samples
Download Log4j Asset As Zip
System downloads referenced library artifacts (tools from the build configuration and the dependencies defined within the project) to be used during build
The build system downloads the dependent asset Log4j and extracts them in the agreed upon page of ${buildArea}/dependency/guid/version directory.
Request
GET http://example.com/oslc/assets/813/1.2.1
Accept: application/zip
OSLC-Core-Version: 2.0
Response
HTTP/1.0 200 OK
OSLC-Core-Version: 2.0
Content-Type: application/zip
ETag: xxx
Content-Length: nnn
Body: Zipped content of the log4j asset
Download Placeholder Asset as XML
The build system downloads the placeholder asset in order to publish the build implementation bits.
Request
GET https://example.com/oslc/assets/000-112/2.0
Accept: application/xml
OSLC-Core-Version: 2.0
Response
HTTP/1.0 200 OK
OSLC-Core-Version: 2.0
Content-Type: application/xml
ETag: xxx
Content-Length: nnn
<?xml version="1.0" encoding="UTF-8"?>
<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_asset="http://open-services.net/ns/asset#" xmlns:myco=”http://example.com/oslc/extended/asset” xmlns:ras="http://www.omg.org/ras/v2.2">
<oslc_asset:Asset>
<rdf:type rdf:resource="http://open-services.net/ns/asset#Asset" />
<ras:id>
<ras:GUID>000-112</ras:GUID>
<ras:version>2.0</ras:version>
</ras:id>
<dcterms:title>Account Management Implementation</dcterms:title>
<dcterms:type>Implementation</dcterms:type>
<oslc:instanceShape rdf:resource="http://example.com/shapes/implementation" />
<dcterms:subject> Websphere Implementation of Myco's web services application </dcterms:subject>
<oslc_asset:relation rdf:resource="http://example.com/oslc/assets/813/1.2.1">
<dc:type>Implementation of</dc:type>
<dc:title>Myco Services Release</dc:title>
</oslc_asset:relation>
</oslc_asset:Asset>
</rdf:RDF>
Publish Samples
Publish Implementation Asset
On success the build system uses the publish.xml template to POST the new Implementation to the asset management system.
Request
PUT https://example.com/oslc/assets/000-112/2.0
Accept: application/rdf+xml
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:dcterms="http://purl.org/dc/terms/" xmlns:oslc="http://open-services.net/ns/core#" xmlns:oslc_asset="http://open-services.net/ns/asset#" xmlns:myco=”http://example.com/oslc/extended/asset” xmlns:ras="http://www.omg.org/ras/v2.2">
<oslc_asset:Asset rdf:about="https://example.com/oslc/assets/000-112/2.0">
<rdf:type rdf:resource="http://open-services.net/ns/asset#Asset" />
<ras:id>
<ras:GUID>000-112</ras:GUID>
<ras:version>2.0</ras:version>
</ras:id>
<dcterms:title>Myco Services Application Websphere Implementation </dcterms:title>
<dcterms:type>Implementation</dcterms:type>
<oslc:instanceShape rdf:resource="http://example.com/shapes/implementation" />
<dcterms:subject> Websphere Implementation of Myco's web services application </dcterms:subject>
<oslc_asset:relation rdf:resource="http://example.com/oslc/assets/813/1.2.1">
<dc:type>Implementation of</dc:type>
<dc:title>Myco Services Release</dc:title>
</oslc_asset:relation>
</oslc_asset:Asset>
</rdf:RDF>
Response
HTTP/1.0 200 OK
OSLC-Core-Version: 2.0
Content-Type: application/rdf+xml
ETag: xxx
Content-Length: nnn
Location: http://example.com/oslc/assets/1945/1.0.10_12_2010
<?xml version="1.0" encoding="UTF-8"?>
<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_asset="http://open-services.net/ns/asset#" xmlns:myco=”http://example.com/oslc/extended/asset” xmlns:ras="http://www.omg.org/ras/v2.2" >
<oslc_asset:Asset rdf:about=”https://example.com/oslc/assets/000-112/2.0”>
<rdf:type rdf:resource="http://open-services.net/ns/asset#Asset" />
<ras:id>
<ras:GUID>000-112</ras:GUID>
<ras:version>2.0</ras:version>
</ras:id>
<dcterms:title>Myco Services Application Websphere Implementation </dcterms:title>
<dcterms:type>Implementation</dcterms:type>
<oslc:instanceShape rdf:resource="http://example.com/shapes/implementation" />
<dcterms:subject> Websphere Implementation of Myco's web services application </dcterms:subject>
<oslc_asset:relation rdf:resource="http://example.com/oslc/assets/813/1.2.1">
<dc:type>Implementation of</dc:type>
<dc:title>Myco Services Release</dc:title>
</oslc_asset:relation>
<oslc_asset:artifactContentFactory rdf:about="https://example.com/oslc/assets/000-112/2.0/artifacts"/>
</oslc_asset:Asset>
</rdf:RDF>
Publish Built EAR
All files created during the build the build are added as Artifacts to the new asset.
Request
POST https://example.com/oslc/assets/000-112/2.0/artifacts
oslc_asset.name=services.ear
Content-Type: application/java-archive
OSLC-Core-Version: 2.0
Response
HTTP/1.0 201 Created
OSLC-Core-Version: 2.0
ETag: xxx
Content-Length: nnn
Location: http://example.com/oslc/assets/000-112/2.0/artifactsContents/services.ear
Update Asset
The build system updates the implementation asset with the new Last Built Date. OSLC Core Guidance: Partial Update
OSLCCorePartialUpdateDRAFT.
Request
POST https://example.com/oslc/assets/1945/1.0.10_12_2010
Content-Type: application/sparql-update
X-Method-Override=PATCH
OSLC-Core-Version: 2.0
PREFIX myco: <http://example.com/oslc/extended/asset>
DELETE DATA {
<https://example.com/oslc/assets/1945/1.0.10_12_2010> myco:lastBuilt "2010-10-08T23:00:00.000Z" }
}
INSERT DATA {
<https://example.com/oslc/assets/1945/1.0.10_12_2010> myco:lastBuilt "2010-10-09T23:00:00.000Z" }
}
Response
HTTP/1.0 200 OK
OSLC-Core-Version: 2.0
ETag: xxx