KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.nextime.ion.backoffice.action.content;
2
3
4 import java.io.IOException JavaDoc;
5 import java.util.Collections JavaDoc;
6 import java.util.Vector JavaDoc;
7
8 import javax.servlet.ServletException JavaDoc;
9 import javax.servlet.http.HttpServletRequest JavaDoc;
10 import javax.servlet.http.HttpServletResponse JavaDoc;
11
12 import org.apache.struts.action.ActionForm;
13 import org.apache.struts.action.ActionForward;
14 import org.apache.struts.action.ActionMapping;
15 import org.nextime.ion.backoffice.action.BaseAction;
16 import org.nextime.ion.framework.business.Publication;
17 import org.nextime.ion.framework.mapping.Mapping;
18
19 public class HistoryPublicationAction extends BaseAction {
20
21     public ActionForward perform(ActionMapping mapping,
22                                  ActionForm form,
23                                  HttpServletRequest JavaDoc request,
24                                  HttpServletResponse JavaDoc response)
25         throws IOException JavaDoc, ServletException JavaDoc {
26             
27         // check if user is correctly logged
28
checkUser(request);
29         
30         String JavaDoc id = request.getParameter("id");
31         int version = Integer.parseInt(request.getParameter("version"));
32         
33         try {
34             Mapping.begin();
35             
36             Publication publication = Publication.getInstance(id);
37             Vector JavaDoc history = publication.getVersion(version).getWorkflow().getHistorySteps();
38             Vector JavaDoc current = publication.getVersion(version).getWorkflow().getCurrentSteps();
39             Collections.reverse(history);
40             Collections.reverse(current);
41             request.setAttribute("history", history);
42             request.setAttribute("current", current);
43             
44             Mapping.rollback();
45         } catch( Exception JavaDoc e ) {
46             Mapping.rollback();
47             throw new ServletException JavaDoc(e);
48         }
49         
50         // Forward to the next page
51
return (mapping.findForward("view"));
52
53     }
54
55 }
56
Popular Tags