It's all about the answers!

Ask a question

How to import ReqIF file in DNG using OSLC API?


Pavithra Shivalingappa (128220) | asked Jun 12 '18, 9:56 a.m.

Unable to import ReqIF file after getting the ReqIF package URL. How to use DNG ReqIF API


Below is the request.


METHOD: POST

REQUEST HEADER:
Accept: application/rdf+xml
Oslc-Core-Version: 2.0
Content-Type: application/rdf+xml

REQUEST BODY:

<rmReqIF:ReqIFImport rdf:about="http://jazz.net/ns/rm/dng/reqif#ReqIFImport">





</rmReqIF:ReqIFImport>
</rdf:RDF>

HTTP RESPONSE: 202. Gives the location url.
If i hit the location url then the status of task is incomplete.

<rm:taskCompletionStatus rdf:datatype="http://www.w3.org/2001/XMLSchema#string">FATAL_ERROR</rm:taskCompletionStatus>

<rm:taskPhase rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Completed</rm:taskPhase>
Please comment if anyone knows solution for this above question.

Thanks & Regards
Pavithra S

5 answers



permanent link
Gabriel Ruelas (1.1k13) | answered Jun 13 '18, 10:56 a.m.

 Hi,


Looks like you are using an internal representation ( see the rmReqIF namespace ).

You have to follow the spec described in : https://jazz.net/wiki/bin/view/Main/DNGReqIF

For OSLC ReqIF Import you should specify :
dng_reqif:package Exactly-onetrueResourceReference dng_reqif:ReqIFPackage Specifies a ReqIF Package to be imported.
Hope that helps.


Comments
Pavithra Shivalingappa commented Jun 13 '18, 11:09 a.m.

 Is the request URL correct? I have included the ReqIF package to be imported  in the request body already. But still there is an error.


permanent link
Gabriel Ruelas (1.1k13) | answered Jun 13 '18, 11:40 a.m.

 Hi,

No , you should not be using rmReqIF, use dng_reqIf ("http://jazz.net/ns/rm/dng/reqif#") name space and the format in the doc https://jazz.net/wiki/bin/view/Main/DNGReqIF.
dng_reqif:package


Comments
Pavithra Shivalingappa commented Jun 13 '18, 11:52 a.m. | edited Jun 13 '18, 11:56 a.m.

permanent link
Gabriel Ruelas (1.1k13) | answered Jun 13 '18, 3:43 p.m.

 Hi,

 Try following for version previous to 606:
<rdf:RDF
    xmlns:dng_reqif="http://jazz.net/ns/rm/dng/reqif#">
  <dng_reqif:package>
    <dng_reqif:definition rdf:resource="https://server.ip:port/rm/reqif/descriptors/_VceSYW9BEeiwWMPA5cp7jg"/>
  </dng_reqif:package>
</rdf:RDF>

Try following for versions 606 and up.

<rdf:RDF
    <dng_reqif:ReqIFImport>
         <dng_reqif:package rdf:resource="https://server:port/rm/reqif/descriptors/_uW8p0yMMEeimytylMhrqug"/>
   </dng_reqif:ReqIFImport>
</rdf:RDF>



Comments
Pavithra Shivalingappa commented Jun 14 '18, 3:43 a.m.

 Hi Gabriel,

   Tried in both ways but still getting 201 as http response followed by 302 error code.
My clm version is 6.0.5. 
Request URL: https://server:port/rm/reqif_oslc/import?componentURI=https://server:port/rm/cm/component/_i_U5YD4rEeiS8byYflf27Q
Request Headers: OSLC-Core-Version :2.0, Accept & Content-Type : application/rdf+xml, Configuration-Context : stream url
What might be missing in the request? Could u pls suggest.

Regards,
Pavithra S



permanent link
Gabriel Ruelas (1.1k13) | answered Jun 14 '18, 9:45 a.m.

 Hi, I just installed a 605 GA and tested my sample program and it works fine. It is using the package definition :

