diff options
Diffstat (limited to 'src/main/java/com/c2kernel/entity/proxy')
| -rw-r--r-- | src/main/java/com/c2kernel/entity/proxy/AgentProxy.java | 110 |
1 files changed, 72 insertions, 38 deletions
diff --git a/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java b/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java index 1f24229..188c393 100644 --- a/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java +++ b/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java @@ -82,21 +82,28 @@ public class AgentProxy extends ItemProxy }
/**
- * Executes a job on the given item using this agent.
+ * Standard execution of jobs. Note that this method should always be the one used from clients - all execution
+ * parameters are taken from the job where they're probably going to be correct.
*
- * @param item - item holding this job
- * @param job - the job to execute
+ * @param job
+ * @throws AccessRightsException
+ * @throws InvalidDataException
+ * @throws InvalidTransitionException
+ * @throws ObjectNotFoundException
+ * @throws PersistencyException
+ * @throws ObjectAlreadyExistsException
* @throws ScriptErrorException
*/
- protected String execute(ItemProxy item, Job job)
+ public String execute(Job job)
throws AccessRightsException,
- InvalidTransitionException,
- ObjectNotFoundException,
- InvalidDataException,
- PersistencyException,
- ObjectAlreadyExistsException,
- ScriptErrorException
+ InvalidDataException,
+ InvalidTransitionException,
+ ObjectNotFoundException,
+ PersistencyException,
+ ObjectAlreadyExistsException,
+ ScriptErrorException
{
+ ItemProxy item = Gateway.getProxyManager().getProxy(job.getItemPath());
OutcomeValidator validator = null;
Date startTime = new Date();
Logger.msg(3, "AgentProxy - executing "+job.getStepPath()+" for "+mAgentPath.getAgentName());
@@ -173,32 +180,6 @@ public class AgentProxy extends ItemProxy return script.execute();
}
- /**
- * Standard execution of jobs. Note that this method should always be the one used from clients - all execution
- * parameters are taken from the job where they're probably going to be correct.
- *
- * @param job
- * @throws AccessRightsException
- * @throws InvalidDataException
- * @throws InvalidTransitionException
- * @throws ObjectNotFoundException
- * @throws PersistencyException
- * @throws ObjectAlreadyExistsException
- * @throws ScriptErrorException
- */
- public String execute(Job job)
- throws AccessRightsException,
- InvalidDataException,
- InvalidTransitionException,
- ObjectNotFoundException,
- PersistencyException,
- ObjectAlreadyExistsException,
- ScriptErrorException
- {
- ItemProxy targetItem = Gateway.getProxyManager().getProxy(job.getItemPath());
- return execute(targetItem, job);
- }
-
public String execute(ItemProxy item, String predefStep, C2KLocalObject obj)
throws AccessRightsException,
InvalidDataException,
@@ -217,7 +198,25 @@ public class AgentProxy extends ItemProxy return execute(item, predefStep, param);
}
- public String execute(ItemProxy item, String predefStep, String... params)
+ /**
+ * Multi-parameter execution. Wraps parameters up in a PredefinedStepOutcome
+ * if the schema of the requested step is such.
+ *
+ * @param item The item on which to execute the step
+ * @param predefStep The step name to run
+ * @param params An array of parameters to pass to the step. See each step's
+ * documentation for its required parameters
+ *
+ * @return The outcome after processing. May have been altered by the step.
+ *
+ * @throws AccessRightsException The agent was not allowed to execute this step
+ * @throws InvalidDataException The parameters supplied were incorrect
+ * @throws InvalidTransitionException The step wasn't available
+ * @throws ObjectNotFoundException Thrown by some steps that try to locate additional objects
+ * @throws PersistencyException Problem writing or reading the database
+ * @throws ObjectAlreadyExistsException Thrown by steps that create additional object
+ */
+ public String execute(ItemProxy item, String predefStep, String[] params)
throws AccessRightsException,
InvalidDataException,
InvalidTransitionException,
@@ -225,7 +224,42 @@ public class AgentProxy extends ItemProxy PersistencyException,
ObjectAlreadyExistsException
{
- return item.getItem().requestAction(mAgentPath.getSystemKey(), "workflow/predefined/"+predefStep, PredefinedStep.DONE, PredefinedStep.bundleData(params));
+ String schemaName = PredefinedStep.getPredefStepSchemaName(predefStep);
+ String param;
+ if (schemaName.equals("PredefinedStepOutcome"))
+ param = PredefinedStep.bundleData(params);
+ else
+ param = params[0];
+
+ return item.getItem().requestAction(mAgentPath.getSystemKey(), "workflow/predefined/"+predefStep, PredefinedStep.DONE, param);
+ }
+
+ /**
+ * Single parameter execution
+ *
+ * @see #execute(ItemProxy, String, String[])
+ *
+ * @param item
+ * @param predefStep
+ * @param param
+ * @return
+ * @throws AccessRightsException
+ * @throws InvalidDataException
+ * @throws InvalidTransitionException
+ * @throws ObjectNotFoundException
+ * @throws PersistencyException
+ * @throws ObjectAlreadyExistsException
+ */
+
+ public String execute(ItemProxy item, String predefStep, String param)
+ throws AccessRightsException,
+ InvalidDataException,
+ InvalidTransitionException,
+ ObjectNotFoundException,
+ PersistencyException,
+ ObjectAlreadyExistsException
+ {
+ return execute(item, predefStep, new String[] {param });
}
/** Wrappers for scripts */
|
