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 WorkflowDetailsAction 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: //get the workflow Id
29: WorkflowId workflowId = new WorkflowId(Integer
30: .parseInt(request.getParameter("workflowId")));
31: User user = new User("foo", "bar");
32:
33: //get workflow details for the workflow Id.
34: WorkflowState workflowState = WorkflowManager
35: .getWorkflowState(workflowId, user);
36:
37: //get all processes for the workflow Id.
38: Vector processes = workflowState.getActiveProcesses();
39:
40: //get all variables for the workflow Id.
41: HashMap variables = workflowState.getVariables();
42:
43: request.setAttribute("workflowState", workflowState);
44: request.setAttribute("processes", processes);
45: request.setAttribute("variables", variables);
46:
47: } catch (Exception e) {
48: e.printStackTrace();
49: target = "failure";
50: }
51:
52: // Forward to the appropriate View
53: return (mapping.findForward(target));
54: }
55: }
|