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  
13  import org.sourceforge.vlibrary.exceptions.LibraryException;
14  import org.sourceforge.vlibrary.user.forms.TransactionForm;
15  
16  /**
17   * Loads reader list to TransactionForm
18   * @version $Revision$ $Date$
19   */
20  
21  public class PrepareMoveBookAction extends LibraryAction {
22      
23      /** log4j Logger */
24      private static Logger logger =
25       Logger.getLogger(PrepareMoveBookAction.class.getName());
26      
27      /**
28       * Prepare move book action.
29       * Take hidden fields posted by booklistContent.jsp and shove them
30       * into TransactionForm for use by movebook.jsp and then MoveBookAction
31       *
32       * @param mapping = ActionMapping used to select this instance
33       * @param form = TransactionForm associated with this request
34       * @param request = HTTP request
35       * @param response = HTTP response* @param messages message resources
36       *
37       * @exception Exception
38       */
39      public ActionForward executeAction(ActionMapping mapping,
40       ActionForm form,
41       HttpServletRequest request,
42       HttpServletResponse response,
43       MessageResources messages)
44       throws Exception {
45          ArrayList<LibraryException> errors = new ArrayList<LibraryException>();
46          
47          TransactionForm frm = (TransactionForm) form;
48          
49          frm.setLibraryManager(libraryManager);
50          
51          // Load readers
52          try {
53              frm.setReaders(libraryManager.getReaders());
54          } catch (Throwable t) {
55              String errString = messages.getMessage("error.readers.retrieve");
56              logger.error(errString,t);
57              errors.add(new LibraryException(errString,t));
58          }
59          
60         // Load locations
61          try {
62              frm.setLocations(libraryManager.getLocations());
63          } catch (Throwable t) {
64              String errString = messages.getMessage("error.locations.retrieve");
65              logger.error(errString,t);
66              errors.add(new LibraryException(errString,t));
67          }
68            
69          return standardForward(mapping, request, errors);
70      }
71  }