mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +00:00
Fix to recent Script ValueConveter changes - NativeDate objects were being incorrectly converted to an empty Map.
Will fix build as script test was failing due to this. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5952 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
04a78f17d2
commit
d403021a74
@ -52,6 +52,8 @@ import org.mozilla.javascript.Wrapper;
|
|||||||
*/
|
*/
|
||||||
public class ValueConverter
|
public class ValueConverter
|
||||||
{
|
{
|
||||||
|
private static final String TYPE_DATE = "Date";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert an object from any repository serialized value to a valid script object.
|
* Convert an object from any repository serialized value to a valid script object.
|
||||||
* This includes converting Collection multi-value properties into JavaScript Array objects.
|
* This includes converting Collection multi-value properties into JavaScript Array objects.
|
||||||
@ -78,15 +80,15 @@ public class ValueConverter
|
|||||||
}
|
}
|
||||||
else if (value instanceof QName || value instanceof StoreRef)
|
else if (value instanceof QName || value instanceof StoreRef)
|
||||||
{
|
{
|
||||||
value = value.toString();
|
value = value.toString();
|
||||||
}
|
}
|
||||||
else if (value instanceof ChildAssociationRef)
|
else if (value instanceof ChildAssociationRef)
|
||||||
{
|
{
|
||||||
value = new ChildAssociation(services, (ChildAssociationRef)value, scope);
|
value = new ChildAssociation(services, (ChildAssociationRef)value, scope);
|
||||||
}
|
}
|
||||||
else if (value instanceof AssociationRef)
|
else if (value instanceof AssociationRef)
|
||||||
{
|
{
|
||||||
value = new Association(services, (AssociationRef)value, scope);
|
value = new Association(services, (AssociationRef)value, scope);
|
||||||
}
|
}
|
||||||
else if (value instanceof Date)
|
else if (value instanceof Date)
|
||||||
{
|
{
|
||||||
@ -95,7 +97,7 @@ public class ValueConverter
|
|||||||
// value from the Java date - this will construct a JavaScript Date with the same value
|
// value from the Java date - this will construct a JavaScript Date with the same value
|
||||||
Date date = (Date)value;
|
Date date = (Date)value;
|
||||||
Object val = ScriptRuntime.newObject(
|
Object val = ScriptRuntime.newObject(
|
||||||
Context.getCurrentContext(), scope, "Date", new Object[] {date.getTime()});
|
Context.getCurrentContext(), scope, TYPE_DATE, new Object[] {date.getTime()});
|
||||||
value = (Serializable)val;
|
value = (Serializable)val;
|
||||||
}
|
}
|
||||||
else if (value instanceof Collection)
|
else if (value instanceof Collection)
|
||||||
@ -138,11 +140,11 @@ public class ValueConverter
|
|||||||
}
|
}
|
||||||
else if (value instanceof ChildAssociation)
|
else if (value instanceof ChildAssociation)
|
||||||
{
|
{
|
||||||
value = ((ChildAssociation)value).getChildAssociationRef();
|
value = ((ChildAssociation)value).getChildAssociationRef();
|
||||||
}
|
}
|
||||||
else if (value instanceof Association)
|
else if (value instanceof Association)
|
||||||
{
|
{
|
||||||
value = ((Association)value).getAssociationRef();
|
value = ((Association)value).getAssociationRef();
|
||||||
}
|
}
|
||||||
else if (value instanceof Wrapper)
|
else if (value instanceof Wrapper)
|
||||||
{
|
{
|
||||||
@ -158,7 +160,16 @@ public class ValueConverter
|
|||||||
|
|
||||||
if (value instanceof IdScriptableObject)
|
if (value instanceof IdScriptableObject)
|
||||||
{
|
{
|
||||||
if (value instanceof NativeArray)
|
// TODO: add code here to use the dictionary and convert to correct value type
|
||||||
|
if (TYPE_DATE.equals(((IdScriptableObject)value).getClassName()))
|
||||||
|
{
|
||||||
|
Object javaObj = Context.jsToJava(value, Date.class);
|
||||||
|
if (javaObj instanceof Serializable)
|
||||||
|
{
|
||||||
|
value = (Serializable)javaObj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (value instanceof NativeArray)
|
||||||
{
|
{
|
||||||
// convert JavaScript array of values to a List of Serializable objects
|
// convert JavaScript array of values to a List of Serializable objects
|
||||||
Object[] propIds = values.getIds();
|
Object[] propIds = values.getIds();
|
||||||
@ -201,15 +212,6 @@ public class ValueConverter
|
|||||||
value = (Serializable)propValues;
|
value = (Serializable)propValues;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO: add code here to use the dictionary and convert to correct value type
|
|
||||||
Object javaObj = Context.jsToJava(value, Date.class);
|
|
||||||
if (javaObj instanceof Serializable)
|
|
||||||
{
|
|
||||||
value = (Serializable)javaObj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (value instanceof Serializable[])
|
else if (value instanceof Serializable[])
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user