View Javadoc

1   package org.sourceforge.vlibrary.user.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.exceptions.LibraryException;
14  import org.sourceforge.vlibrary.user.forms.ManageReaderForm;
15  
16  /**
17   * Loads list of readers onto ManageReaderForm
18   * @version $Revision$ $Date$
19   */
20  public class PrepareManageReaderAction extends LibraryAction {
21      /** log4j Logger */
22      private static Logger logger =
23       Logger.getLogger(PrepareManageReaderAction.class.getName());
24      
25      
26      /**
27       * Prepare manage reader action
28       *
29       * @param mapping = ActionMapping used to select this instance
30       * @param form = TransactionForm associated with this requewst
31       * @param request = HTTP request
32       * @param response = HTTP response* @param messages message resources
33       *
34       * @exception Exception
35       */
36      public ActionForward executeAction(ActionMapping mapping,
37       ActionForm form,
38       HttpServletRequest request,
39       HttpServletResponse response,
40       MessageResources messages)
41       throws Exception {
42          
43          ArrayList errors = new ArrayList();
44          
45          try {
46              /* Load the full list of registered readers into the readers
47               *  property of the ManageReader form */
48              ManageReaderForm frm = (ManageReaderForm) form;
49              
50              frm.setReaders(libraryManager.getReaders());
51              
52              // Set default action to edit
53              frm.setAction(Constants.UPDATE);
54          } catch (Throwable t) {
55              String errString = messages.getMessage("error.readers.retrieve");
56              
57              logger.error(errString,t);
58              
59              errors.add(new LibraryException(errString,t));
60          }
61          
62          return standardForward(mapping,request,errors);
63      }
64  }