01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.workflow.timer;
06:
07: import com.opensymphony.workflow.Workflow;
08: import com.opensymphony.workflow.WorkflowException;
09: import com.opensymphony.workflow.basic.BasicWorkflow;
10: import com.opensymphony.workflow.config.Configuration;
11:
12: import org.quartz.Job;
13: import org.quartz.JobDataMap;
14: import org.quartz.JobExecutionContext;
15: import org.quartz.JobExecutionException;
16:
17: /**
18: * DOCUMENT ME!
19: *
20: */
21: public class LocalWorkflowJob implements Job {
22: //~ Methods ////////////////////////////////////////////////////////////////
23:
24: public void execute(JobExecutionContext jobExecutionContext)
25: throws JobExecutionException {
26: JobDataMap data = jobExecutionContext.getJobDetail()
27: .getJobDataMap();
28: long id = data.getLong("entryId");
29: int triggerId = data.getInt("triggerId");
30: String username = data.getString("username");
31: Workflow wf = new BasicWorkflow(username);
32: wf.setConfiguration((Configuration) data.get("configuration"));
33:
34: try {
35: wf.executeTriggerFunction(id, triggerId);
36: } catch (WorkflowException e) {
37: //this cast is a fairly horrible hack, but it's more due to the fact that quartz is stupid enough to have wrapped exceptions
38: //wrap Exception, instead of Throwable.
39: throw new JobExecutionException(
40: "Error Executing local job",
41: (e.getRootCause() != null) ? (Exception) e
42: .getRootCause() : e, true);
43: }
44: }
45: }
|