KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nextime > ion > backoffice > action > content > ActionsAction


1 package org.nextime.ion.backoffice.action.content;
2
3 import java.io.IOException JavaDoc;
4 import java.util.Hashtable JavaDoc;
5 import javax.servlet.ServletException JavaDoc;
6 import javax.servlet.http.HttpServletRequest JavaDoc;
7 import javax.servlet.http.HttpServletResponse JavaDoc;
8 import org.apache.struts.action.ActionForm;
9 import org.apache.struts.action.ActionForward;
10 import org.apache.struts.action.ActionMapping;
11 import org.nextime.ion.backoffice.action.BaseAction;
12
13 import org.nextime.ion.framework.business.Publication;
14 import org.nextime.ion.framework.business.PublicationVersion;
15 import org.nextime.ion.framework.business.User;
16 import org.nextime.ion.framework.mapping.Mapping;
17 import org.nextime.ion.framework.workflow.WorkflowAction;
18
19 public class ActionsAction extends BaseAction {
20
21     public ActionForward perform(
22         ActionMapping mapping,
23         ActionForm form,
24         HttpServletRequest JavaDoc request,
25         HttpServletResponse JavaDoc response)
26         throws IOException JavaDoc, ServletException JavaDoc {
27
28         // check if user is correctly logged
29
checkUser(request);
30
31         String JavaDoc id =
32             (request.getAttribute("id") == null)
33                 ? request.getParameter("id")
34                 : request.getAttribute("id") + "";
35         String JavaDoc sAction =
36             (request.getAttribute("action") == null)
37                 ? request.getParameter("action")
38                 : request.getAttribute("action") + "";
39         String JavaDoc sVersion =
40             (request.getAttribute("version") == null)
41                 ? request.getParameter("version")
42                 : request.getAttribute("version") + "";
43
44         int action = Integer.parseInt(sAction);
45         int version = Integer.parseInt(sVersion);
46
47         // execute the action
48
try {
49             Mapping.begin();
50
51             // il y a une action externe à effectuer ?
52
PublicationVersion publi =
53                 Publication.getInstance(id).getVersion(version);
54
55             WorkflowAction Waction =
56                 publi
57                     .getWorkflow(
58                         User.getInstance(
59                             request.getSession().getAttribute("userLogin")
60                                 + ""))
61                     .getAction(action);
62
63             String JavaDoc external = Waction.getExternalAction();
64
65             if (external != null && request.getAttribute("inputs") == null) {
66                 request.setAttribute("externalAction", external);
67                 return new ActionForward(request.getParameter("externalTemplate"));
68             }
69
70             if (request.getAttribute("inputs") == null) {
71                 Waction.execute();
72             } else {
73                 Waction.execute((Hashtable JavaDoc) request.getAttribute("inputs"));
74             }
75             Mapping.commit();
76         } catch (Exception JavaDoc e) {
77             throw new ServletException JavaDoc(e);
78         } finally {
79             Mapping.rollback();
80         }
81
82         // Forward to the next page
83
return new ActionForward(request.getParameter("retour"));
84
85     }
86
87 }
88
Popular Tags