KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > contineo > actions > communication > EditAccountAction


1 /*
2  * ChangePasswordAction.java
3  *
4  * Created on 16. Dezember 2003, 22:25
5  */

6
7 package org.contineo.actions.communication;
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.communication.EMailAccount;
19 import org.contineo.communication.dao.EMailAccountDAO;
20 import org.contineo.core.LoggingManager;
21 import org.contineo.core.SessionManagement;
22
23 /**
24  *
25  * @author Michael Scholz
26  * @version 1.0
27  */

28 public class EditAccountAction 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 ChangePasswordAction */
38     public EditAccountAction() {
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         HttpSession JavaDoc session = request.getSession();
47         if (SessionManagement.isValid(session)) {
48             try {
49                 session.setAttribute("helppage", "editaccount");
50                 String JavaDoc username = (String JavaDoc)session.getAttribute("authuser");
51                 String JavaDoc 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 JavaDoc 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