KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > methodhead > reg > SendPasswordForm


1 /*
2  * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
3  *
4  * This file is part of TransferCM.
5  *
6  * TransferCM is free software; you can redistribute it and/or modify it under the
7  * terms of the GNU General Public License as published by the Free Software
8  * Foundation; either version 2 of the License, or (at your option) any later
9  * version.
10  *
11  * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
18  * Fifth Floor, Boston, MA 02110-1301 USA
19  */

20
21 package com.methodhead.reg;
22
23 import java.io.Serializable JavaDoc;
24 import javax.servlet.http.HttpServletRequest JavaDoc;
25
26 import org.apache.struts.action.ActionMapping;
27 import org.apache.struts.action.ActionErrors;
28 import org.apache.struts.action.ActionError;
29 import org.apache.struts.validator.DynaValidatorForm;
30 import com.methodhead.reg.User;
31 import com.methodhead.reg.RegPolicy;
32 import com.methodhead.reg.Role;
33 import com.methodhead.util.StrutsUtil;
34 import com.methodhead.sitecontext.SiteContext;
35 import java.util.Iterator JavaDoc;
36
37 public class SendPasswordForm
38 extends
39   DynaValidatorForm
40 implements
41   Serializable JavaDoc {
42
43   public ActionErrors validate(
44     ActionMapping mapping,
45     HttpServletRequest JavaDoc request ) {
46
47     ActionErrors errors = super.validate( mapping, request );
48
49     if ( errors.isEmpty() ) {
50
51       //
52
// create a user
53
//
54
RegPolicy policy = ( RegPolicy )StrutsUtil.getPolicy( mapping );
55       User user = policy.newRegUser();
56
57       //
58
// does the user exist at all?
59
//
60
if ( !user.loadForLogin( ( String JavaDoc )get( "email" ) ) ) {
61         errors.add(
62           "email", new ActionError( "reg.sendpassword.noSuchUser" ) );
63       }
64     }
65
66     return errors;
67   }
68 }
69
Popular Tags