diff --git a/source/java/org/alfresco/repo/content/ContentTestSuite.java b/source/java/org/alfresco/repo/content/ContentTestSuite.java index 9304952579..9dcf5b038a 100644 --- a/source/java/org/alfresco/repo/content/ContentTestSuite.java +++ b/source/java/org/alfresco/repo/content/ContentTestSuite.java @@ -60,7 +60,6 @@ public class ContentTestSuite extends TestSuite { TestSuite suite = new TestSuite(); - suite.addTestSuite(ContentStoreCleanerTest.class); suite.addTestSuite(ContentStoreCleanerTest.class); suite.addTestSuite(FileContentStoreTest.class); suite.addTestSuite(NoRandomAccessFileContentStoreTest.class); diff --git a/source/java/org/alfresco/repo/domain/PropertyValue.java b/source/java/org/alfresco/repo/domain/PropertyValue.java index 531e33dadb..4954c2989d 100644 --- a/source/java/org/alfresco/repo/domain/PropertyValue.java +++ b/source/java/org/alfresco/repo/domain/PropertyValue.java @@ -34,10 +34,13 @@ import java.util.Locale; import java.util.Map; import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.repo.attributes.Attribute; +import org.alfresco.repo.attributes.AttributeConverter; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentData; +import org.alfresco.service.cmr.repository.MLText; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.Path; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; @@ -49,8 +52,6 @@ import org.apache.commons.logging.LogFactory; /** * Immutable property value storage class. - *
- * The
*
* @author Derek Hulley
*/
@@ -160,6 +161,18 @@ public class PropertyValue implements Cloneable, Serializable
return DefaultTypeConverter.INSTANCE.convert(Date.class, value);
}
},
+ DB_ATTRIBUTE
+ {
+ /** class that is able to convert from persisted attributes to normal attributes */
+ private AttributeConverter attributeConverter = new AttributeConverter();
+
+ @Override
+ Serializable convert(Serializable value)
+ {
+ Attribute attribute = DefaultTypeConverter.INSTANCE.convert(Attribute.class, value);
+ return attributeConverter.toPersistent(attribute);
+ }
+ },
SERIALIZABLE
{
@Override
@@ -168,6 +181,20 @@ public class PropertyValue implements Cloneable, Serializable
return value;
}
},
+ MLTEXT
+ {
+ @Override
+ protected ValueType getPersistedType(Serializable value)
+ {
+ return ValueType.DB_ATTRIBUTE;
+ }
+
+ @Override
+ Serializable convert(Serializable value)
+ {
+ return DefaultTypeConverter.INSTANCE.convert(MLText.class, value);
+ }
+ },
CONTENT
{
@Override
@@ -292,6 +319,9 @@ public class PropertyValue implements Cloneable, Serializable
}
/**
+ * Converts a value to this type. The implementation must be able to cope with any legitimate
+ * source value.
+ *
* @see DefaultTypeConverter.INSTANCE#convert(Class, Object)
*/
abstract Serializable convert(Serializable value);
@@ -389,6 +419,14 @@ public class PropertyValue implements Cloneable, Serializable
{
return ValueType.VERSION_NUMBER;
}
+ else if (value instanceof Attribute)
+ {
+ return ValueType.DB_ATTRIBUTE;
+ }
+ else if (value instanceof MLText)
+ {
+ return ValueType.MLTEXT;
+ }
else
{
// type is not recognised as belonging to any particular slot
@@ -412,8 +450,7 @@ public class PropertyValue implements Cloneable, Serializable
valueTypesByPropertyType.put(DataTypeDefinition.CATEGORY, ValueType.NODEREF);
valueTypesByPropertyType.put(DataTypeDefinition.CONTENT, ValueType.CONTENT);
valueTypesByPropertyType.put(DataTypeDefinition.TEXT, ValueType.STRING);
- // TODO: Re-examine storage of MLTEXT data type
- valueTypesByPropertyType.put(DataTypeDefinition.MLTEXT, ValueType.SERIALIZABLE);
+ valueTypesByPropertyType.put(DataTypeDefinition.MLTEXT, ValueType.MLTEXT);
valueTypesByPropertyType.put(DataTypeDefinition.NODE_REF, ValueType.NODEREF);
valueTypesByPropertyType.put(DataTypeDefinition.CHILD_ASSOC_REF, ValueType.CHILD_ASSOC_REF);
valueTypesByPropertyType.put(DataTypeDefinition.ASSOC_REF, ValueType.ASSOC_REF);
@@ -434,6 +471,7 @@ public class PropertyValue implements Cloneable, Serializable
private Float floatValue;
private Double doubleValue;
private String stringValue;
+ private Attribute attributeValue;
private Serializable serializableValue;
/**
@@ -534,6 +572,7 @@ public class PropertyValue implements Cloneable, Serializable
EqualsHelper.nullSafeEquals(this.floatValue, that.floatValue) &&
EqualsHelper.nullSafeEquals(this.doubleValue, that.doubleValue) &&
EqualsHelper.nullSafeEquals(this.stringValue, that.stringValue) &&
+ EqualsHelper.nullSafeEquals(this.attributeValue, that.attributeValue) &&
EqualsHelper.nullSafeEquals(this.serializableValue, that.serializableValue)
);
@@ -636,6 +675,9 @@ public class PropertyValue implements Cloneable, Serializable
case STRING:
this.stringValue = (String) value;
break;
+ case DB_ATTRIBUTE:
+ this.attributeValue = (Attribute) value;
+ break;
case SERIALIZABLE:
this.serializableValue = (Serializable) value;
break;
@@ -679,6 +721,8 @@ public class PropertyValue implements Cloneable, Serializable
{
return this.stringValue;
}
+ case DB_ATTRIBUTE:
+ return this.attributeValue;
case SERIALIZABLE:
return this.serializableValue;
default:
@@ -819,6 +863,15 @@ public class PropertyValue implements Cloneable, Serializable
this.stringValue = value;
}
+ public Attribute getAttributeValue()
+ {
+ return attributeValue;
+ }
+ public void setAttributeValue(Attribute value)
+ {
+ this.attributeValue = value;
+ }
+
public Serializable getSerializableValue()
{
return serializableValue;
diff --git a/source/java/org/alfresco/repo/domain/PropertyValueTest.java b/source/java/org/alfresco/repo/domain/PropertyValueTest.java
new file mode 100644
index 0000000000..a526f23f87
--- /dev/null
+++ b/source/java/org/alfresco/repo/domain/PropertyValueTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing
+ */
+package org.alfresco.repo.domain;
+
+import java.util.Locale;
+
+import junit.framework.TestCase;
+
+import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
+import org.alfresco.service.cmr.repository.MLText;
+import org.alfresco.util.ApplicationContextHelper;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * @see PropertyValue
+ *
+ * @author Derek Hulley
+ */
+public class PropertyValueTest extends TestCase
+{
+ @SuppressWarnings("unused")
+ private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
+
+ public void testMLText()
+ {
+ MLText mlText = new MLText(Locale.FRENCH, "bonjour");
+ PropertyValue propertyValue = new PropertyValue(DataTypeDefinition.MLTEXT, mlText);
+ assertNotNull("MLText not persisted as an attribute", propertyValue.getAttributeValue());
+ }
+}
diff --git a/source/java/org/alfresco/repo/domain/hibernate/Node.hbm.xml b/source/java/org/alfresco/repo/domain/hibernate/Node.hbm.xml
index 6c19229b83..5b5046e3cb 100644
--- a/source/java/org/alfresco/repo/domain/hibernate/Node.hbm.xml
+++ b/source/java/org/alfresco/repo/domain/hibernate/Node.hbm.xml
@@ -70,6 +70,7 @@