View Javadoc

1   package org.sourceforge.vlibrary.security.actions;
2   
3   import java.util.ArrayList;
4   import javax.servlet.http.HttpServletRequest;
5   import javax.servlet.http.HttpServletResponse;
6   import org.apache.struts.action.ActionForm;
7   import org.apache.struts.action.ActionForward;
8   import org.apache.struts.action.ActionMapping;
9   import org.apache.struts.util.MessageResources;
10  import org.apache.log4j.Logger;
11  
12  import org.sourceforge.vlibrary.Constants;
13  import org.sourceforge.vlibrary.security.forms.AdminPasswordResetForm;
14  import org.sourceforge.vlibrary.user.actions.LibraryAction;
15  import org.sourceforge.vlibrary.exceptions.LibraryException;
16  
17  /**
18   * Loads reader list to AdminPasswordReset form
19   *
20   * @version $Revision$ $Date$
21   */
22  public class PreparePasswordResetAction extends LibraryAction {
23      /** log4j Logger */
24      private static Logger logger =
25       Logger.getLogger(PreparePasswordResetAction.class.getName());
26      
27      /**
28       * Prepare password reset action
29       *
30       * @param mapping ActionMapping used to select this instance
31       * @param form  TransactionForm associated with this requewst
32       * @param request  HTTP request
33       * @param response  HTTP response*
34       * @param messages message resources
35       *
36       * @exception Exception
37       */
38      public ActionForward executeAction(ActionMapping mapping, ActionForm form,
39       HttpServletRequest request, HttpServletResponse response,
40       MessageResources messages) throws Exception {
41          
42          ArrayList errors = new ArrayList();
43          
44          try {
45              if (mapping.getPath().startsWith(Constants.ADMIN_PATH)) {
46                  /*
47                   * Load the full list of registered readers into the readers
48                   * property of the Transaction form
49                   */
50                  AdminPasswordResetForm frm = (AdminPasswordResetForm) form;
51                  frm.setReaders(libraryManager.getReaders());
52              }
53          } catch (Throwable t) {
54              String errString = messages.getMessage("error.readers.retrieve");
55              logger.error(errString, t);
56              errors.add(new LibraryException(errString, t));
57          }
58          
59          return standardForward(mapping, request, errors);
60      }
61  }