KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > struts > actions > UserPreferencesAction


1 package hero.struts.actions;
2
3 import java.io.IOException JavaDoc;
4 import javax.servlet.ServletException JavaDoc;
5 import javax.servlet.http.HttpServletRequest JavaDoc;
6 import javax.servlet.http.HttpServletResponse JavaDoc;
7 import org.apache.struts.action.ActionError;
8 import org.apache.struts.action.ActionErrors;
9 import org.apache.struts.action.ActionForm;
10 import org.apache.struts.action.ActionMapping;
11 import org.apache.struts.action.ActionForward;
12
13 import hero.struts.forms.*;
14 import hero.interfaces.*;
15
16
17 /**
18  * <strong>UserPreferencesAction</strong>
19  * Action that allows the admin to add new users
20  *
21  *@author Miguel Valdes Faura
22  */

23
24 public class UserPreferencesAction extends AbstStrutsActionBase
25 {
26   public boolean authenticate(String JavaDoc username, String JavaDoc password)
27   {
28     return(true);
29   }
30     /**
31      * @param mapping The ActionMapping used to select this instance
32      * @param actionForm The optional AbstActionFormBase bean for this request (if any)
33      * @param request The HTTP request we are processing
34      * @param response The HTTP response we are creating
35      * @exception IOException if an input/output error occurs
36      * @exception ServletException if a servlet exception occurs
37      */

38     public ActionForward perform(ActionMapping mapping, ActionForm form,
39         HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws IOException JavaDoc, ServletException JavaDoc
40     {
41         ActionForward actionForward;
42         // Create the container for any errors that occur
43
ActionErrors errors = new ActionErrors();
44
45     actionForward = mapping.findForward(LOGIN);
46
47     UserPreferencesForm upForm = (UserPreferencesForm) form;
48     String JavaDoc startMail = request.getParameter("startMail");
49     String JavaDoc startJabber = request.getParameter("startJabber");
50     String JavaDoc terminateMail = request.getParameter("terminateMail");
51     String JavaDoc terminateJabber = request.getParameter("terminateJabber");
52     String JavaDoc addNodeMail = request.getParameter("addNodeMail");
53     String JavaDoc addNodeJabber = request.getParameter("addNodeJabber");
54     String JavaDoc addEdgeMail = request.getParameter("addEdgeMail");
55     String JavaDoc addEdgeJabber = request.getParameter("addEdgeJabber");
56     String JavaDoc nodeStateMail = request.getParameter("nodeStateMail");
57     String JavaDoc nodeStateJabber = request.getParameter("nodeStateJabber");
58     String JavaDoc nodeDeadlineMail = request.getParameter("nodeDeadlineMail");
59     String JavaDoc nodeDeadlineJabber = request.getParameter("nodeDeadlineJabber");
60
61
62     try
63     {
64         hero.interfaces.UserRegistrationLocalHome userh = (UserRegistrationLocalHome)hero.interfaces.UserRegistrationUtil.getLocalHome();
65         hero.interfaces.UserRegistrationLocal user = userh.create();
66         if (!isCancelled(request))
67         {
68
69         String JavaDoc username = (String JavaDoc)request.getSession(true).getAttribute("newusername");
70         
71         user.setUserProperty(username,hero.util.EventConstants.START+"Mail",startMail);
72         user.setUserProperty(username,hero.util.EventConstants.START+"Jabber",startJabber);
73         user.setUserProperty(username,hero.util.EventConstants.TERMINATED+"Mail",terminateMail);
74         user.setUserProperty(username,hero.util.EventConstants.TERMINATED+"Jabber",terminateJabber);
75         user.setUserProperty(username,hero.util.EventConstants.ADDNODE+"Mail",addNodeMail);
76         user.setUserProperty(username,hero.util.EventConstants.ADDNODE+"Jabber",addNodeJabber);
77         user.setUserProperty(username,hero.util.EventConstants.ADDEDGE+"Mail",addEdgeMail);
78         user.setUserProperty(username,hero.util.EventConstants.ADDEDGE+"Jabber",addEdgeJabber);
79         
80         user.setUserProperty(username,hero.util.EventConstants.SETNODESTATE+"Mail",nodeStateMail);
81         user.setUserProperty(username,hero.util.EventConstants.SETNODESTATE+"Jabber",nodeStateJabber);
82         user.setUserProperty(username,hero.util.EventConstants.SETNODEDEADLINE+"Mail",nodeDeadlineMail);
83         user.setUserProperty(username,hero.util.EventConstants.SETNODEDEADLINE+"Jabber",nodeDeadlineJabber);
84         }
85         
86         }catch(Exception JavaDoc e1){errors.add("user_error", new ActionError("error.setProperty.mismatch"));}
87         if (!errors.empty()) {
88         saveErrors(request, errors);
89         }
90     
91     // Forward control to the appropriate URI as determined by the action.
92
return (actionForward);
93     }
94 }
95
Popular Tags