}
VarArgParser.Arguments parsedArgs = WGAGlobal._callActionVarargs.parse(args);
// Determine action id and action context
TMLContext context = (TMLContext) parsedArgs.get("context");
if (context == null) {
context = WGAGlobal.fetchInitialContext(cx);
}
String actionID = (String) parsedArgs.get("id");
List actionArgs = new ArrayList(parsedArgs.getOverflowArgs());
// Locate action
TMLAction action;
if (design._currentObject != null) {
TMLAction.Locator locator = WGAGlobal.determineActionLocator(cx, design._currentObject, context, actionID);
action = context.getActionByID(locator.getId(), locator.getDbkey());
}
else {
action = context.getActionByID(actionID, design._designContext.getDesignDB().getDbReference());
}
if (action == null) {
throw new EvaluatorException("Could not retrieve action for ID '" + actionID + "'");
}
// Call action
Object actionResult;
try {
TMLScriptRootScope rootScope = WGAGlobal.fetchRootScope(cx);
actionResult = context.callCustomAction(action, actionArgs, rootScope.getData().getUnwrappedGlobalScopeObjects());
}
catch (WGAPIException e) {
throw Context.throwAsScriptRuntimeEx(e);
}