Merged V2.1 to HEAD

6368: Change home folder provider to use User Homes and not company home
   6370: Fixed BDE-50: Empty line in the clean_tomcat.sh script file
   6373: Working copy nodes don't get sys:temporary aspect applied.
            Node archival ignores working copy nodes.
   6375: Fixed AR-1154: Benchmark override sample
   6377: Documentation updates.
   6379: Moved old installer files.
   6381: Fixed AR-782: Early detection of property conversion issues
   6382: Fixed AR-1414: Serializable property values are immediately disconnected from the client's instance.
   6384: Fix AR-1642 : Pooled task is not auto-assigned when task is completed by user, but user has not first 'taken ownership'
   6385: AR-1621 Workflow bootstrap is not sensitive to system read-only mode
            Resolved conflicted state of 'root\projects\repository\source\java\org\alfresco\repo\workflow\WorkflowInterpreter.java'


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6726 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-09-10 15:21:52 +00:00
parent 60ea2805cc
commit 1050a3cb98
10 changed files with 172 additions and 42 deletions

View File

@@ -24,6 +24,10 @@
*/
package org.alfresco.repo.domain;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
@@ -512,6 +516,11 @@ public class PropertyValue implements Cloneable, Serializable
}
else
{
// Convert the value to the type required. This ensures that any type conversion issues
// are caught early and prevent the scenario where the data in the DB cannot be given
// back out because it is unconvertable.
ValueType valueType = makeValueType(typeQName);
value = valueType.convert(value);
// get the persisted type
ValueType persistedValueType = this.actualType.getPersistedType(value);
// convert to the persistent type
@@ -679,7 +688,7 @@ public class PropertyValue implements Cloneable, Serializable
this.attributeValue = (Attribute) value;
break;
case SERIALIZABLE:
this.serializableValue = (Serializable) value;
this.serializableValue = cloneSerializable(value);
break;
default:
throw new AlfrescoRuntimeException("Unrecognised value type: " + persistedType);
@@ -687,6 +696,37 @@ public class PropertyValue implements Cloneable, Serializable
// we store the type that we persisted as
this.persistedType = persistedType;
}
/**
* Clones a serializable object to disconnect the original instance from the persisted instance.
*
* @param original the original object
* @return the new cloned object
*/
private Serializable cloneSerializable(Serializable original)
{
try
{
// Connect the pipes
PipedOutputStream pipeOut = new PipedOutputStream();
PipedInputStream pipeIn = new PipedInputStream();
pipeOut.connect(pipeIn);
ObjectOutputStream objectOut = new ObjectOutputStream(pipeOut);
ObjectInputStream objectIn = new ObjectInputStream(pipeIn);
// Now write the object
objectOut.writeObject(original);
// Read the new object in
Object newObj = objectIn.readObject();
// Done
return (Serializable) newObj;
}
catch (Throwable e)
{
throw new AlfrescoRuntimeException("Failed to clone serializable object: " + original, e);
}
}
/**
* @return Returns the persisted value, keying off the persisted value type