From 9079ce1aac20ed8d8f2d99b0e11d2ea7d2cc7742 Mon Sep 17 00:00:00 2001 From: Gavin Cornwell Date: Tue, 14 Feb 2006 15:05:45 +0000 Subject: [PATCH] If an empty string value is passed for a number property it is set to null git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2372 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../web/bean/DocumentPropertiesBean.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/java/org/alfresco/web/bean/DocumentPropertiesBean.java b/source/java/org/alfresco/web/bean/DocumentPropertiesBean.java index 2b7eca419..e172cc3df 100644 --- a/source/java/org/alfresco/web/bean/DocumentPropertiesBean.java +++ b/source/java/org/alfresco/web/bean/DocumentPropertiesBean.java @@ -33,7 +33,9 @@ import org.alfresco.config.Config; import org.alfresco.config.ConfigService; import org.alfresco.model.ContentModel; import org.alfresco.service.ServiceRegistry; +import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.cmr.model.FileExistsException; import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.repository.AssociationRef; @@ -177,6 +179,24 @@ public class DocumentPropertiesBean // make sure the property is represented correctly Serializable propValue = (Serializable)props.get(propName); + + // check for empty strings when using number types, set to null in this case + if ((propValue != null) && (propValue instanceof String) && + (propValue.toString().length() == 0)) + { + PropertyDefinition propDef = this.dictionaryService.getProperty(qname); + if (propDef != null) + { + if (propDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE) || + propDef.getDataType().getName().equals(DataTypeDefinition.FLOAT) || + propDef.getDataType().getName().equals(DataTypeDefinition.INT) || + propDef.getDataType().getName().equals(DataTypeDefinition.LONG)) + { + propValue = null; + } + } + } + properties.put(qname, propValue); }