1 package org.nextime.ion.backoffice.action.content; 2 3 import java.io.IOException ; 4 import java.util.Hashtable ; 5 import javax.servlet.ServletException ; 6 import javax.servlet.http.HttpServletRequest ; 7 import javax.servlet.http.HttpServletResponse ; 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 request, 25 HttpServletResponse response) 26 throws IOException , ServletException { 27 28 checkUser(request); 30 31 String id = 32 (request.getAttribute("id") == null) 33 ? request.getParameter("id") 34 : request.getAttribute("id") + ""; 35 String sAction = 36 (request.getAttribute("action") == null) 37 ? request.getParameter("action") 38 : request.getAttribute("action") + ""; 39 String 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 try { 49 Mapping.begin(); 50 51 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 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 ) request.getAttribute("inputs")); 74 } 75 Mapping.commit(); 76 } catch (Exception e) { 77 throw new ServletException (e); 78 } finally { 79 Mapping.rollback(); 80 } 81 82 return new ActionForward(request.getParameter("retour")); 84 85 } 86 87 } 88 | Popular Tags |