diff --git a/source/java/org/alfresco/repo/domain/PropertyValue.java b/source/java/org/alfresco/repo/domain/PropertyValue.java index 654d8099dd..a0d21a3ccf 100644 --- a/source/java/org/alfresco/repo/domain/PropertyValue.java +++ b/source/java/org/alfresco/repo/domain/PropertyValue.java @@ -257,6 +257,7 @@ public class PropertyValue implements Cloneable, Serializable @Override protected ValueType getPersistedType(Serializable value) { + // NOTE: since 2.2.1, PropertyValue is only used by AVM (which does not natively support MLText, other than single/default string) if (value instanceof MLText) { MLText mlText = (MLText) value; @@ -269,7 +270,7 @@ public class PropertyValue implements Cloneable, Serializable return ValueType.STRING; } } - else if (value instanceof String) + else if ((value == null) || (value instanceof String)) { return ValueType.STRING; } diff --git a/source/java/org/alfresco/repo/domain/PropertyValueTest.java b/source/java/org/alfresco/repo/domain/PropertyValueTest.java index e8cb1ddbb9..c816d6a3ee 100644 --- a/source/java/org/alfresco/repo/domain/PropertyValueTest.java +++ b/source/java/org/alfresco/repo/domain/PropertyValueTest.java @@ -51,7 +51,7 @@ public class PropertyValueTest extends TestCase // single language MLText mlText = new MLText(Locale.FRENCH, "bonjour"); PropertyValue propertyValue = new PropertyValue(DataTypeDefinition.MLTEXT, mlText); - assertNotNull("MLText not persisted as a string", propertyValue.getStringValue()); + assertEquals("MLText not persisted as a string", "bonjour", propertyValue.getStringValue()); try { @@ -69,6 +69,16 @@ public class PropertyValueTest extends TestCase // NOTE: since 2.2.1, PropertyValue is only used by AVM (which does not natively support MLText, other than single/default string) } + // single language - empty string + mlText = new MLText(Locale.FRENCH, ""); + propertyValue = new PropertyValue(DataTypeDefinition.MLTEXT, mlText); + assertEquals("MLText not persisted as an empty string", "", propertyValue.getStringValue()); + + // single language - null string + mlText = new MLText(Locale.GERMAN, null); + propertyValue = new PropertyValue(DataTypeDefinition.MLTEXT, mlText); + assertNull("MLText not persisted as a null string", propertyValue.getStringValue()); + return null; } };