01: package xflow.action;
02:
03: import java.io.IOException;
04: import java.util.*;
05: import javax.servlet.*;
06: import javax.servlet.http.*;
07:
08: import org.apache.struts.action.*;
09: import org.apache.struts.Globals;
10:
11: import xflow.client.*;
12: import xflow.security.*;
13: import xflow.common.*;
14: import xflow.forms.*;
15:
16: public class StartWorkflowAction extends Action {
17:
18: public ActionForward execute(ActionMapping mapping,
19: ActionForm form, HttpServletRequest request,
20: HttpServletResponse response) throws IOException,
21: ServletException {
22:
23: // Default target to success
24: String target = new String("success");
25:
26: try {
27:
28: User user = new User("foo", "bar");
29:
30: String workflowName = request.getParameter("workflowName");
31:
32: int workflowVersion = Integer.parseInt(request
33: .getParameter("modelVersion"));
34: WorkItem workItem = new WorkItem();
35: workItem.setPayload(request.getParameter("payload"));
36: workItem
37: .setPayloadType(request.getParameter("payloadType"));
38: workItem.setWorkflowId(null);
39:
40: WorkflowManager.startWorkflow(workflowName,
41: workflowVersion, workItem, user);
42:
43: } catch (Exception e) {
44: e.printStackTrace();
45: target = "failure";
46: }
47:
48: // Forward to the appropriate View
49: return (mapping.findForward(target));
50: }
51: }
|