1 6 7 package org.contineo.actions.documan.util; 8 9 import javax.servlet.http.HttpServletRequest ; 10 import javax.servlet.http.HttpServletResponse ; 11 import javax.servlet.http.HttpSession ; 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.dao.MenuDAO; 19 import org.contineo.core.LoggingManager; 20 import org.contineo.core.SessionManagement; 21 import org.contineo.documan.Document; 22 import org.contineo.documan.dao.DocumentDAO; 23 import org.contineo.forms.CheckinForm; 24 28 public class CheckinAction extends Action { 29 30 34 private Logger logger; 35 36 37 38 public CheckinAction() { 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 String menuid = request.getParameter("menuid"); 49 try { 50 MenuDAO mdao = new MenuDAO(); 51 String username = (String )session.getAttribute("authuser"); 52 if (mdao.isWriteEnable(Integer.parseInt(menuid), username)) { 53 DocumentDAO ddao = new DocumentDAO(); 54 Document doc = ddao.findByMenuId(Integer.parseInt(menuid)); 55 if (doc.getDocStatus() == Document.DOC_CHECKED_OUT) { 56 CheckinForm cform = new CheckinForm(); 57 cform.setDocid(new Integer (doc.getDocId())); 58 cform.setDocName(doc.getDocName()); 59 request.setAttribute("document", cform); 60 actionForward = mapping.findForward("checkin"); 61 } else { 62 actionForward = mapping.findForward("noaccess"); 63 } 64 } else 65 actionForward = mapping.findForward("noaccess"); 66 } catch (Exception e) { 67 if (logger.isEnabledFor(Level.ERROR)) 68 logger.error(e.getMessage()); 69 actionForward = mapping.findForward("error"); 70 } 71 } else 72 actionForward = mapping.findForward("invalid"); 73 return actionForward; 74 } 75 } 76 | Popular Tags |