DNG 6.2: Cerating folder in DNG using OSLC
I have been using this code to create the folder in DNG 6.0 but it is not working after we updated to DNG 6.2, getting 500 response code.
String targetProject = "?projectURL=" + webContextUrl + "/process/project-areas/" + projectID;
String folderCreationFactory = webContextUrl + "/folders" + targetProject;
// Create the body content
StringBuffer folderBody = new StringBuffer();
folderBody
.append("<rdf:RDF\n")
.append("xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns%23\"\n")
.append("xmlns:dcterms=\"http://purl.org/dc/terms/\"\n")
.append("xmlns:oslc=\"http://open-services.net/ns/core%23\"\n")
.append("xmlns:nav=\"http://jazz.net/ns/rm/navigation%23\">\n")
.append("<nav:folder rdf:about=\"\">\n")
.append("<dcterms:title>" + folderName + "</dcterms:title>\n")
.append("<nav:parent rdf:resource=\"" + parentfolder + "\"/>").append("</nav:folder>\n")
.append("</rdf:RDF>");
final String content = folderBody.toString();
// Post to the Requirement Factory
HttpPost post = new HttpPost(folderCreationFactory);
post.addHeader("Accept", "application/xml");
post.addHeader("Content-Type", "application/xml");
post.addHeader("OSLC-Core-Version", "2.0");
post.setEntity(new StringEntity(content, HTTP.UTF_8));
HttpResponse sendPostForSecureDocument = HttpUtils.sendPostForSecureDocument(webContextUrl, post, null, null, client.getHttpClient());
folderLocation = sendPostForSecureDocument.getFirstHeader("Location");
sendPostForSecureDocument.getEntity().consumeContent();
Can anyone help me to resolve the issue. Thanks in advance.
String targetProject = "?projectURL=" + webContextUrl + "/process/project-areas/" + projectID;
String folderCreationFactory = webContextUrl + "/folders" + targetProject;
// Create the body content
StringBuffer folderBody = new StringBuffer();
folderBody
.append("<rdf:RDF\n")
.append("xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns%23\"\n")
.append("xmlns:dcterms=\"http://purl.org/dc/terms/\"\n")
.append("xmlns:oslc=\"http://open-services.net/ns/core%23\"\n")
.append("xmlns:nav=\"http://jazz.net/ns/rm/navigation%23\">\n")
.append("<nav:folder rdf:about=\"\">\n")
.append("<dcterms:title>" + folderName + "</dcterms:title>\n")
.append("<nav:parent rdf:resource=\"" + parentfolder + "\"/>").append("</nav:folder>\n")
.append("</rdf:RDF>");
final String content = folderBody.toString();
// Post to the Requirement Factory
HttpPost post = new HttpPost(folderCreationFactory);
post.addHeader("Accept", "application/xml");
post.addHeader("Content-Type", "application/xml");
post.addHeader("OSLC-Core-Version", "2.0");
post.setEntity(new StringEntity(content, HTTP.UTF_8));
HttpResponse sendPostForSecureDocument = HttpUtils.sendPostForSecureDocument(webContextUrl, post, null, null, client.getHttpClient());
folderLocation = sendPostForSecureDocument.getFirstHeader("Location");
sendPostForSecureDocument.getEntity().consumeContent();
Can anyone help me to resolve the issue. Thanks in advance.
2 answers
Able to solve the issue just by replacing %23 with #. It sis working on DNG 6.2 not sure %23 not is working when it was fine with 6.0.
Comments
Naveen Tyagi
Sep 30 '16, 6:23 a.m.I tried doing same with poster but getting 404 error.
<err:errorStatus rdf:datatype="http://www.w3.org/2001/XMLSchema#long"
>403</err:errorStatus>
<err:errorMessage rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>Forbidden</err:errorMessage>
<err:detailedMessage rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>CRRRS4142E getInternalRequestHandlerService(context) returned null. This error used to report 'The requested service requires a private header'.</err:detailedMessage>
</rdf:Description>
</rdf:RDF>