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
|
||||
{
|
||||
private static final String TYPE_DATE = "Date";
|
||||
|
||||
/**
|
||||
* Convert an object from any repository serialized value to a valid script object.
|
||||
* This includes converting Collection multi-value properties into JavaScript Array objects.
|
||||
@ -95,7 +97,7 @@ public class ValueConverter
|
||||
// value from the Java date - this will construct a JavaScript Date with the same value
|
||||
Date date = (Date)value;
|
||||
Object val = ScriptRuntime.newObject(
|
||||
Context.getCurrentContext(), scope, "Date", new Object[] {date.getTime()});
|
||||
Context.getCurrentContext(), scope, TYPE_DATE, new Object[] {date.getTime()});
|
||||
value = (Serializable)val;
|
||||
}
|
||||
else if (value instanceof Collection)
|
||||
@ -158,7 +160,16 @@ public class ValueConverter
|
||||
|
||||
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
|
||||
Object[] propIds = values.getIds();
|
||||
@ -201,15 +212,6 @@ public class ValueConverter
|
||||
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[])
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user