It's all about the answers!

Ask a question

How to create a OSLC query to download a artifact of type document in DNG


G C (498) | asked Mar 10 '21, 12:50 a.m.

 I need to build a query to download a artifact of type document. Can anyone help please.?

Accepted answer


permanent link
Ian Barnard (1.9k613) | answered Mar 11 '21, 5:54 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Mar 15 '21, 9:01 a.m.

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#">
        <dcterms:title rdf:parseType="Literal">Configuring Raspbian.docx</dcterms:title>
        <oslc:instanceShape rdf:resource="https://jazz.ibm.com:9443/rm/types/_osb4unX4Eeu2X8eF6GmMrw"/>
        <dcterms:identifier rdf:datatype="http://www.w3.org/2001/XMLSchema#string">106284</dcterms:identifier>
        <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

G C selected this answer as the correct answer

Comments
G C commented Mar 14 '21, 11:58 p.m.

Thanks.. Should I have to use any specific headers ? 


Ian Barnard commented Mar 15 '21, 9:00 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I added the headers to my answer 


G C commented Mar 16 '21, 1:48 a.m.

 Thanks.I tried this, and I am able to get the binary response only if I make the response type as blob.. how can I cod that in my code



Ian Barnard commented Mar 17 '21, 5:04 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I can't advise you how to write your code - it's just http, use StackOverflow?

3 other answers



permanent link
David Honey (1.8k17) | answered Mar 10 '21, 6:40 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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.

Comments
G C commented Mar 11 '21, 1:25 a.m. | edited Mar 11 '21, 1:26 a.m.

 I need to get the document for example a word document in response either in blob or in some other format.is it possible?


permanent link
Ian Barnard (1.9k613) | answered Mar 10 '21, 8:37 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Mar 11 '21, 3:58 a.m.

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):
Which decoded and with the parameters split across lines looks like:

GET /rm/views
?oslc.pageSize=200
&oslc.paging=true
&oslc.query=true

HTH
Ian


Comments
G C commented Mar 11 '21, 1:28 a.m.

I need to get the artifact of type file in OSLC response, it is not a custom attribute

 


-1
permanent link
Lonnie VanZandt (88517) | answered May 28 '21, 7:12 p.m.

 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>'


Comments
Ralph Schoon commented May 29 '21, 4:40 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

If you want to ask a question, please ask your own question instead of answering with your question on another persons question. You can convert your question here.  


Ralph Schoon commented May 29 '21, 1:33 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Also the second example uses the header

--header 'DoorsRP-Request-Type: private'

Which clearly indicates it is an internal, private API and not OSLC. This API is not supported.

Lonnie VanZandt commented May 29 '21, 10:44 p.m.

 Hi Ralph.


I guess I meant it as a Comment on your Answer and not as an Answer to the OP. Apologies about that misuse of this site’s conventions.

I comment on your Answer because we find that your advice was accurate for 6.0.6 (and many earlier point releases) but is no longer effective in 7.0.2 and you stated that it was applicable for 7.0.2 as well.

The Doors Private call is provided to illustrate that the outage for 7.0.2  more likely has to do with a change in 7.0.2 for that specific method (that handles the endpoint) than is about incorrect credentials or licenses. If it was just a matter of credentials or licenses, then the call to the other endpoint for the access request to the same information in the same destination for the same user on the same day would also get rejected for the same reason. (We know that the second one is not an OSLC call. Is it the case that OSLC calls require a different license or project role from calls made by the rm/web service? There are enough CLM license variants that that wouldn’t be surprising! ;-) )


Ian Barnard commented Jun 02 '21, 10:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 Hi Lonnie start a new question and I'll try to help.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.