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
Configuration-Context: https://localhost:9443/rm/cm/stream/_kFjJQG1MEeiVzuQmixXetA
REQUEST BODY:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rm="http://www.ibm.com/xmlns/rdm/rdf/" xmlns:rmReqIF="http://www.ibm.com/xmlns/rdm/reqif/" >
<rmReqIF:ReqIFImport rdf:about="http://jazz.net/ns/rm/dng/reqif#ReqIFImport">
<rmReqIF:importToProject rdf:resource="https://localhost:9443/rm/rm-projects/_yjdR4DjWEeigONvxHDayiw/components/_0ap4AGryEeiVzuQmixXetA"></rmReqIF:importToProject>
<rmReqIF:isMigration rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</rmReqIF:isMigration>
<rmReqIF:reqifPackageURI rdf:resource="https://localhost:9443/rm/reqif/_gNbWQm1OEeiVzuQmixXetA"></rmReqIF:reqifPackageURI>
<rmReqIF:defaultFolderForNewResources rdf:resource="https://si-z0rl9.si.de.bosch.com:9443/rm/folders/_0bjP4WryEeiVzuQmixXetA"></rmReqIF:defaultFolderForNewResources>
</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
![]() 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 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.
<rmReqIF:reqifPackageURI rdf:resource="https://localhost:9443/rm/reqif/_gNbWQm1OEeiVzuQmixXetA"></rmReqIF:reqifPackageURI>
|
![]() 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 Hi, I have tried same. I'm getting 201 created but the file is not imported in Project Area.
Request Body:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dng_reqif="http://jazz.net/ns/rm/dng/reqif#"
xmlns:rmTypes="http://www.ibm.com/xmlns/rdm/types/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:oslc_config="http://open-services.net/ns/config#" xmlns:oslc_rm="http://open-services.net/ns/rm#" xmlns:dng_task="http://jazz.net/ns/rm/dng/task#" xmlns:oslc_auto="http://open-services.net/ns/auto#">
<dng_reqif:ReqIFImport>
<dng_reqif:ReqIFPackage rdf:about="https://localhost:9443/rm/reqif/descriptors/_BD1vtG8dEeiVzuQmixXetA">
</dng_reqif:ReqIFPackage>
</dng_reqif:ReqIFImport>
|
![]() Hi,
Try following for version previous to 606:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
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
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dng_reqif="http://jazz.net/ns/rm/dng/reqif#">
<dng_reqif:ReqIFImport>
<dng_reqif:package rdf:resource="https://server:port/rm/reqif/descriptors/_uW8p0yMMEeimytylMhrqug"/>
</dng_reqif:ReqIFImport>
</rdf:RDF>
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
|
![]() 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:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
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
xmlns:dng_reqif="http://jazz.net/ns/rm/dng/reqif#"
<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#");
model.setNsPrefix("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
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;
}
|
![]() 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 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,
Hi,
That is the only way I know.
Best Regards.
|
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.