mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-11659: CLuster specific - Could not execute "Start Polled Review and Approve"script
- added some logging capability into ScriptServiceImpl to see if we can catch the problem in the log file. To enable it, add this to log4j.properties: log4j.logger.org.alfresco.repo.processor.ScriptServiceImpl=warn git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32639 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -117,29 +117,9 @@ public class ScriptServiceImpl implements ScriptService
|
|||||||
public Object executeScript(String scriptClasspath, Map<String, Object> model)
|
public Object executeScript(String scriptClasspath, Map<String, Object> model)
|
||||||
throws ScriptException
|
throws ScriptException
|
||||||
{
|
{
|
||||||
if (scriptClasspath == null)
|
ParameterCheck.mandatory("scriptClasspath", scriptClasspath);
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Script ClassPath is mandatory.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug("Executing script: " + scriptClasspath);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ScriptProcessor scriptProcessor = getScriptProcessor(scriptClasspath);
|
ScriptProcessor scriptProcessor = getScriptProcessor(scriptClasspath);
|
||||||
return scriptProcessor.execute(scriptClasspath, model);
|
return execute(scriptProcessor, scriptClasspath, model);
|
||||||
}
|
|
||||||
catch (ScriptException err)
|
|
||||||
{
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
catch (Throwable err)
|
|
||||||
{
|
|
||||||
throw new ScriptException("Failed to execute script '" + scriptClasspath + "': " + err.getMessage(), err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,30 +127,9 @@ public class ScriptServiceImpl implements ScriptService
|
|||||||
*/
|
*/
|
||||||
public Object executeScript(String engine, String scriptClasspath, Map<String, Object> model)
|
public Object executeScript(String engine, String scriptClasspath, Map<String, Object> model)
|
||||||
throws ScriptException
|
throws ScriptException
|
||||||
{
|
|
||||||
if (scriptClasspath == null)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Script ClassPath is mandatory.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug("Executing script: " + scriptClasspath);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
ScriptProcessor scriptProcessor = lookupScriptProcessor(engine);
|
ScriptProcessor scriptProcessor = lookupScriptProcessor(engine);
|
||||||
return scriptProcessor.execute(scriptClasspath, model);
|
return execute(scriptProcessor, scriptClasspath, model);
|
||||||
}
|
|
||||||
catch (ScriptException err)
|
|
||||||
{
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
catch (Throwable err)
|
|
||||||
{
|
|
||||||
throw new ScriptException("Failed to execute script '" + scriptClasspath + "': " + err.getMessage(), err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -179,29 +138,9 @@ public class ScriptServiceImpl implements ScriptService
|
|||||||
public Object executeScript(NodeRef scriptRef, QName contentProp, Map<String, Object> model)
|
public Object executeScript(NodeRef scriptRef, QName contentProp, Map<String, Object> model)
|
||||||
throws ScriptException
|
throws ScriptException
|
||||||
{
|
{
|
||||||
if (scriptRef == null)
|
ParameterCheck.mandatory("scriptRef", scriptRef);
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Script NodeRef is mandatory.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug("Executing script: " + scriptRef.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ScriptProcessor scriptProcessor = getScriptProcessor(scriptRef);
|
ScriptProcessor scriptProcessor = getScriptProcessor(scriptRef);
|
||||||
return scriptProcessor.execute(scriptRef, contentProp, model);
|
return execute(scriptProcessor, scriptRef, contentProp, model);
|
||||||
}
|
|
||||||
catch (ScriptException err)
|
|
||||||
{
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
catch (Throwable err)
|
|
||||||
{
|
|
||||||
throw new ScriptException("Failed to execute script '" + scriptRef.toString() + "': " + err.getMessage(), err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -209,30 +148,9 @@ public class ScriptServiceImpl implements ScriptService
|
|||||||
*/
|
*/
|
||||||
public Object executeScript(String engine, NodeRef scriptRef, QName contentProp, Map<String, Object> model)
|
public Object executeScript(String engine, NodeRef scriptRef, QName contentProp, Map<String, Object> model)
|
||||||
throws ScriptException
|
throws ScriptException
|
||||||
{
|
|
||||||
if (scriptRef == null)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Script NodeRef is mandatory.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug("Executing script: " + scriptRef.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
ScriptProcessor scriptProcessor = lookupScriptProcessor(engine);
|
ScriptProcessor scriptProcessor = lookupScriptProcessor(engine);
|
||||||
return scriptProcessor.execute(scriptRef, contentProp, model);
|
return execute(scriptProcessor, scriptRef, contentProp, model);
|
||||||
}
|
|
||||||
catch (ScriptException err)
|
|
||||||
{
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
catch (Throwable err)
|
|
||||||
{
|
|
||||||
throw new ScriptException("Failed to execute script '" + scriptRef.toString() + "': " + err.getMessage(), err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -241,26 +159,9 @@ public class ScriptServiceImpl implements ScriptService
|
|||||||
public Object executeScript(ScriptLocation location, Map<String, Object> model)
|
public Object executeScript(ScriptLocation location, Map<String, Object> model)
|
||||||
throws ScriptException
|
throws ScriptException
|
||||||
{
|
{
|
||||||
ParameterCheck.mandatory("Location", location);
|
ParameterCheck.mandatory("location", location);
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug("Executing script: " + location.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ScriptProcessor scriptProcessor = getScriptProcessor(location.toString());
|
ScriptProcessor scriptProcessor = getScriptProcessor(location.toString());
|
||||||
return scriptProcessor.execute(location, model);
|
return execute(scriptProcessor, location, model);
|
||||||
}
|
|
||||||
catch (ScriptException err)
|
|
||||||
{
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
catch (Throwable err)
|
|
||||||
{
|
|
||||||
throw new ScriptException("Failed to execute script '" + location.toString() + "': " + err.getMessage(), err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -268,27 +169,9 @@ public class ScriptServiceImpl implements ScriptService
|
|||||||
*/
|
*/
|
||||||
public Object executeScript(String engine, ScriptLocation location, Map<String, Object> model)
|
public Object executeScript(String engine, ScriptLocation location, Map<String, Object> model)
|
||||||
throws ScriptException
|
throws ScriptException
|
||||||
{
|
|
||||||
ParameterCheck.mandatory("Location", location);
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug("Executing script: " + location.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
ScriptProcessor scriptProcessor = lookupScriptProcessor(engine);
|
ScriptProcessor scriptProcessor = lookupScriptProcessor(engine);
|
||||||
return scriptProcessor.execute(location, model);
|
return execute(scriptProcessor, location, model);
|
||||||
}
|
|
||||||
catch (ScriptException err)
|
|
||||||
{
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
catch (Throwable err)
|
|
||||||
{
|
|
||||||
throw new ScriptException("Failed to execute script '" + location.toString() + "': " + err.getMessage(), err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -306,40 +189,136 @@ public class ScriptServiceImpl implements ScriptService
|
|||||||
public Object executeScriptString(String engine, String script, Map<String, Object> model)
|
public Object executeScriptString(String engine, String script, Map<String, Object> model)
|
||||||
throws ScriptException
|
throws ScriptException
|
||||||
{
|
{
|
||||||
if (script == null || script.length() == 0)
|
ScriptProcessor scriptProcessor = lookupScriptProcessor(engine);
|
||||||
{
|
return executeString(scriptProcessor, script, model);
|
||||||
throw new IllegalArgumentException("Script argument is mandatory.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute script
|
||||||
|
*
|
||||||
|
* @param location the location of the script
|
||||||
|
* @param model context model
|
||||||
|
* @return Object the result of the script
|
||||||
|
*/
|
||||||
|
protected Object execute(ScriptProcessor processor, ScriptLocation location, Map<String, Object> model)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("location", location);
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Executing script:\n" + location);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return processor.execute(location, model);
|
||||||
|
}
|
||||||
|
catch (Throwable err)
|
||||||
|
{
|
||||||
|
throw translateProcessingException(location.toString(), err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute script
|
||||||
|
*
|
||||||
|
* @param scriptRef the script node reference
|
||||||
|
* @param contentProp the content property of the script
|
||||||
|
* @param model the context model
|
||||||
|
* @return Object the result of the script
|
||||||
|
*/
|
||||||
|
protected Object execute(ScriptProcessor processor, NodeRef scriptRef, QName contentProp, Map<String, Object> model)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("scriptRef", scriptRef);
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Executing script:\n" + scriptRef);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return processor.execute(scriptRef, contentProp, model);
|
||||||
|
}
|
||||||
|
catch (Throwable err)
|
||||||
|
{
|
||||||
|
throw translateProcessingException(scriptRef.toString(), err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute script
|
||||||
|
*
|
||||||
|
* @param location the classpath string locating the script
|
||||||
|
* @param model the context model
|
||||||
|
* @return Object the result of the script
|
||||||
|
*/
|
||||||
|
protected Object execute(ScriptProcessor processor, String location, Map<String, Object> model)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatoryString("location", location);
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Executing script:\n" + location);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return processor.execute(location, model);
|
||||||
|
}
|
||||||
|
catch (Throwable err)
|
||||||
|
{
|
||||||
|
throw translateProcessingException(location, err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute script string
|
||||||
|
*
|
||||||
|
* @param script the script string
|
||||||
|
* @param model the context model
|
||||||
|
* @return Object the result of the script
|
||||||
|
*/
|
||||||
|
protected Object executeString(ScriptProcessor processor, String script, Map<String, Object> model)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatoryString("script", script);
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("Executing script:\n" + script);
|
logger.debug("Executing script:\n" + script);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ScriptProcessor scriptProcessor = lookupScriptProcessor(engine);
|
return processor.executeString(script, model);
|
||||||
return scriptProcessor.executeString(script, model);
|
|
||||||
}
|
|
||||||
catch (ScriptException err)
|
|
||||||
{
|
|
||||||
throw err;
|
|
||||||
}
|
}
|
||||||
catch (Throwable err)
|
catch (Throwable err)
|
||||||
{
|
{
|
||||||
throw new ScriptException("Failed to execute supplied script: " + err.getMessage(), err);
|
throw translateProcessingException("provided by caller", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ScriptException translateProcessingException(String scriptInfo, Throwable err)
|
||||||
|
{
|
||||||
|
ScriptException result = null;
|
||||||
|
String msg = "Failed to execute script " + (scriptInfo == null ? "" : scriptInfo);
|
||||||
|
if (logger.isWarnEnabled())
|
||||||
|
{
|
||||||
|
logger.warn(msg, err);
|
||||||
|
}
|
||||||
|
if (ScriptException.class.isAssignableFrom(err.getClass()))
|
||||||
|
{
|
||||||
|
result = (ScriptException)err;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = new ScriptException(msg, err);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to lookup the script proecessor based on a name
|
* Helper method to lookup the script processor based on a name
|
||||||
*
|
*
|
||||||
* @param name the name of the script processor
|
* @param name the name of the script processor
|
||||||
* @return ScriptProcessor the script processor, default processor if no match found
|
* @return ScriptProcessor the script processor, default processor if no match found
|
||||||
*/
|
*/
|
||||||
protected ScriptProcessor lookupScriptProcessor(String name)
|
protected ScriptProcessor lookupScriptProcessor(String name)
|
||||||
{
|
{
|
||||||
ScriptProcessor scriptProcessor = this.scriptProcessors.get(name);
|
ScriptProcessor scriptProcessor = (name == null ? null : this.scriptProcessors.get(name));
|
||||||
if (scriptProcessor == null)
|
if (scriptProcessor == null)
|
||||||
{
|
{
|
||||||
scriptProcessor = this.scriptProcessors.get(this.defaultScriptProcessor);
|
scriptProcessor = this.scriptProcessors.get(this.defaultScriptProcessor);
|
||||||
|
Reference in New Issue
Block a user