Fix for ALF-1501: regex constraint on text field should allow blank if mandatory not set

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19911 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2010-04-20 10:49:59 +00:00
parent 703aeeaeb9
commit 0a85d1f52f

View File

@@ -1056,13 +1056,29 @@ public abstract class ContentModelFormProcessor<ItemType, PersistType> extends
else if ((value instanceof String) && ((String) value).length() == 0) else if ((value instanceof String) && ((String) value).length() == 0)
{ {
// make sure empty strings stay as empty strings, // make sure empty strings stay as empty strings,
// everything else // everything else should be represented as null
// should be represented as null if (!propDef.getDataType().getName().equals(DataTypeDefinition.TEXT) &&
if (!propDef.getDataType().getName().equals(DataTypeDefinition.TEXT) !propDef.getDataType().getName().equals(DataTypeDefinition.MLTEXT))
&& !propDef.getDataType().getName().equals(DataTypeDefinition.MLTEXT))
{ {
value = null; value = null;
} }
else
{
// if the text property has a regex constraint set the empty
// string to null otherwise the integrity checker will reject it
List<ConstraintDefinition> constraints = propDef.getConstraints();
if (constraints != null && constraints.size() > 0)
{
for (ConstraintDefinition constraintDef : constraints)
{
if ("REGEX".equals(constraintDef.getConstraint().getType()))
{
value = null;
break;
}
}
}
}
} }
// add the property to the map // add the property to the map