<rdf:RDF
    xmlns:dng_reqif="http://jazz.net/ns/rm/dng/reqif#">
  <dng_reqif:package>
    <dng_reqif:definition rdf:resource="https://server.ip:port/rm/reqif/descriptors/_VceSYW9BEeiwWMPA5cp7jg"/>
  </dng_reqif:package>
</rdf:RDF>

This is the method I am using :
private static String importReqIfPackage(String importFactoryUrl, String reqIfpackageUrl, JazzFormAuthClient client) throws ClientProtocolException, IOException, UnsupportedOperationException, InterruptedException {
String returnMessage = "Unexpected error while trying to import the ReqIf package";
HttpPost importRequest = new HttpPost(importFactoryUrl);
importRequest.addHeader("OSLC-Core-Version", "2.0");
importRequest.addHeader("Content-Type", "application/rdf+xml");
// Sample model used
/<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
<dng_reqif:package rdf:about="">
<dng_reqif:definition rdf:resource="{definition}"/>
</dng_reqif:package>
</rdf:RDF>/
Model model = ModelFactory.createDefaultModel();
model.setNsPrefix("dng_reqif", "http://jazz.net/ns/rm/dng/reqif#");
Resource reqIfImportResource = model.createResource();
reqIfImportResource.addProperty(RDF.type, model.createResource("http://jazz.net/ns/rm/dng/reqif#"+ "package"));
reqIfImportResource.addProperty(model.createProperty("http://jazz.net/ns/rm/dng/reqif#" + "definition"), model.createResource(reqIfpackageUrl));
StringWriter writer = new StringWriter();
model.write(writer, "RDF/XML-ABBREV");
BasicHttpEntity entity = new BasicHttpEntity();
String toSend= writer.toString();
byte [] bytes = toSend.getBytes("UTF-8");
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
entity.setContent(bis); 
entity.setContentLength(bytes.length);
entity.setContentType("application/rdf+xml");
importRequest.setEntity(entity);
HttpResponse postImportResponse = client.getHttpClient().execute(importRequest);
if ( postImportResponse != null ) {
int statusCode = postImportResponse.getStatusLine().getStatusCode();
if ( statusCode == 202 ) {
Header taskHeader = postImportResponse.getFirstHeader("Location");
postImportResponse.getEntity().consumeContent();
// Lets wait for the task to complete
if ( taskHeader != null ) {
String taskUrl = taskHeader.getValue();
String resultInfo = waitForTaskTraker(taskUrl, 10, client);
if ( resultInfo != null ) {
returnMessage = "Task ended with code :" + resultInfo;
}
}
}
return returnMessage;
}


permanent link
Gabriel Ruelas (1.1k13) | answered Jun 14 '18, 9:52 a.m.

 Just add the configuration context header:

importRequest.addHeader("Configuration-Context", "https://server.ip:9443/rm/cm/stream/_nJd8gG_ZEeiFntPvECNjhg");

Just tested on different cfgs and it works fine


Comments
Pavithra Shivalingappa commented Jun 18 '18, 10:09 a.m.

Hi Gabriel, 

   Now I'am testing with 6.0.5 server and its working fine. Later, I will test  with different versions .
Thanks for your support Gabriel. 
One more clarification,  in the above importReqIfPackage(....) method, you have called waitForTaskTraker(....) . What it does? It waits for ten milliseconds and then fetches the status?

Regards,
Pavithra s


Gabriel Ruelas commented Jun 18 '18, 11:24 a.m.

 The pots returns a task tracker URL, it is used by that method to do gets on it until the task is done. 


You can see that behavior when the RDNG UI issues a import CSV.

Best regards


Pavithra Shivalingappa commented Jun 18 '18, 11:41 a.m.

Any website / links to refer to know how to use it ?


Pavithra Shivalingappa commented Aug 11 '18, 9:23 a.m.

Hi Gabriel,
    The task tracker URL shows the state as complete and verdict as passed . But when i check the report , it shows errors and file is not imported successfully. How can i track  this?
Currently we have dcterms:references  to view the report.
Do we have any option to track whether the file was imported successfully or not without checking the report ?

Regards,
Pavithra


Gabriel Ruelas commented Aug 13 '18, 7:58 a.m.

 Hi,


That is the only way I know.

Best Regards.

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.