Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/clra/web/ValidateMemberRoleAndStatus.java


1   /*
2    * Copyright (c) Carnegie Lake Rowing Association 2002. All rights reserved.
3    * Distributed under the GPL license. See doc/COPYING.
4    * $RCSfile: ValidateMemberRoleAndStatus.java,v $
5    * $Date: 2003/02/26 03:38:46 $
6    * $Revision: 1.4 $
7    */
8   
9   package com.clra.web;
10  
11  import com.clra.member.AccountType;
12  import com.clra.member.MemberRole;
13  import org.apache.struts.action.ActionError;
14  import org.apache.struts.action.ActionErrors;
15  
16  /**
17   * Checks whether a member's role and status are valid and consistent.
18   *
19   * @version $Id: ValidateMemberRoleAndStatus.java,v 1.4 2003/02/26 03:38:46 rphall Exp $
20   * @author <a href="mailto:rphall@pluto.njcc.com">Rick Hall</a>
21   */
22  class ValidateMemberRoleAndStatus extends ValidateMember {
23  
24    public final static String PROPERTY_TYPE_ROLES = "accountTypeAndRoles";
25  
26    ValidateMemberRoleAndStatus( MemberInfoForm f ) {
27      super( f );
28    }
29  
30    /**
31     * Checks whether a member's roles and account-type are valid and consistent.
32     */
33    void validate( ActionErrors errors ) {
34  
35      if ( errors == null ) {
36        throw new IllegalArgumentException( "null action errors" );
37      }
38      
39      String messageKey = "validate.member.accountType.missing";
40      String strAccountType = this.form.getAccountTypeStr();
41      validateRequiredValue(PROPERTY_TYPE_ROLES,messageKey,strAccountType,errors);
42  
43      AccountType accountType = null;
44      if ( strAccountType != null && strAccountType.trim().length() > 0 ) {
45        try {
46          accountType = new AccountType( strAccountType );
47        }
48        catch ( IllegalArgumentException x ) {
49          messageKey = "validate.member.accountType.invalid";
50          ActionError ae = new ActionError( messageKey, strAccountType );
51          errors.add( PROPERTY_TYPE_ROLES, ae );
52        }
53      }
54  
55      MemberRole[] memberRoles = this.form.getMemberRoles();
56      if ( memberRoles.length > 0 && accountType != null
57        && AccountType.DUPLICATE.equals(accountType) ) {
58  
59          messageKey = "validate.member.accountType.duplicateWithRoles";
60          ActionError ae = new ActionError( messageKey );
61          errors.add( PROPERTY_TYPE_ROLES, ae );
62  
63      } // if duplicate
64  
65      return;
66    } // validate(ActionErrors)
67  
68  } // ValidateMemberRoleAndStatus
69  
70  /*
71   * $Log: ValidateMemberRoleAndStatus.java,v $
72   * Revision 1.4  2003/02/26 03:38:46  rphall
73   * Added copyright and GPL license
74   *
75   * Revision 1.3  2003/02/21 19:16:06  rphall
76   * First non-stubbed impl: checks that DUPLICATE accounts have no roles
77   *
78   * Revision 1.2  2003/02/20 04:06:09  rphall
79   * Stubbed versions
80   *
81   * Revision 1.1  2003/02/11 21:13:15  rphall
82   * Separate class for specific validation task; stubbed implementation
83   *
84   */
85