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
2 answers
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>"}
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.
Comments
David Honey
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Sep 01 '21, 4:22 a.m.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.
jyoti mishra
Sep 01 '21, 5:19 a.m.I am trying to link Requirement with Testcase,by using below code-