mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix for ALFCOM-1666 - Null pointer when calling ScriptNode in Java (for workflow)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13499 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -43,7 +43,6 @@ import org.mozilla.javascript.IdScriptableObject;
|
||||
import org.mozilla.javascript.NativeArray;
|
||||
import org.mozilla.javascript.ScriptRuntime;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
import org.mozilla.javascript.ScriptableObject;
|
||||
import org.mozilla.javascript.Wrapper;
|
||||
|
||||
|
||||
@@ -96,10 +95,19 @@ public class ValueConverter
|
||||
// call the "Date" constructor on the root scope object - passing in the millisecond
|
||||
// value from the Java date - this will construct a JavaScript Date with the same value
|
||||
Date date = (Date)value;
|
||||
|
||||
try
|
||||
{
|
||||
Context.enter();
|
||||
Object val = ScriptRuntime.newObject(
|
||||
Context.getCurrentContext(), scope, TYPE_DATE, new Object[] {date.getTime()});
|
||||
value = (Serializable)val;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Context.exit();
|
||||
}
|
||||
}
|
||||
else if (value instanceof Collection)
|
||||
{
|
||||
// recursively convert each value in the collection
|
||||
@@ -110,9 +118,17 @@ public class ValueConverter
|
||||
{
|
||||
array[index++] = convertValueForScript(services, scope, qname, obj);
|
||||
}
|
||||
try
|
||||
{
|
||||
Context.enter();
|
||||
// convert array to a native JavaScript Array
|
||||
value = (Serializable)Context.getCurrentContext().newArray(scope, array);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Context.exit();
|
||||
}
|
||||
}
|
||||
// simple numbers and strings are wrapped automatically by Rhino
|
||||
|
||||
return value;
|
||||
|
Reference in New Issue
Block a user