I am trying to set the Plain Text of an artifact in RRC using the OSLC rest API and the creation does not set the plain text at all.
![]()
Following is the code snippet which I am trying to use to set the plain text in RRC rich text editor
String title = "MyDocument7"; String description = "This is a test document created"; //Note: primary text must be in xhtml compliant format String primaryText = "<div xmlns=\"http://www.w3.org/1999/xhtml\" >Test Document</div>"; //Create a requirement request - Note the URL is "" because the requirement is not yet created RequirementRequest req = new RequirementRequest(server, "", shapeURL); req.setDcTitle(title); req.setDcDescription(description); //Add any internal properties to request by getting property URI from shape String primaryTextPropURI = findPropertyByTitle(doc, "Primary Text"); System.out.println("printing the property URI ... "+primaryTextPropURI); req.addRMLiteralProperty(primaryTextPropURI, primaryText); //System.out.println("getting the content based on URI "+req.getPrimaryText(primaryTextPropURI)); Now the artifact does get created correctly but the primaryTextPropURI does not have the correct value. The return from the method findPropertyByTitle is null. The method conatins the following snippet: protected String findPropertyByTitle(Document doc, String title) throws Exception { String propertyDefinition = "//oslc:Property[oslc:name=\"" + title +"\"]/oslc:propertyDefinition/@rdf:resource"; XPath xpathNamespace = getXpathNamespace(); Node node = (Node) xpathNamespace.evaluate(propertyDefinition, doc, XPathConstants.NODE); if(node != null){ return node.getTextContent(); } return null; } Can someone help understand why this does not work. |
Accepted answer
![]()
Hi,
If you are using RRC 4.0 or later version then you have to modify your routine as follows : protected String findPropertyByTitle(Document doc, String title) throws Exception { // based on last Resource shapes changes we need to use dcterms:title to get the property name String propertyDefinition = null; if (this.version >= 4.0f ) { propertyDefinition = "//oslc:Property[dcterms:title=\"" + title +"\"]/oslc:propertyDefinition/@rdf:resource"; } else { propertyDefinition = "//oslc:Property[oslc:name=\"" + title +"\"]/oslc:propertyDefinition/@rdf:resource"; } XPath xpathNamespace = getXpathNamespace(); Node node = (Node) xpathNamespace.evaluate(propertyDefinition, doc, XPathConstants.NODE); if(node != null){ return node.getTextContent(); } return null; } This is because there was a change in the way the primary Text information was changed and now client code must use dcterms:title instead of oslc:name. Samanwita Majumdar selected this answer as the correct answer
|
One other answer
![]()
Thanks Gab,
This works fine for me. |
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.