Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

OSLC API/Rest API to Programmatically link Testcase with Requirement or vice versa with GC Enabled

 Hello Everyone,


I would like to know the  OSLC API or reportable rest API to fetch link validity summary(ex-suspect) and link attached to test cases and requirements, from the project Area ,where GC Enabled .I would also like to know, how we can automatically link requirement with Testcase and vice-versa. I am able to link programmatically Requirement with Test case from the project Areas, where GC has not enabled, but when I am trying to link Requirement with Testcase, from the project area, where GC has enabled,is throwing forbidden Exception.

Error:- org.apache.http.client.HttpResponseException: Forbidden

Kindly help at the earliest.

Thanks and Regards,
Jyoti

0 votes

Comments
Please supply more specific information. For example:
  • Which resource are you trying to modify - a test case, or a requirement?
  • Which link (e.g. link type or RDF predicate URI) are you trying to add?
  • Details of the REST request (URI, headers, body) being made?
  • Details of the REST response (status, headers, body) you are getting back?
Note that in some cases, requests to DOORS Next might require an Oslc-Version=2.0 header. .

Regarding getting link validity information about a relationship between two versioned artifacts. This data is not a property of either the source resource or the target resource. Its meta data about the relationship itself and is stored in JTS rather than the application that owns the source or target resource. I'm not aware of any public REST API for this. My understanding is that this is currently regarded as a private API.

I am trying to link Requirement with Testcase,by using below code-

Example:-
HttpGet query = new HttpGet(requirementURL);
query.addHeader("Accept", "application/xml");query.addHeader("OSLC-Core-Version", "2.0");
InputSource source = new InputSource(response.getEntity().getContent());
Document doc = parse(source);
response.getEntity().consumeContent();
Header etag = response.getLastHeader("etag");
Element validatedBy = doc.createElement("oslc_rm:validatedBy");
req.appendChild(validatedBy ); 
Using put command to requirementURL for updating link.



2 answers

Permanent link

I do the following:


GET
URL = server_url>/rm/resources/<requirement_externalId>
HEADER = {"Content-Type": "application/rdf+xml", "OSLC-CORE-Version": "2.0"}

Add a validatedBy element to the xml returned
<oslc_rm:validatedBy rdf:resouce="<oslc url to testcase>"

POST
URL = server_url>/rm/resources/<requirement_externalId>
HEADER = {"Content-Type": "application/rdf+xml", "OSLC-CORE-Version": "2.0", If-Match": "<eTag from GET>"}

0 votes


Permanent link

A better method is not to directly changed serialized RDF (RDF/XML or Turtle) but use Jena to do the serialization/deserialization and then make changes to a Jena Model object. That way the code works with a variety of supported RDF media types and is likely to be more robust. Something like....

    HttpResponse response; // The response from executing the GET
    Model model = ModelFactory.createDefaultModel();
    model.read(httpResponse.getEntity().getContent(), null, "RDF/XML");
    Resource subject = model.createResource(uriOfResource);
    model.add(subject, model.createProperty(), model.createResource());
    RdfJsonEntity entity = new RdfJsonEntity(model, null, contentType, null);
    HttpPut put = new HttpPut(uriOfResource);
    put.addHeader(HttpConstants.CONTENT_TYPE, "application/rdf+xml");
    put.setEntity(entity);
The above can be made more general and support multiple RDF media types. For example, accept either RDF/XML or Turtle types.

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,927

Question asked: Sep 01 '21, 3:59 a.m.

Question was seen: 1,855 times

Last updated: Sep 02 '21, 2:12 p.m.

Confirmation Cancel Confirm