1 4 package org.contineo.actions.documan.util; 5 6 import java.util.Collection ; 7 8 import javax.servlet.http.HttpServletRequest ; 9 import javax.servlet.http.HttpServletResponse ; 10 import javax.servlet.http.HttpSession ; 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 28 public class ShowHistoryAction extends Action { 29 30 private Logger logger; 31 32 33 public ShowHistoryAction() { 34 logger = LoggingManager.getLogger(this.getClass()); 35 } 36 37 public ActionForward execute(ActionMapping mapping, 38 ActionForm form, HttpServletRequest request, 39 HttpServletResponse response) { 40 ActionForward actionForward = new ActionForward(); 41 HttpSession session = request.getSession(); 42 if (SessionManagement.isValid(session)) { 43 try { 44 String menuId = request.getParameter("menuid"); 45 DocumentDAO docDao = new DocumentDAO(); 46 Document doc = docDao.findByMenuId(Integer.parseInt(menuId)); 47 HistoryDAO historyDao = new HistoryDAO(); 48 Collection coll = historyDao.findByDocId(doc.getDocId()); 49 request.setAttribute("histories", coll); 50 } catch (Exception 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 |