KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Created on 14.04.2004
3  *
4  * To change the template for this generated file go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */

7 package org.contineo.actions.communication;
8
9 import java.util.Collection JavaDoc;
10 import javax.servlet.http.HttpServletRequest JavaDoc;
11 import javax.servlet.http.HttpServletResponse JavaDoc;
12 import javax.servlet.http.HttpSession JavaDoc;
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.communication.dao.EMailAccountDAO;
20 import org.contineo.core.LoggingManager;
21 import org.contineo.core.SessionManagement;
22
23 /**
24  * @author Michael Scholz
25  *
26  * To change the template for this generated type comment go to
27  * Window>Preferences>Java>Code Generation>Code and Comments
28  */

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

35     private Logger logger;
36
37     /**
38      *
39      */

40     public ShowAccountsAction() {
41         logger = LoggingManager.getLogger(this.getClass());
42     }
43     
44     public ActionForward execute(ActionMapping mapping,
45                     ActionForm form, HttpServletRequest JavaDoc request,
46                     HttpServletResponse JavaDoc response) {
47         ActionForward actionForward = new ActionForward();
48         HttpSession JavaDoc session = request.getSession();
49         if (SessionManagement.isValid(session)) {
50             try {
51                 String JavaDoc username = (String JavaDoc)session.getAttribute("authuser");
52                 EMailAccountDAO accountDao = new EMailAccountDAO();
53                 Collection JavaDoc accounts = accountDao.findByUserName(username);
54                 request.setAttribute("accounts", accounts);
55                 actionForward = mapping.findForward("showaccounts");
56             } catch (Exception JavaDoc e) {
57                 if (logger.isEnabledFor(Level.ERROR))
58                     logger.error(e.getMessage());
59                 actionForward = mapping.findForward("showaccounts");
60             }
61         } else
62             actionForward = mapping.findForward("invalid");
63         return actionForward;
64     }
65 }
66
Popular Tags