diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2012-07-12 14:52:36 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2012-07-12 14:52:36 +0200 |
| commit | 20c81748688547c1b13686f15c65fbb1d60d81a0 (patch) | |
| tree | 59dc2b94c47ed30b8bc93c07cab42e96904d1146 /src/main/java/com/c2kernel/entity/proxy | |
| parent | 61559eef9369dbdbb027bec7c571d7f770b2e7a3 (diff) | |
Suspend transition now can carry an optional 'Errors' outcome where
client processes can record the reason for the suspension. Errors XML is
marshalled ErrorInfo. UserCodeProcess automatically sends fatal
ErrorInfos through suspend jobs.
Job API added to to support all this.
fixes #23
Diffstat (limited to 'src/main/java/com/c2kernel/entity/proxy')
| -rw-r--r-- | src/main/java/com/c2kernel/entity/proxy/AgentProxy.java | 31 | ||||
| -rw-r--r-- | src/main/java/com/c2kernel/entity/proxy/ItemProxy.java | 2 |
2 files changed, 16 insertions, 17 deletions
diff --git a/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java b/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java index 5c6a37e..286be88 100644 --- a/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java +++ b/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java @@ -36,6 +36,7 @@ import com.c2kernel.persistency.outcome.Schema; import com.c2kernel.process.Gateway;
import com.c2kernel.scripting.ErrorInfo;
import com.c2kernel.scripting.Script;
+import com.c2kernel.scripting.ScriptErrorException;
import com.c2kernel.scripting.ScriptingEngineException;
import com.c2kernel.utils.LocalObjectLoader;
import com.c2kernel.utils.Logger;
@@ -98,6 +99,7 @@ public class AgentProxy extends EntityProxy *
* @param item - item holding this job
* @param job - the job to execute
+ * @throws ScriptErrorException
*/
public void execute(ItemProxy item, Job job)
throws AccessRightsException,
@@ -105,24 +107,19 @@ public class AgentProxy extends EntityProxy ObjectNotFoundException,
InvalidDataException,
PersistencyException,
- ObjectAlreadyExistsException
+ ObjectAlreadyExistsException,
+ ScriptErrorException
{
OutcomeValidator validator = null;
String scriptName = job.getActPropString("ScriptName");
Date startTime = new Date();
Logger.msg(3, "AgentProxy - executing "+job.getStepPath()+" for "+path.getAgentName());
// get the outcome validator if present
- if (job.isOutcomeUsed())
+ if (job.isOutcomeSet())
{
+ String schemaName = job.getSchemaType();
+ int schemaVersion = job.getSchemaVersion();
- // get schema info from act props
- String schemaName = job.getActPropString("SchemaType");
- int schemaVersion;
- try {
- schemaVersion = Integer.parseInt(job.getActPropString("SchemaVersion"));
- } catch (Exception e) {
- throw new InvalidDataException(e.getClass().getName()+" extracing schema version", "");
- }
Logger.msg(5, "AgentProxy - fetching schema "+schemaName+"_"+schemaVersion+" for validation");
// retrieve schema
Schema schema = LocalObjectLoader.getSchema(schemaName, schemaVersion);
@@ -155,20 +152,20 @@ public class AgentProxy extends EntityProxy // load script
ErrorInfo scriptErrors = (ErrorInfo)callScript(item, job);
+ String errorString = scriptErrors.toString();
if (scriptErrors.getFatal()) {
Logger.msg(3, "AgentProxy - fatal script error");
- Logger.error(scriptErrors.getErrors());
- throw new InvalidDataException("Fatal Script Error: \n"+scriptErrors.getErrors(), "");
+ throw new ScriptErrorException(scriptErrors);
}
- if (scriptErrors.getErrors().length() > 0)
- Logger.warning("Script errors: "+scriptErrors.getErrors());
+ if (errorString.length() > 0)
+ Logger.warning("Script errors: "+errorString);
} catch (ScriptingEngineException ex) {
Logger.error(ex);
throw new InvalidDataException(ex.getMessage(), "");
}
}
- if (job.isOutcomeUsed()) {
+ if (job.isOutcomeSet()) {
Logger.msg(3, "AgentProxy - validating outcome");
String error = validator.validate(job.getOutcomeString());
if (error.length() > 0)
@@ -201,6 +198,7 @@ public class AgentProxy extends EntityProxy * @throws ObjectNotFoundException
* @throws PersistencyException
* @throws ObjectAlreadyExistsException
+ * @throws ScriptErrorException
*/
public void execute(Job job)
throws AccessRightsException,
@@ -208,7 +206,8 @@ public class AgentProxy extends EntityProxy InvalidTransitionException,
ObjectNotFoundException,
PersistencyException,
- ObjectAlreadyExistsException
+ ObjectAlreadyExistsException,
+ ScriptErrorException
{
try {
ItemProxy targetItem = (ItemProxy)Gateway.getProxyManager().getProxy(new EntityPath(job.getItemSysKey()));
diff --git a/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java b/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java index dcaef55..55e1fe9 100644 --- a/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java +++ b/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java @@ -105,7 +105,7 @@ public class ItemProxy extends EntityProxy String outcome = thisJob.getOutcomeString();
// check fields that should have been filled in
if (outcome==null)
- if (thisJob.isOutcomeUsed())
+ if (thisJob.requiresOutcome())
throw new InvalidDataException("Outcome is required.", "");
else
outcome="";
|
