mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.0 to HEAD
12297: Fix mysql config instructions for case sensitive user names - DOC-68 12298: Merged V2.2 to V3.0 12257: Fixed ETWOTWO-952: MLText properties not intercepted when calling addAspect and createNode 12270: Fixed RhinoScriptTest to propogate exceptions for full recording by Junit 12271: Fixed NPE in ML interceptor when null node properties are passed to createNode 12282: Merged V2.1 to V2.2 11616: Fix for ETWOONE-218: Common.js function needs to be changed to support root context 12287: Merged V2.1 to V2.2 12229: WCM - disable/hide link validation by defrault (ETWOONE-106, ETWOONE-392) 12301: Merged V2.2 to V3.0 12288: Merged V2.1 to V2.2 12233: Fixed ETWOONE-124: Add the property UUIDBinding to ImporterBootstrap git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12530 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -588,6 +588,26 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest
|
||||
{
|
||||
value = new ContentData(null, MimetypeMap.EXTENSION_BINARY, 0L, "UTF-8");
|
||||
}
|
||||
else if (propertyTypeQName.equals(DataTypeDefinition.LOCALE))
|
||||
{
|
||||
value = Locale.CHINESE;
|
||||
}
|
||||
else if (propertyTypeQName.equals(DataTypeDefinition.BOOLEAN))
|
||||
{
|
||||
value = Boolean.TRUE;
|
||||
}
|
||||
else if (propertyTypeQName.equals(DataTypeDefinition.PATH))
|
||||
{
|
||||
value = new Path();
|
||||
}
|
||||
else if (propertyTypeQName.equals(DataTypeDefinition.QNAME))
|
||||
{
|
||||
value = TYPE_QNAME_EXTENDED_CONTENT;
|
||||
}
|
||||
else if (propertyTypeQName.equals(DataTypeDefinition.CATEGORY) || propertyTypeQName.equals(DataTypeDefinition.NODE_REF))
|
||||
{
|
||||
value = new NodeRef("workspace://SpacesStore/12345");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = new Long(System.currentTimeMillis());
|
||||
|
@@ -25,11 +25,14 @@
|
||||
package org.alfresco.repo.node;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.repo.node.db.DbNodeServiceImpl;
|
||||
import org.alfresco.service.cmr.repository.MLText;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -132,6 +135,75 @@ public class FullNodeServiceTest extends BaseNodeServiceTest
|
||||
assertNull("Value returned is not null", mlText);
|
||||
}
|
||||
|
||||
public void testMLValuesOnCreate() throws Exception
|
||||
{
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||
fillProperties(BaseNodeServiceTest.TYPE_QNAME_TEST_MANY_PROPERTIES, properties);
|
||||
// Replace the MLText value with a plain string
|
||||
properties.put(BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, "Bonjour");
|
||||
// Now switch to French
|
||||
I18NUtil.setContentLocale(Locale.FRENCH);
|
||||
// Create a node with the value
|
||||
NodeRef nodeRef = nodeService.createNode(
|
||||
rootNodeRef,
|
||||
BaseNodeServiceTest.ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
||||
QName.createQName(BaseNodeServiceTest.NAMESPACE, getName()),
|
||||
BaseNodeServiceTest.TYPE_QNAME_TEST_MANY_PROPERTIES,
|
||||
properties).getChildRef();
|
||||
// Now switch to English
|
||||
I18NUtil.setContentLocale(Locale.ENGLISH);
|
||||
// Set the english property
|
||||
nodeService.setProperty(nodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, "Hello");
|
||||
|
||||
// Switch back to French and get the value
|
||||
I18NUtil.setContentLocale(Locale.FRENCH);
|
||||
assertEquals(
|
||||
"Expected French value property",
|
||||
"Bonjour",
|
||||
nodeService.getProperty(nodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE));
|
||||
|
||||
// Switch back to English and get the value
|
||||
I18NUtil.setContentLocale(Locale.ENGLISH);
|
||||
assertEquals(
|
||||
"Expected English value property",
|
||||
"Hello",
|
||||
nodeService.getProperty(nodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE));
|
||||
}
|
||||
|
||||
public void testMLValuesOnAddAspect() throws Exception
|
||||
{
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||
fillProperties(BaseNodeServiceTest.TYPE_QNAME_TEST_MANY_PROPERTIES, properties);
|
||||
// Replace the MLText value with a plain string
|
||||
properties.put(BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, "Bonjour");
|
||||
// Now switch to French
|
||||
I18NUtil.setContentLocale(Locale.FRENCH);
|
||||
// Add an aspect
|
||||
NodeRef nodeRef = rootNodeRef;
|
||||
nodeService.addAspect(
|
||||
nodeRef,
|
||||
BaseNodeServiceTest.ASPECT_QNAME_TEST_TITLED,
|
||||
properties);
|
||||
// Now switch to English
|
||||
I18NUtil.setContentLocale(Locale.ENGLISH);
|
||||
// Set the english property
|
||||
nodeService.setProperty(nodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, "Hello");
|
||||
|
||||
// Switch back to French and get the value
|
||||
I18NUtil.setContentLocale(Locale.FRENCH);
|
||||
assertEquals(
|
||||
"Expected French value property",
|
||||
"Bonjour",
|
||||
nodeService.getProperty(nodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE));
|
||||
|
||||
// Switch back to English and get the value
|
||||
I18NUtil.setContentLocale(Locale.ENGLISH);
|
||||
assertEquals(
|
||||
"Expected English value property",
|
||||
"Hello",
|
||||
nodeService.getProperty(nodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
@@ -25,6 +25,7 @@
|
||||
package org.alfresco.repo.node;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
@@ -196,26 +197,20 @@ public class MLPropertyInterceptor implements MethodInterceptor
|
||||
else if (methodName.equals("setProperties"))
|
||||
{
|
||||
NodeRef nodeRef = (NodeRef) args[0];
|
||||
Map<QName, Serializable> newProperties =(Map<QName, Serializable>) args[1];
|
||||
|
||||
// Get the pivot translation, if appropriate
|
||||
NodeRef pivotNodeRef = getPivotNodeRef(nodeRef);
|
||||
|
||||
Map<QName, Serializable> newProperties =(Map<QName, Serializable>) args[1];
|
||||
// Get the current properties for the node
|
||||
Map<QName, Serializable> currentProperties = nodeService.getProperties(nodeRef);
|
||||
// Convert all properties
|
||||
Map<QName, Serializable> convertedProperties = new HashMap<QName, Serializable>(newProperties.size() * 2);
|
||||
for (Map.Entry<QName, Serializable> entry : newProperties.entrySet())
|
||||
{
|
||||
QName propertyQName = entry.getKey();
|
||||
Serializable inboundValue = entry.getValue();
|
||||
// Get the current property value
|
||||
Serializable currentValue = currentProperties.get(propertyQName);
|
||||
// Convert the inbound property value
|
||||
inboundValue = convertInboundProperty(contentLocale, nodeRef, pivotNodeRef, propertyQName, inboundValue, currentValue);
|
||||
// Put the value into the map
|
||||
convertedProperties.put(propertyQName, inboundValue);
|
||||
}
|
||||
Map<QName, Serializable> convertedProperties = convertInboundProperties(
|
||||
currentProperties,
|
||||
newProperties,
|
||||
contentLocale,
|
||||
nodeRef,
|
||||
pivotNodeRef);
|
||||
// Now complete the call by passing the converted properties
|
||||
nodeService.setProperties(nodeRef, convertedProperties);
|
||||
// Done
|
||||
@@ -236,6 +231,55 @@ public class MLPropertyInterceptor implements MethodInterceptor
|
||||
nodeService.setProperty(nodeRef, propertyQName, inboundValue);
|
||||
// Done
|
||||
}
|
||||
else if (methodName.equals("createNode") && args.length > 4)
|
||||
{
|
||||
NodeRef parentNodeRef = (NodeRef) args[0];
|
||||
QName assocTypeQName = (QName) args[1];
|
||||
QName assocQName = (QName) args[2];
|
||||
QName nodeTypeQName = (QName) args[3];
|
||||
Map<QName, Serializable> newProperties =(Map<QName, Serializable>) args[4];
|
||||
if (newProperties == null)
|
||||
{
|
||||
newProperties = Collections.emptyMap();
|
||||
}
|
||||
NodeRef nodeRef = null; // Not created yet
|
||||
|
||||
// No pivot
|
||||
NodeRef pivotNodeRef = null;
|
||||
|
||||
// Convert all properties
|
||||
Map<QName, Serializable> convertedProperties = convertInboundProperties(
|
||||
null,
|
||||
newProperties,
|
||||
contentLocale,
|
||||
nodeRef,
|
||||
pivotNodeRef);
|
||||
// Now complete the call by passing the converted properties
|
||||
ret = nodeService.createNode(parentNodeRef, assocTypeQName, assocQName, nodeTypeQName, convertedProperties);
|
||||
// Done
|
||||
}
|
||||
else if (methodName.equals("addAspect") && args[2] != null)
|
||||
{
|
||||
NodeRef nodeRef = (NodeRef) args[0];
|
||||
QName aspectTypeQName = (QName) args[1];
|
||||
|
||||
// Get the pivot translation, if appropriate
|
||||
NodeRef pivotNodeRef = getPivotNodeRef(nodeRef);
|
||||
|
||||
Map<QName, Serializable> newProperties =(Map<QName, Serializable>) args[2];
|
||||
// Get the current properties for the node
|
||||
Map<QName, Serializable> currentProperties = nodeService.getProperties(nodeRef);
|
||||
// Convert all properties
|
||||
Map<QName, Serializable> convertedProperties = convertInboundProperties(
|
||||
currentProperties,
|
||||
newProperties,
|
||||
contentLocale,
|
||||
nodeRef,
|
||||
pivotNodeRef);
|
||||
// Now complete the call by passing the converted properties
|
||||
nodeService.addAspect(nodeRef, aspectTypeQName, convertedProperties);
|
||||
// Done
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = invocation.proceed();
|
||||
@@ -328,6 +372,28 @@ public class MLPropertyInterceptor implements MethodInterceptor
|
||||
return ret;
|
||||
}
|
||||
|
||||
private Map<QName, Serializable> convertInboundProperties(
|
||||
Map<QName, Serializable> currentProperties,
|
||||
Map<QName, Serializable> newProperties,
|
||||
Locale contentLocale,
|
||||
NodeRef nodeRef,
|
||||
NodeRef pivotNodeRef)
|
||||
{
|
||||
Map<QName, Serializable> convertedProperties = new HashMap<QName, Serializable>(newProperties.size() * 2);
|
||||
for (Map.Entry<QName, Serializable> entry : newProperties.entrySet())
|
||||
{
|
||||
QName propertyQName = entry.getKey();
|
||||
Serializable inboundValue = entry.getValue();
|
||||
// Get the current property value
|
||||
Serializable currentValue = currentProperties == null ? null : currentProperties.get(propertyQName);
|
||||
// Convert the inbound property value
|
||||
inboundValue = convertInboundProperty(contentLocale, nodeRef, pivotNodeRef, propertyQName, inboundValue, currentValue);
|
||||
// Put the value into the map
|
||||
convertedProperties.put(propertyQName, inboundValue);
|
||||
}
|
||||
return convertedProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param inboundValue The value that must be set
|
||||
@@ -360,7 +426,7 @@ public class MLPropertyInterceptor implements MethodInterceptor
|
||||
{
|
||||
// This is a multilingual single-valued property
|
||||
// Get the current value from the node service, if not provided
|
||||
if (currentValue == null)
|
||||
if (currentValue == null && nodeRef != null)
|
||||
{
|
||||
currentValue = nodeService.getProperty(nodeRef, propertyQName);
|
||||
}
|
||||
|
Reference in New Issue
Block a user