1 20 21 package com.methodhead.reg; 22 23 import java.io.Serializable ; 24 import javax.servlet.http.HttpServletRequest ; 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.aikp.AikpForm; 31 import com.methodhead.auth.AuthUtil; 32 import java.util.List ; 33 import java.util.ArrayList ; 34 import java.util.Iterator ; 35 import org.apache.struts.Globals; 36 import org.apache.struts.util.LabelValueBean; 37 import org.apache.struts.util.MessageResources; 38 import com.methodhead.sitecontext.SiteContext; 39 import com.methodhead.util.StrutsUtil; 40 import org.apache.commons.lang.StringUtils; 41 42 public class ProfileForm 43 extends 44 DynaValidatorForm 45 implements 46 Serializable { 47 48 public ActionErrors validate( 49 ActionMapping mapping, 50 HttpServletRequest request ) { 51 52 if ( !StringUtils.isBlank( ( String )get( "cancel" ) ) ) 56 return new ActionErrors(); 57 58 ActionErrors errors = super.validate( mapping, request ); 59 60 if ( !errors.isEmpty() ) 61 return errors; 62 63 RegPolicy policy = ( RegPolicy )StrutsUtil.getPolicy( mapping ); 67 User user = ( User )policy.newRegUser(); 68 69 if ( user.loadForLogin( ( String )get( "email" ) ) ) { 70 User cur = ( User )AuthUtil.getUser( request ); 71 if ( user.getInt( "id" ) != cur.getInt( "id" ) ) { 72 errors.add( 73 "email", new ActionError( "reg.profile.userExists" ) ); 74 return errors; 75 } 76 } 77 78 return errors; 79 } 80 } 81 | Popular Tags |