From: Aron Roberts Date: Fri, 4 Nov 2011 01:50:01 +0000 (+0000) Subject: CSPACE-4533,CSPACE-3231: Changed the way that empty strings are handled in services... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=187550673cb887ab63533343ff53bb64d7746a0b;p=tmp%2Fjakarta-migration.git CSPACE-4533,CSPACE-3231: Changed the way that empty strings are handled in services request payloads. Now, for non-date values, these result in null values being passed to Nuxeo, rather than empty string values. --- diff --git a/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java b/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java index 7ad430654..b22c39a4c 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java @@ -860,7 +860,7 @@ public class DocumentUtils { return false; } } - + /** * Insert multi values. * @@ -1189,7 +1189,12 @@ public class DocumentUtils { } } } else { - result = type.decode(element.getText()); + String textValue = element.getText(); + if (textValue != null && textValue.trim().isEmpty()) { + result = null; + } else { + result = type.decode(textValue); + } } } else if (type.isListType()) { ListType ltype = (ListType) type; diff --git a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java index a2619f28d..2a1065698 100644 --- a/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java +++ b/services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java @@ -476,8 +476,10 @@ public class MovementServiceTest extends AbstractServiceTestImpl { } // Check selected fields in the updated common part. - Assert.assertEquals(updatedMovementCommon.getNormalLocation(), - movementCommon.getNormalLocation(), "Data in updated object did not match submitted data."); + + // By submitting an empty string in the update payload, the value of this field + // in the object created from the response payload will be null. + Assert.assertNull(updatedMovementCommon.getNormalLocation(), "Data in updated object did not match submitted data."); if(logger.isDebugEnabled()){ logger.debug("Normal location after update=|" + updatedMovementCommon.getNormalLocation() + "|"); }