1 6 7 package org.contineo.actions.documan.document; 8 9 import java.util.Collection ; 10 import javax.servlet.http.HttpServletRequest ; 11 import javax.servlet.http.HttpServletResponse ; 12 import javax.servlet.http.HttpSession ; 13 import org.apache.log4j.Level; 14 import org.apache.log4j.Logger; 15 import org.apache.struts.action.Action; 16 import org.apache.struts.action.ActionForm; 17 import org.apache.struts.action.ActionForward; 18 import org.apache.struts.action.ActionMapping; 19 import org.contineo.core.LoggingManager; 20 import org.contineo.core.SessionManagement; 21 import org.contineo.documan.Document; 22 import org.contineo.documan.dao.ArticleDAO; 23 import org.contineo.documan.dao.DocumentDAO; 24 29 public class ShowArticlesAction extends Action { 30 31 35 private Logger logger; 36 37 38 public ShowArticlesAction() { 39 logger = LoggingManager.getLogger(this.getClass()); 40 } 41 42 public ActionForward execute(ActionMapping mapping, 43 ActionForm form, HttpServletRequest request, 44 HttpServletResponse response) { 45 ActionForward actionForward = new ActionForward(); 46 HttpSession session = request.getSession(); 47 if (SessionManagement.isValid(session)) { 48 try { 49 String menuid = request.getParameter("menuid"); 50 String docid = request.getParameter("docid"); 51 if (docid == null || docid.equals("")) { 52 DocumentDAO docDao = new DocumentDAO(); 53 Document doc = docDao.findByMenuId(Integer.parseInt(menuid)); 54 docid = String.valueOf(doc.getDocId()); 55 } 56 ArticleDAO artDao = new ArticleDAO(); 57 Collection coll = artDao.findByDocId(Integer.parseInt(docid)); 58 request.setAttribute("articles", coll); 59 request.setAttribute("docid", docid); 60 } catch (Exception e) { 61 if (logger.isEnabledFor(Level.ERROR)) 62 logger.error(e.getMessage()); 63 } 64 actionForward = mapping.findForward("showarticles"); 65 } else 66 actionForward = mapping.findForward("invalid"); 67 return actionForward; 68 } 69 } | Popular Tags |