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 UpdateVariableAction 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: WorkflowId workflowId = new WorkflowId(Integer
29: .parseInt(request.getParameter("workflowId")));
30: User user = new User("foo", "bar");
31: String variableName = request.getParameter("variableName");
32: Object variableValue = request
33: .getParameter("variableValue");
34:
35: WorkflowManager.setVariable(workflowId, variableName,
36: variableValue, user);
37:
38: request.setAttribute("workflowId", "" + workflowId.getId());
39:
40: } catch (Exception e) {
41: e.printStackTrace();
42: target = "failure";
43: }
44:
45: // Forward to the appropriate View
46: return (mapping.findForward(target));
47: }
48: }
|