KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > contineo > actions > documan > util > ShowHistoryAction


1 /*
2  * Created on 23.08.2004
3  */

4 package org.contineo.actions.documan.util;
5
6 import java.util.Collection JavaDoc;
7
8 import javax.servlet.http.HttpServletRequest JavaDoc;
9 import javax.servlet.http.HttpServletResponse JavaDoc;
10 import javax.servlet.http.HttpSession JavaDoc;
11
12 import org.apache.log4j.Level;
13 import org.apache.log4j.Logger;
14 import org.apache.struts.action.Action;
15 import org.apache.struts.action.ActionForm;
16 import org.apache.struts.action.ActionForward;
17 import org.apache.struts.action.ActionMapping;
18 import org.contineo.core.LoggingManager;
19 import org.contineo.core.SessionManagement;
20 import org.contineo.documan.Document;
21 import org.contineo.documan.dao.DocumentDAO;
22 import org.contineo.documan.dao.HistoryDAO;
23
24 /**
25  * @author Michael Scholz
26  *
27  */

28 public class ShowHistoryAction extends Action {
29
30     private Logger logger;
31
32     /** Creates a new instance of StrutsAction */
33     public ShowHistoryAction() {
34         logger = LoggingManager.getLogger(this.getClass());
35     }
36
37     public ActionForward execute(ActionMapping mapping,
38                     ActionForm form, HttpServletRequest JavaDoc request,
39                     HttpServletResponse JavaDoc response) {
40         ActionForward actionForward = new ActionForward();
41         HttpSession JavaDoc session = request.getSession();
42         if (SessionManagement.isValid(session)) {
43             try {
44                 String JavaDoc menuId = request.getParameter("menuid");
45                 DocumentDAO docDao = new DocumentDAO();
46                 Document doc = docDao.findByMenuId(Integer.parseInt(menuId));
47                 HistoryDAO historyDao = new HistoryDAO();
48                 Collection JavaDoc coll = historyDao.findByDocId(doc.getDocId());
49                 request.setAttribute("histories", coll);
50             } catch (Exception JavaDoc e) {
51                 if (logger.isEnabledFor(Level.ERROR))
52                     logger.error(e.getMessage());
53             }
54             actionForward = mapping.findForward("showhistory");
55         } else
56             actionForward = mapping.findForward("invalid");
57         return actionForward;
58     }
59 }
60
Popular Tags