How to create a OSLC query to download a artifact of type document in DNG
Accepted answer
So to be more specific about your question, you want to know how to find (using OSLC Query) wrapped resources and then download the file content, using DOORS Next Generation 6.0.6.1
For all requests below, use these headers (there are other headers and cookies also present in the request):
- OSLC-Core-Version: 2.0
- vvc.configuration: URL_for_your_configuration
- Accept: application/rdf+xml (you might have to vary this to download the embedded image at step 3)
1. You can query for these by using oslc.where=rdm_types:ArtifactFormat=jazz:rm:WrapperResource perhaps with additional conditions to limit the results - NOTE you can see the available artifact format definitions in the component properties in the Attribute Data Type definition for ArtifactFormats. AFAICT you can get the same results using oslc.where=rdf:type=jazz_rm:WrapperResource - not sure if one query is in any way better than the other.
NOTE: YMMV but I couldn't get the query to also filter on public_rm_10:wrappedResourceContentType, and oslc.select didn't include this value in the query results.
2. For each result, GET the resource URI like https://jazz.ibm.com:9443/rm/resources/_QGLNIYJVEeuCd97r4x93Qg it will return the resource RDF, something like this:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:acp="http://jazz.net/ns/acp#" xmlns:public_rm_10="http://www.ibm.com/xmlns/rm/public/1.0/" xmlns:calm="http://jazz.net/xmlns/prod/jazz/calm/1.0/" xmlns:jazz_rm="http://jazz.net/ns/rm#" xmlns:acc="http://open-services.net/ns/core/acc#" xmlns:process="http://jazz.net/ns/process#" xmlns:rm_property="https://jazz.ibm.com:9443/rm/types/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oslc="http://open-services.net/ns/core#" xmlns:nav="http://jazz.net/ns/rm/navigation#" xmlns:oslc_config="http://open-services.net/ns/config#" xmlns:oslc_rm="http://open-services.net/ns/rm#" xmlns:dng_task="http://jazz.net/ns/rm/dng/task#" xmlns:rm="http://www.ibm.com/xmlns/rdm/rdf/" xmlns:oslc_auto="http://open-services.net/ns/auto#"><rdf:Description rdf:about="https://jazz.ibm.com:9443/rm/resources/_QGLNIYJVEeuCd97r4x93Qg"><dcterms:title rdf:parseType="Literal">Configuring Raspbian.docx</dcterms:title><public_rm_10:wrappedResourceContentType rdf:datatype="http://www.w3.org/2001/XMLSchema#string">application/vnd.openxmlformats-officedocument.wordprocessingml.document</public_rm_10:wrappedResourceContentType><nav:parent rdf:resource="https://jazz.ibm.com:9443/rm/folders/_oslCWHX4Eeu2X8eF6GmMrw"/><dcterms:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2021-03-11T10:33:42.951Z</dcterms:created><oslc:instanceShape rdf:resource="https://jazz.ibm.com:9443/rm/types/_osb4unX4Eeu2X8eF6GmMrw"/><process:projectArea rdf:resource="https://jazz.ibm.com:9443/rm/process/project-areas/_n2bdc3X4Eeu2X8eF6GmMrw"/><oslc:serviceProvider rdf:resource="https://jazz.ibm.com:9443/rm/oslc_rm/_n2bdc3X4Eeu2X8eF6GmMrw/services.xml"/><dcterms:identifier rdf:datatype="http://www.w3.org/2001/XMLSchema#string">106284</dcterms:identifier><dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2021-03-11T10:33:42.951Z</dcterms:modified><public_rm_10:wrappedResourceRevision rdf:resource="https://jazz.ibm.com:9443/rm/wrappedResources/_QE6o4YJVEeuCd97r4x93Qg?revision=_QFXU0YJVEeuCd97r4x93Qg"/><dcterms:creator rdf:resource="https://jazz.ibm.com:9443/jts/users/ibm"/><oslc_config:component rdf:resource="https://jazz.ibm.com:9443/rm/cm/component/_oAeKQHX4Eeu2X8eF6GmMrw"/><dcterms:contributor rdf:resource="https://jazz.ibm.com:9443/jts/users/ibm"/><rdf:type rdf:resource="http://open-services.net/ns/rm#Requirement"/><acp:accessControl rdf:resource="https://jazz.ibm.com:9443/rm/accessControl/_n2bdc3X4Eeu2X8eF6GmMrw"/><dcterms:description rdf:parseType="Literal"/><rdf:type rdf:resource="http://jazz.net/ns/rm#WrapperResource"/><public_rm_10:wrappedResource rdf:resource="https://jazz.ibm.com:9443/rm/wrappedResources/_QE6o4YJVEeuCd97r4x93Qg"/></rdf:Description></rdf:RDF>
3. Then you need to code downloading the resource URI in the <public_rm_10:wrappedResourceRevision> tag, perhaps after filtering for the type of content you're looking for which is specified in the <public_rm_10:wrappedResourceContentType> tag
HTH
Ian
Comments
3 other answers
I'm not sure I understand your question. OSLC queries do not download anything. An OSLC query queries for artifacts of some resource type with optional query conditions, and returns RDF describing a query results container that references the resources found by the query. You can find more information about OSLC Query in the OSLC 3.0 Query specification which can be found at https://open-services.net/specifications/.
David.
Hi
I'm assuming you mean you want to get details of artifacts which are of a custom Artifact Type you created called Document, using OSLC Query.
This works on 6.0.6.1 and 7.0.2: You can query for a particular artifact type using oslc.where oslc:instanceShape=<shapeuri>
An OSLC query can give you just the URI(s) of the matching artifacts, or by using oslc.select you can also get additional attributes (where present) for each result, or you could make a separate GET on the artifact URIs to retrieve their full RDF.
shapeuri is the uri of the artifact type you're interested in.
You can find this by getting the services.xml for your project/component (NOTE when using configuraiton management, i.e. for a component, you have to retrieve the services.xml with the RM-local configuration specified in header vvc.configuration) and (still using the vvc.configuration header) retrieving all the oslc:resourceShape URI entries like <oslc:resourceShape rdf:resource="https://jazz.ibm.com:9443/rm/types/OT_BZBjXHa8EeuhuNAwh4oTmw"/> to find one which has dcterms:title the artifact type you're looking for. Then in this example your oslc.where would be the escaped version of oslc.where=oslc:instanceShape=<https://jazz.ibm.com:9443/rm/types/OT_BZBjXHa8EeuhuNAwh4oTmw> and you'll have to put the uri for the oslc prefix in oslc.prefix.
If you're using configurations you'll have to put the config on the query too using header vvc.configuration.
A full encoded query URL might look like:
GET /rm/views?oslc.pageSize=200&oslc.paging=true&oslc.prefix=oslc%3D%3Chttp%3A%2F%2Fopen-services.net%2Fns%2Fcore%23%3E&oslc.query=true&oslc.where=oslc%3AinstanceShape%3D%3Chttps%3A%2F%2Fjazz.ibm.com%3A9443%2Frm%2Ftypes%2FOT_BZBjXHa8EeuhuNAwh4oTmw%3E&projectURL=https%3A%2F%2Fjazz.ibm.com%3A9443%2Frm%2Fprocess%2Fproject-areas%2F_9ahGYHa7EeuhuNAwh4oTmw
Headers added (there are other headers and cookies also present in the request):
- OSLC-Core-Version: 2.0
- vvc.configuration: https://jazz.ibm.com:9443/rm/cm/stream/_duWaJna8EeuhuNAwh4oTmw
- Accept: application/rdf+xml
Which decoded and with the parameters split across lines looks like:
GET /rm/views
?oslc.pageSize=200
&oslc.paging=true
&oslc.prefix=oslc=<http://open-services.net/ns/core#>
&oslc.query=true
&oslc.where=oslc:instanceShape=<https://jazz.ibm.com:9443/rm/types/OT_BZBjXHa8EeuhuNAwh4oTmw>
HTH
Ian
Ian,
Is there any known issue with CLM DNG 7.0.2 such that the /rm/views/oslc.query method returns a 403 Unauthorized even when similar queries for /rm/folders are accepted with the same authentication credentials and cookies and when /rm/views?execute POST sparql queries are accepted with those sam credentials?
In all cases, the same user, Project Area, Component, Stream, and Folder are used to determine where the query should be scoped.
Only in CLM DNG 7.0.2 is the query rejected. The exact same HTTP request is honored by a CLM DNG 6.0.6 service.
We have extensive monitoring of over-the-wire traffic in place. Licenses are good. Logs are clean.
Just the /rm/views?oslc.query=true ... call is denied.
Here's the failed call as a curl command:
curl --location --request GET 'https://jas-clm702.someserver.com:9443/rm/views?oslc.query=true&projectURL=https://jas-clm702.someserver.com:9443/rm/process/project-areas/_KqzVoJl3Eeu2tZGJYqFOkw&oslc.prefix=oslc%3D%3Chttp://open-services.net/ns/core%23%3E&oslc.paging=true&oslc.pageSize=10' \
--header 'Accept: application/rdf+xml' \
--header 'OSLC-Core-Version: 2.0' \
--header 'vvc.configuration: https://jas-clm702.someserver.com:9443/rm/cm/stream/_rhyDgL-nEeudTeI6vIuG0A' \
--header 'Authorization: Basic bHZhbnphbmR0Omx2MTAx' \
--header 'Cookie: JSA_SESSION_IDENTITY=fd170f1b-7e7d-4b2e-bf80-39fa2532660c; JSESSIONID=0000NQD98RzITbLiKWZBX3mqauc:6cd9e53a-f785-41d8-84c7-be9a04c73e49; LtpaToken2=IKXrrRCormwadUg9yUwOWno2SPFJp+3NePySZ+o8MCPXMYAG2GNiMaAl1u8m2gtkQqbBOZO7JrD0ZhAguLe27R4lEYjzJCtsEeOd9z9R+s/EUmimmvb7btaNxcVgIMhsrnpkX31aYfprq/VUniSKAcCH361WD7/HeRUUpDxMIkRLyT75az/ufD8hazgNMuXKO1xo206bhBI/uS1eQ42UvKynm3vqr2xlwyVcPDkoG29ZLaK/YBsoCUAlwDlgc15HT7ebDWY56gJojL65u6khCweZgAgDirB+1tt1AWGlYAnSXsx00pUCd6mzHkxM5eVHrSopcztVtrLO8Ztb6DiSiWi5k6OojTn/ZvEj7E5pyyx39GOon4vixeQX0p6dpRe8'
Here is a query of the same context using the /rm/views service as hacked out of Chrome Dev Tools. This is accepted.
curl --location --request POST 'https://jas-clm702.someserver.com:9443/rm/views?execute=true&fullObject=false&net.jazz.jfs.owning-context=https://jas-clm702.someserver.com:9443/rm/rm-projects/_KqzVoJl3Eeu2tZGJYqFOkw/components/_KtSo8Jl3Eeu2tZGJYqFOkw&vvc.configuration=https://jas-clm702.someserver.com:9443/rm/cm/stream/_rhyDgL-nEeudTeI6vIuG0A' \ --header 'DoorsRP-Request-Type: private' \ --header 'Authorization: Basic bHZhbnphbmR0Omx2MTAx' \ --header 'Content-Type: text/plain' \ --header 'Cookie: JSA_SESSION_IDENTITY=b2d4a2c1-a518-45d5-aaf0-903cae722248; JSESSIONID=0000NQD98RzITbLiKWZBX3mqauc:6cd9e53a-f785-41d8-84c7-be9a04c73e49; LtpaToken2=IKXrrRCormwadUg9yUwOWno2SPFJp+3NePySZ+o8MCPXMYAG2GNiMaAl1u8m2gtkQqbBOZO7JrD0ZhAguLe27R4lEYjzJCtsEeOd9z9R+s/EUmimmvb7btaNxcVgIMhsrnpkX31aYfprq/VUniSKAcCH361WD7/HeRUUpDxMIkRLyT75az/ufD8hazgNMuXKO1xo206bhBI/uS1eQ42UvKynm3vqr2xlwyVcPDkoG29ZLaK/YBsoCUAlwDlgc15HT7ebDWY56gJojL65u6khCweZgAgDirB+1tt1AWGlYAnSXsx00pUCd6mzHkxM5eVHrSopcztVtrLO8Ztb6DiSiWi5k6OojTn/ZvEj7E5pyyx39GOon4vixeQX0p6dpRe8' \ --data-raw '<rdf:RDF <!-- whole lot of snipped SPARQL/RDF/XML for the query --> </rm:View> </rdf:RDF>'