1 6 7 package org.contineo.actions.communication; 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.communication.EMailAccount; 19 import org.contineo.communication.dao.EMailAccountDAO; 20 import org.contineo.core.LoggingManager; 21 import org.contineo.core.SessionManagement; 22 23 28 public class EditAccountAction extends Action { 29 30 34 private Logger logger; 35 36 37 38 public EditAccountAction() { 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 session.setAttribute("helppage", "editaccount"); 50 String username = (String )session.getAttribute("authuser"); 51 String accountid = request.getParameter("accountid"); 52 int accountId = Integer.parseInt(accountid); 53 EMailAccountDAO accountDao = new EMailAccountDAO(); 54 EMailAccount account = accountDao.findByPrimaryKey(accountId); 55 if (username.equals(account.getUserName())) { 56 request.setAttribute("account", account); 57 actionForward = mapping.findForward("editaccount"); 58 } else 59 actionForward = mapping.findForward("noaccess"); 60 } catch (Exception e) { 61 if (logger.isEnabledFor(Level.ERROR)) 62 logger.error(e.getMessage()); 63 actionForward = mapping.findForward("error"); 64 } 65 } else 66 actionForward = mapping.findForward("invalid"); 67 return actionForward; 68 } 69 } 70
| Popular Tags
|