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

Quick Search    Search Deep

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


1   /*
2    * Copyright (c) Carnegie Lake Rowing Association 2002. All rights reserved.
3    * Distributed under the GPL license. See doc/COPYING.
4    * $RCSfile: ApplyMemberShipAction.java,v $
5    * $Date: 2003/02/26 03:38:46 $
6    * $Revision: 1.7 $
7    */
8   
9   package com.clra.web;
10  
11  import com.clra.visitor.IApplicantHome;
12  import com.clra.visitor.Configuration;
13  import com.clra.util.MailHelper;
14  import java.io.IOException;
15  import java.util.Collection;
16  import java.util.Calendar;
17  import javax.servlet.ServletException;
18  import javax.servlet.http.HttpServletRequest;
19  import javax.servlet.http.HttpSession;
20  import javax.servlet.http.HttpServletResponse;
21  import javax.naming.InitialContext;
22  import javax.naming.NamingException;
23  import javax.rmi.PortableRemoteObject;
24  import javax.ejb.ObjectNotFoundException;
25  import org.apache.log4j.Category;
26  import org.apache.struts.action.Action;
27  import org.apache.struts.action.ActionForm;
28  import org.apache.struts.action.ActionForward;
29  import org.apache.struts.action.ActionMapping;
30  
31  /**
32   * @author <a href="mailto:donaldzhu@sympatico.ca">Angela Yue</a>
33   * @version $Revision: 1.7 $ $Date: 2003/02/26 03:38:46 $
34   */
35  
36  public final class ApplyMemberShipAction extends Action {
37  
38    private final static String base = ApplyMemberShipAction.class.getName();
39    private final static Category theLog = Category.getInstance( base );
40  
41    public ActionForward perform( ActionMapping mapping, ActionForm form,
42      HttpServletRequest request, HttpServletResponse response )
43        throws IOException, ServletException {
44  
45      // A null return value indicates that processing should continue
46      ActionForward retVal = null;
47  
48      ApplyMemberShipForm regform = (ApplyMemberShipForm)form;
49  
50      IApplicantHome mHome = null;
51      int id = -1;
52  
53      try {
54        InitialContext jndiContext = new InitialContext();
55        Object ref  = jndiContext.lookup( Configuration.APPLYMEMBERSHIP_HOME() );
56        mHome = (IApplicantHome)
57          PortableRemoteObject.narrow (ref, IApplicantHome.class);
58      } catch (Exception ex) {
59        theLog.error("Exception in perform: " + ex);
60        retVal = mapping.findForward("failure");
61        return retVal;
62      }
63  
64      String birthday = regform.getBirthday_day() + "-" + regform.getBirthday_month() + "-" + regform.getBirthday_year();
65      theLog.info("birthday = " + birthday);
66  
67      Calendar c = Calendar.getInstance();
68      c.set(regform.getBirthday_year(), regform.getBirthday_month() - 1, regform.getBirthday_day());
69  
70      theLog.info("last name = '" + regform.getName_last() + "'");
71      theLog.info("first name = " + regform.getName_first());
72      theLog.info("middle name = " + regform.getName_middle());
73      theLog.info("suffix name = " + regform.getName_suffix());
74      theLog.info("tel evening = " + regform.getTel_evening());
75      theLog.info("tel day = " + regform.getTel_day());
76      theLog.info("street1 = " + regform.getAddress_street1());
77      theLog.info("city = " + regform.getAddress_city());
78      theLog.info("experience = " + regform.getExperience_year());
79      theLog.info("recent = " + regform.getRecent_year());
80  
81      try {
82          mHome.create(regform.getName_last(),
83                       regform.getName_first(), regform.getName_middle(),
84                       regform.getName_suffix(), regform.getEmail(),
85                       regform.getTel_evening(), regform.getTel_day(),
86                       regform.getTel_other(), regform.getAddress_street1(),
87                       regform.getAddress_street2(), regform.getAddress_city(),
88                       regform.getAddress_state(), regform.getAddress_zip(),
89                       regform.getExperience_year(), regform.getRecent_year(), 
90                       c.getTime(), regform.getSex(), null, "waiting");
91  
92          MailHelper mh = new MailHelper();
93          String content = "<html><body>Apply for Membership";
94  
95          // just a test, the following link should be changed
96          content = "<a href=\"http:\\\\www.clra.com\" target=_blank>CLRA</a></body></html>";
97  
98          mh.createAndSendMail("Apply for Membership", content, null);
99  
100         content = "<html><body>Your application is received. Thanks! <p> To learn more about the club, click " +
101                   "<a href=\"http:\\\\www.clra.com\" target=_blank>CLRA</a></body></html>";
102                   
103         mh.createAndSendMail(regform.getEmail(), "Confirmation", content, null);
104 
105         request.setAttribute("firstname", regform.getName_first());
106         retVal = mapping.findForward("success");
107     } catch (Exception ex) {
108         theLog.error("Exception : " + ex);
109         retVal = mapping.findForward("failure");
110     }
111 
112     return retVal;
113   } // perform
114 
115 
116 } // MemberRegisterAction
117 
118 /*
119  * $Log: ApplyMemberShipAction.java,v $
120  * Revision 1.7  2003/02/26 03:38:46  rphall
121  * Added copyright and GPL license
122  *
123  * Revision 1.6  2003/02/19 22:30:31  rphall
124  * Removed gratuitous use of CLRA acronym
125  *
126  */
127