KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * DocMenuAction.java
3  *
4  * Created on 27. Oktober 2003, 17:21
5  */

6
7 package org.contineo.actions.documan.util;
8
9 import javax.servlet.http.HttpServletRequest JavaDoc;
10 import javax.servlet.http.HttpServletResponse JavaDoc;
11 import javax.servlet.http.HttpSession JavaDoc;
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.admin.Menu;
19 import org.contineo.admin.dao.MenuDAO;
20 import org.contineo.core.LoggingManager;
21 import org.contineo.core.SessionManagement;
22 import org.contineo.documan.Document;
23 import org.contineo.documan.dao.DocumentDAO;
24 /**
25  *
26  * @author Michael Scholz
27  */

28 public class DocMenuAction extends Action {
29
30     /**
31      * @uml.property name="logger"
32      * @uml.associationEnd
33      */

34     private Logger logger;
35
36     
37     /** Creates a new instance of DocMenuAction */
38     public DocMenuAction() {
39         logger = LoggingManager.getLogger(this.getClass());
40     }
41
42     public ActionForward execute(ActionMapping mapping,
43                     ActionForm form, HttpServletRequest JavaDoc request,
44                     HttpServletResponse JavaDoc response) {
45         ActionForward actionForward = new ActionForward();
46         String JavaDoc menuid = request.getParameter("menuid");
47         HttpSession JavaDoc session = request.getSession();
48         if (SessionManagement.isValid(session)) {
49             String JavaDoc username = (String JavaDoc)session.getAttribute("authuser");
50             try {
51                 int id = Integer.parseInt(menuid);
52                 MenuDAO menuDao = new MenuDAO();
53                 if (menuDao.isReadEnable(id, username)) {
54                     Menu menu = menuDao.findByPrimaryKey(id);
55                     request.setAttribute("parent", String.valueOf(menu.getMenuParent()));
56                     DocumentDAO docDao = new DocumentDAO();
57                     Document doc = docDao.findByMenuId(id);
58                     request.setAttribute("document", doc);
59                     boolean isWritable = menuDao.isWriteEnable(id, username);
60                     request.setAttribute("writable", Boolean.valueOf(isWritable));
61                     actionForward = mapping.findForward("docmenu");
62                 } else
63                     actionForward = mapping.findForward("noaccess");
64             } catch (Exception JavaDoc e) {
65                 if (logger.isEnabledFor(Level.ERROR))
66                     logger.error(e.getMessage());
67                 actionForward = mapping.findForward("error");
68             }
69         } else
70             actionForward = mapping.findForward("invalid");
71         return actionForward;
72     }
73 }
74
Popular Tags