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.
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,
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, 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