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:
Jan Vonka
2008-12-22 12:17:00 +00:00
parent eca46db62b
commit 38ba58dede
9 changed files with 284 additions and 69 deletions

View File

@@ -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);
}