+ * No assumptions should be made about the return type. The raw type might not match the persisted type. + * + * @param from the instance supplying the data + * @return Returns a value object based on the provided data + */ + public abstract AttributeValue getAttributeValue(Attribute from); + + /** + * Get a persistable implementation of the {@link Attribute} given an existing attribute. + * The from attribute may be a persistable entity or not but a new instance will + * be created. + *
+ * No assumptions should be made about the return type. It is possible that the data will
+ * be converted to a different persistable type.
+ *
+ * @param from the instance supplying the data
+ * @return Returns a persistable entity based on the provided data
+ */
+ public abstract AttributeImpl getAttributeImpl(Attribute from);
};
/**
@@ -67,10 +424,25 @@ public interface Attribute extends Serializable, Iterable
+ * The system - as of V2.1.2 - will attempt to adjust the maximum string length size
+ * automatically and therefore this method is not normally required. But it is possible
+ * to manually override the value if, for example, the system doesn't guess the correct
+ * maximum length or if the dialect is not explicitly catered for.
+ *
+ * All negative or zero values are ignored and the system defaults to its best guess based
+ * on the dialect being used.
+ *
+ * @param maximumStringLength the maximum length of the string_value columns
+ */
+ public void setMaximumStringLength(int maximumStringLength)
+ {
+ if (maximumStringLength > 0)
+ {
+ this.maximumStringLength = maximumStringLength;
+ }
+ }
+
/**
* Helper method to generate a schema creation SQL script from the given Hibernate
* configuration.
@@ -768,6 +825,76 @@ public class SchemaBootstrap extends AbstractLifecycleBean
try { stmt.close(); } catch (Throwable e) {}
}
}
+
+ /**
+ * Performs dialect-specific checking. This includes checking for InnoDB, dumping the dialect being used
+ * as well as setting any runtime, dialect-specific properties.
+ */
+ private void checkDialect(Dialect dialect)
+ {
+ Class dialectClazz = dialect.getClass();
+ LogUtil.info(logger, MSG_DIALECT_USED, dialectClazz.getName());
+ if (dialectClazz.equals(MySQLDialect.class) || dialectClazz.equals(MySQL5Dialect.class))
+ {
+ LogUtil.warn(logger, WARN_DIALECT_UNSUPPORTED, dialectClazz.getName());
+ }
+ if (dialectClazz.equals(HSQLDialect.class))
+ {
+ LogUtil.info(logger, WARN_DIALECT_HSQL);
+ }
+
+ int maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
+ // Adjust the maximum allowable String length according to the dialect
+ if (dialect instanceof AlfrescoSQLServerDialect)
+ {
+ // string_value nvarchar(1024) null,
+ // serializable_value image null,
+ maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
+ }
+ else if (dialect instanceof AlfrescoSybaseAnywhereDialect)
+ {
+ // string_value text null,
+ // serializable_value varbinary(8192) null,
+ maxStringLength = Integer.MAX_VALUE;
+ }
+ else if (dialect instanceof DB2Dialect)
+ {
+ // string_value varchar(1024),
+ // serializable_value varchar(8192) for bit data,
+ maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
+ }
+ else if (dialect instanceof HSQLDialect)
+ {
+ // string_value varchar(1024),
+ // serializable_value varbinary(8192),
+ maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
+ }
+ else if (dialect instanceof MySQLInnoDBDialect)
+ {
+ // string_value text,
+ // serializable_value blob,
+ maxStringLength = Integer.MAX_VALUE;
+ }
+ else if (dialect instanceof Oracle9Dialect)
+ {
+ // string_value varchar2(1024 char),
+ // serializable_value long raw,
+ maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
+ }
+ else if (dialect instanceof PostgreSQLDialect)
+ {
+ // string_value varchar(1024),
+ // serializable_value bytea,
+ maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH;
+ }
+ SchemaBootstrap.setMaxStringLength(maxStringLength);
+
+ // Now override the maximum string length if it was set directly
+ if (maximumStringLength > 0)
+ {
+ SchemaBootstrap.setMaxStringLength(maximumStringLength);
+ }
+ }
@Override
protected void onBootstrap(ApplicationEvent event)
@@ -789,16 +916,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
// Check and dump the dialect being used
Dialect dialect = Dialect.getDialect(cfg.getProperties());
- Class dialectClazz = dialect.getClass();
- LogUtil.info(logger, MSG_DIALECT_USED, dialectClazz.getName());
- if (dialectClazz.equals(MySQLDialect.class) || dialectClazz.equals(MySQL5Dialect.class))
- {
- LogUtil.warn(logger, WARN_DIALECT_UNSUPPORTED, dialectClazz.getName());
- }
- if (dialectClazz.equals(HSQLDialect.class))
- {
- LogUtil.info(logger, WARN_DIALECT_HSQL);
- }
+ checkDialect(dialect);
// Ensure that our static connection provider is used
String defaultConnectionProviderFactoryClass = cfg.getProperty(Environment.CONNECTION_PROVIDER);
diff --git a/source/java/org/alfresco/repo/node/FullNodeServiceTest.java b/source/java/org/alfresco/repo/node/FullNodeServiceTest.java
index 2a78f8056f..dafa94f3b4 100644
--- a/source/java/org/alfresco/repo/node/FullNodeServiceTest.java
+++ b/source/java/org/alfresco/repo/node/FullNodeServiceTest.java
@@ -84,6 +84,35 @@ public class FullNodeServiceTest extends BaseNodeServiceTest
mlTextProperty.getValue(Locale.ENGLISH),
propertiesFiltered.get(BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE));
}
+
+ public void testLongMLTextValues() throws Exception
+ {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < 4096; i++)
+ {
+ sb.append(" ").append(i);
+ }
+ String longString = sb.toString();
+ // Set the server default locale
+ Locale.setDefault(Locale.ENGLISH);
+
+ // Set it as a normal string
+ nodeService.setProperty(
+ rootNodeRef,
+ BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE,
+ longString);
+
+ MLText mlTextProperty = new MLText();
+ mlTextProperty.addValue(Locale.ENGLISH, longString);
+ mlTextProperty.addValue(Locale.FRENCH, longString);
+ mlTextProperty.addValue(Locale.GERMAN, longString);
+
+ // Set it as MLText
+ nodeService.setProperty(
+ rootNodeRef,
+ BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE,
+ mlTextProperty);
+ }
/**
* {@inheritDoc}
diff --git a/source/java/org/alfresco/repo/workflow/jbpm/JBPMTransactionTemplate.java b/source/java/org/alfresco/repo/workflow/jbpm/JBPMTransactionTemplate.java
index 2a50908baa..33cc619818 100644
--- a/source/java/org/alfresco/repo/workflow/jbpm/JBPMTransactionTemplate.java
+++ b/source/java/org/alfresco/repo/workflow/jbpm/JBPMTransactionTemplate.java
@@ -116,7 +116,6 @@ public class JBPMTransactionTemplate extends JbpmTemplate
if (context == null)
{
context = super.getContext();
- SessionSizeResourceManager.setDisableInTransaction();
AlfrescoTransactionSupport.bindResource(JBPM_CONTEXT_KEY, context);
AlfrescoTransactionSupport.bindListener(this);
diff --git a/source/java/org/alfresco/service/cmr/repository/datatype/DefaultTypeConverter.java b/source/java/org/alfresco/service/cmr/repository/datatype/DefaultTypeConverter.java
index d856f0162b..41ba24dd58 100644
--- a/source/java/org/alfresco/service/cmr/repository/datatype/DefaultTypeConverter.java
+++ b/source/java/org/alfresco/service/cmr/repository/datatype/DefaultTypeConverter.java
@@ -44,7 +44,6 @@ import org.alfresco.i18n.I18NUtil;
import org.alfresco.repo.attributes.Attribute;
import org.alfresco.repo.attributes.MapAttribute;
import org.alfresco.repo.attributes.MapAttributeValue;
-import org.alfresco.repo.attributes.StringAttribute;
import org.alfresco.repo.attributes.StringAttributeValue;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -322,15 +321,9 @@ public class DefaultTypeConverter
"MapAttribute string key cannot be converted to a locales:" + localeStr, e);
}
Attribute valueAttribute = entry.getValue();
- if (valueAttribute instanceof StringAttribute)
- {
- ret.put(locale, valueAttribute.getStringValue());
- }
- else
- {
- throw new TypeConversionException(
- "MapAttribute must contain Locale-String mappings to convert to MLText");
- }
+ // Use the attribute's built-in conversion
+ String valueStr = valueAttribute == null ? null : valueAttribute.getStringValue();
+ ret.put(locale, valueStr);
}
return ret;
}
diff --git a/source/java/org/alfresco/util/RuntimeSystemPropertiesSetter.java b/source/java/org/alfresco/util/RuntimeSystemPropertiesSetter.java
index afb66c27f6..ea006d65e4 100644
--- a/source/java/org/alfresco/util/RuntimeSystemPropertiesSetter.java
+++ b/source/java/org/alfresco/util/RuntimeSystemPropertiesSetter.java
@@ -21,46 +21,79 @@
* 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"
-
-*
-* Author Jon Cox
+ * This class is used by the Spring framework to inject system properties into
+ * the runtime environment (e.g.: alfresco.jmx.dir). The motivation for this
+ * is that certain values must be set within spring must be computed in advance
+ * for org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
+ * to work properly.
+ *
+ * @author Jon Cox
+ * @see #setProperties(Map)
*/
-public class RuntimeSystemPropertiesSetter
- implements BeanFactoryPostProcessor, Ordered
+public class RuntimeSystemPropertiesSetter implements BeanFactoryPostProcessor, Ordered
{
- private static org.apache.commons.logging.Log log=
- org.apache.commons.logging.LogFactory.getLog(
- RuntimeSystemPropertiesSetter.class );
+ private static Log logger = LogFactory.getLog(RuntimeSystemPropertiesSetter.class );
- // default: just before PropertyPlaceholderConfigurer
- private int order = Integer.MAX_VALUE - 1;
+ /** default: just before PropertyPlaceholderConfigurer */
+ private int order = Integer.MAX_VALUE - 1;
+
+ /**
+ * @see #setProperties(Map)
+ */
+ private Map