How to create a OSLC query to download a artifact of type document in DNG
I need to build a query to download a artifact of type document. Can anyone help please.? |
Accepted answer
Ian Barnard (2.3k●7●14)
| 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):
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:
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 ? 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 I can't advise you how to write your code - it's just http, use StackOverflow? |
3 other answers
David Honey (1.8k●1●7)
| 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 I need to get the document for example a word document in response either in blob or in some other format.is it possible? |
Ian Barnard (2.3k●7●14)
| 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.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
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 |
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' \ 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 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.
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! ;-) )
Hi Lonnie start a new question and I'll try to help. |
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.