From 210f6ed95c325099e0bab591b6b6e6822b8fc768 Mon Sep 17 00:00:00 2001 From: Sanjay Dalal Date: Fri, 30 Oct 2009 06:43:27 +0000 Subject: [PATCH] CSPACE-524 empty string is treated as it is. more checks are needed to see how non-string values are treated. M collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java M common/src/main/java/org/collectionspace/services/common/repository/DocumentUtils.java --- .../test/CollectionObjectServiceTest.java | 1 + .../common/repository/DocumentUtils.java | 28 +++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java index 819d2be50..7301939a3 100644 --- a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java +++ b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java @@ -595,6 +595,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { collectionObject.setObjectNumber(objectNumber); collectionObject.setObjectName(objectName); + collectionObject.setAge(""); //test for null string MultipartOutput multipart = new MultipartOutput(); OutputPart commonPart = multipart.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE); diff --git a/services/common/src/main/java/org/collectionspace/services/common/repository/DocumentUtils.java b/services/common/src/main/java/org/collectionspace/services/common/repository/DocumentUtils.java index 25608423b..a38670b35 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/repository/DocumentUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/repository/DocumentUtils.java @@ -21,7 +21,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.collectionspace.services.common.repository; import java.io.InputStream; @@ -45,11 +44,11 @@ import org.w3c.dom.NodeList; import org.w3c.dom.Text; /** -* DocumentUtils is a collection of utilities related to document management -* -* $LastChangedRevision: $ -* $LastChangedDate: $ -*/ + * DocumentUtils is a collection of utilities related to document management + * + * $LastChangedRevision: $ + * $LastChangedDate: $ + */ public class DocumentUtils { /** @@ -93,12 +92,19 @@ public class DocumentUtils { Node node = (Node) children.item(i); if(node.getNodeType() == Node.ELEMENT_NODE){ Node cnode = node.getFirstChild(); - if(cnode.getNodeType() != Node.TEXT_NODE){ - continue; + if(cnode == null){ + //if element is present but no value, set to "" + //FIXME what about non-string types? + objectProps.put(node.getNodeName(), ""); + }else{ + if(cnode.getNodeType() != Node.TEXT_NODE){ + continue; + } + Node textNode = (Text) cnode; + //FIXME what about other native xml types? + objectProps.put(node.getNodeName(), + textNode.getNodeValue()); } - Node textNode = (Text) cnode; - objectProps.put(node.getNodeName(), - textNode.getNodeValue()); } } return objectProps; -- 2.47.3