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

How to import ReqIF file in DNG using OSLC API?

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

0 votes



5 answers

Permanent link

 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.

0 votes

Comments

 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

 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

0 votes


Permanent link

 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>


0 votes

Comments

 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

 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;
}

0 votes


Permanent link

 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

0 votes

Comments

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

 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

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

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

 Hi,


That is the only way I know.

Best Regards.

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
× 12,019
× 38

Question asked: Jun 12 '18, 9:56 a.m.

Question was seen: 4,688 times

Last updated: Aug 13 '18, 7:58 a.m.

Related questions
Confirmation Cancel Confirm