View Javadoc

1   package org.itracker.web.actions.user;
2   
3   import java.io.IOException;
4   
5   import javax.servlet.ServletException;
6   import javax.servlet.http.HttpServletRequest;
7   import javax.servlet.http.HttpServletResponse;
8   
9   import org.apache.log4j.Logger;
10  import org.apache.struts.action.ActionForm;
11  import org.apache.struts.action.ActionForward;
12  import org.apache.struts.action.ActionMapping;
13  import org.apache.struts.action.ActionMessage;
14  import org.apache.struts.action.ActionMessages;
15  import org.itracker.web.actions.base.ItrackerBaseAction;
16  import org.itracker.web.forms.ForgotPasswordForm;
17  
18  public class ForgotPasswordFormAction extends ItrackerBaseAction {
19  	private static final Logger log = Logger.getLogger(ForgotPasswordFormAction.class);
20  
21  
22  	public ActionForward execute(ActionMapping mapping,
23  			ActionForm form,
24  			HttpServletRequest request,
25  			HttpServletResponse response)
26  	throws ServletException, IOException {
27  		ActionMessages errors = new ActionMessages();
28  
29  		try {
30  			ForgotPasswordForm forgotPasswordForm = (ForgotPasswordForm) form;
31        if (forgotPasswordForm == null) {
32        	forgotPasswordForm = new ForgotPasswordForm();
33        }
34        if (errors.isEmpty()) {
35          request.setAttribute("forgotPasswordForm", forgotPasswordForm);
36          saveToken(request);
37          return mapping.getInputForward();
38      }
39  		} catch (Exception e) {
40  			log.error("Exception while creating forgot password form.", e);
41  			errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("itracker.web.error.system"));
42  		}
43  
44  		if (!errors.isEmpty()) {
45  			saveErrors(request, errors);
46  		}
47  
48  		return mapping.findForward("error");
49  
50  	}
51  
52  }