Applied fix from trunk for revision: 1855403

===

Fixed: simpleTypeConvert always returns Null for Document, Document Type and Notation Node 
(OFBIZ-10832)

As per the code, getTextContent() method is used get text content of the node and its descendants but the node.getTextContent() always return Null for the following Node type
DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE [1]

Since we can't get the text value of Document, Document Type and Notation Node, thus simply return the same object.

[1] https://docs.oracle.com/javase/7/docs/api/org/w3c/dom/Node.html#getTextContent()

Thanks: Deepak Dixit for reviewing the code.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release17.12@1855410 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Swapnil Mane
2019-03-13 12:39:06 +00:00
parent 4d3bef9c25
commit f958cc6cdd
@@ -513,6 +513,17 @@ public class ObjectType {
}
if (obj instanceof Node) {
Node node = (Node) obj;
/* We can't get the text value of Document, Document Type and Notation Node,
* thus simply returning the same object from simpleTypeOrObjectConvert method.
* Please refer to OFBIZ-10832 Jira and
* https://docs.oracle.com/javase/7/docs/api/org/w3c/dom/Node.html#getTextContent() for more details.
*/
short nodeType = node.getNodeType();
if (Node.DOCUMENT_NODE == nodeType || Node.DOCUMENT_TYPE_NODE == nodeType || Node.NOTATION_NODE == nodeType) {
return obj;
}
String nodeValue = node.getTextContent();
if ("String".equals(type) || "java.lang.String".equals(type)) {
return nodeValue;