KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > killingar > forum > actions > user > Add


1 /* Copyright 2000-2005 Anders Hovmöller
2  *
3  * The person or persons who have associated their work with
4  * this document (the "Dedicator") hereby dedicate the entire
5  * copyright in the work of authorship identified below (the
6  * "Work") to the public domain.
7  *
8  * Dedicator makes this dedication for the benefit of the
9  * public at large and to the detriment of Dedicator's heirs
10  * and successors. Dedicator intends this dedication to be an
11  * overt act of relinquishment in perpetuity of all present
12  * and future rights under copyright law, whether vested or
13  * contingent, in the Work. Dedicator understands that such
14  * relinquishment of all rights includes the relinquishment of
15  * all rights to enforce (by lawsuit or otherwise) those
16  * copyrights in the Work.
17  *
18  * Dedicator recognizes that, once placed in the public
19  * domain, the Work may be freely reproduced, distributed,
20  * transmitted, used, modified, built upon, or otherwise
21  * exploited by anyone for any purpose, commercial or non-
22  * commercial, and in any way, including by methods that have
23  * not yet been invented or conceived.
24  */

25
26 package net.killingar.forum.actions.user;
27
28 import net.killingar.forum.internal.User;
29
30 public class Add extends Edit
31 {
32     // Private --------------------------------------------------------
33

34     // Attributes -----------------------------------------------------
35

36     // Types ----------------------------------------------------------
37

38     // Setters --------------------------------------------------------
39

40     // Getters --------------------------------------------------------
41

42     // Implementation -------------------------------------------------
43
protected void doValidation()
44   {
45         user.birthdate = new java.sql.Date JavaDoc(year-1900, month, date);
46
47         if (newpassword != null && !newpassword.equals(newpassword2))
48         addError("newpassword2", "passwords do not match");
49     }
50
51     protected String JavaDoc doExecute()
52     {
53         try
54         {
55             if (modify)
56             {
57                 userID = manager.addUser(user, newpassword);
58
59                 return SUCCESS;
60             }
61
62             user = new UserData(manager, new User());
63
64             user.groups = manager.getGroupsOfUser(userID);
65
66             user.email = net.killingar.forum.internal.Utils.unHTML(user.email );
67             user.icq = net.killingar.forum.internal.Utils.unHTML(user.icq );
68             user.telephone = net.killingar.forum.internal.Utils.unHTML(user.telephone );
69             user.mobilephone = net.killingar.forum.internal.Utils.unHTML(user.mobilephone );
70             user.address = net.killingar.forum.internal.Utils.unHTML(user.address );
71             user.other = net.killingar.forum.internal.Utils.unHTML(user.other );
72             user.realName = net.killingar.forum.internal.Utils.unHTML(user.realName );
73             user.publicEmail = net.killingar.forum.internal.Utils.unHTML(user.publicEmail );
74             user.restrictedEmail = net.killingar.forum.internal.Utils.unHTML(user.restrictedEmail);
75             user.secretEmail = net.killingar.forum.internal.Utils.unHTML(user.secretEmail );
76             user.birthdate = new java.sql.Date JavaDoc(year-1900, month, date);
77
78             return INPUT;
79         }
80         catch (Exception JavaDoc e)
81         {
82             e.printStackTrace();
83             addErrorMessage("executing "+getClass().toString()+" action failed, exception thrown: "+e.toString());
84             return ERROR;
85         }
86     }
87
88 }
89
Popular Tags