Example working code for adding requirements to a module via OSLC?
I've been reading the various documentation, as listed below, in order to meet my requirements.
I can successfully create a module, create folders, add artifacts to the new folder and modify the name of the module. However, if I add artifacts to the module or remove artifacts (after adding them manually) by manipulating the oscl_rm:uses tags I get a bad request error.
The workshop is a great resource to cover OSLC functions, but it doesn't unfortunately, have an example that does this task.
Does anyone have some example code that they could post for this?
I've used the following article:
Also tried this following in place of using the above for module structure changes:
Thanks,
Andy.
2 answers
AFAICT the documentation for using the Module Structure API is correct apart from two conflicting statements about the headers on the PUT: the correct statement says to use If-Match with the etag header from the GET response. The incorrect statement says to use an etag header on the PUT.
NOTE it is only possible to modify the structure from 6.0.6 onwards.
The headers you use are critical - use exactly what the docs say exactly (these are case-sensitive!) and it works.
The overview is here: https://jazz.net/wiki/bin/view/Main/DNGModuleApiOverview
This links to:
1. The 'specification' https://jazz.net/wiki/bin/view/Main/DNGModuleAPI
2. Three scenarios for usage:
a. Discover a module and its associated structure https://jazz.net/wiki/bin/view/Main/DNGModuleAPI
b. Add a new / existing Artifact to a Module. https://jazz.net/wiki/bin/view/Main/DNGModuleApiScenario2
c. Manipulation of Module structure (remove, re-order, re-parent). https://jazz.net/wiki/bin/view/Main/DNGModuleApiScenario3
So the sequence might look like:
-
Find the module URI -e.g. by OSLC Query, or by manually finding the module an dselecting Sahre Link To Artifact., e.g. https://jazz.ibm.com:9443/rm/resources/_OAAJRdcLEeqXpuBdEolY7w?oslc_config.context=https%3A%2F%2Fjazz.ibm.com%3A9443%2Frm%2Fcm%2Fstream%2F_NMu5RtcLEeqXpuBdEolY7w
- The module URL is the first part of this up to ? - i.e. https://jazz.ibm.com:9443/rm/resources/_OAAJRdcLEeqXpuBdEolY7w
-
GET from this url with only headers:
-
Accept: application/rdf+xml
-
DOORS-RP-Request-Type: public 2.0
NOTE yes that's "public" with a lower case p - P won't work!
-
This returns the RDF with an entry like this (prefix j.1 is http://jazz.net/ns/rm/dng/module#
<j.1:structure rdf:resource="https://jazz.ibm.com:9443/rm/resources/_OAAJRdcLEeqXpuBdEolY7w/structure"/>NOTE if what you get has any <oslc_rm:uses ...> tags you haven't done the above right - no point in proceeding beyond here until you see the structure tag
-
The structure URL is e.g. https://jazz.ibm.com:9443/rm/resources/_OAAJRdcLEeqXpuBdEolY7w/structure
-
GET from this URL with headers same as the previous request
The structure starts like this:<j.0:Binding rdf:about="https://jazz.ibm.com:9443/rm/resources/_OAAJRdcLEeqXpuBdEolY7w/structure"><j.0:childBindings rdf:parseType="Collection"><j.0:Binding rdf:about="https://jazz.ibm.com:9443/rm/resources/_OAvwIdcLEeqXpuBdEolY7w"><j.0:isHeading rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</j.0:isHeading><oslc_config:component rdf:resource="https://jazz.ibm.com:9443/rm/cm/component/_NMJDYNcLEeqXpuBdEolY7w"/><j.0:boundArtifact rdf:resource="https://jazz.ibm.com:9443/rm/resources/_OCh41tcLEeqXpuBdEolY7w"/><j.0:module rdf:resource="https://jazz.ibm.com:9443/rm/resources/_OAAJRdcLEeqXpuBdEolY7w"/><j.0:childBindings rdf:parseType="Collection"><j.0:Binding rdf:about="https://jazz.ibm.com:9443/rm/resources/_OAvwItcLEeqXpuBdEolY7w">...
-
Modify the structure, e.g. removing an artifact etc. as per https://jazz.net/wiki/bin/view/Main/DNGModuleApiScenario2 and https://jazz.net/wiki/bin/view/Main/DNGModuleApiScenario3
-
PUT the structure with the same headers as previous, plus:
If-Match: (copy the complete etag header from the response to the GET, don't decode it or remove " or modify it in any way - NOTE the documentation https://jazz.net/wiki/bin/view/Main/DNGModuleApiOverview#IfMatch says submit using the etag header on the put but this is wrong - you must use If-Match, as it says here https://jazz.net/wiki/bin/view/Main/DNGModuleApiScenario2
-
You'll get a 202 Accepted response - use the Location header in the response to get the task tracker URL
-
Poll the task tracker URL until you get 200 response with
oslc_auto:stateproperty NOT set tooslc_auto:inProgressand theoslc_auto:verdictproperty NOT set tooslc_auto:unavailable -
The final task tracker response indicating no longer in progress and with a verdict available, the response has dcterms:references with a URL of the status.
I suggest you test this out using a browser REST client.
HTHIan
Comments
The Module Structure API is the way to modify module structure. - Note this is only provided on >=6.0.5
I don't have example code - GET/PUT should be used to first retrieve the structure then update it.
Comments
1 vote
showing 5 of 9
show 4 more comments