1 package org.sourceforge.vlibrary.user.actions;
2
3 import java.util.ArrayList;
4
5 import javax.servlet.http.HttpServletRequest;
6 import javax.servlet.http.HttpServletResponse;
7
8 import org.apache.log4j.Logger;
9 import org.apache.struts.action.ActionForm;
10 import org.apache.struts.action.ActionForward;
11 import org.apache.struts.action.ActionMapping;
12 import org.apache.struts.util.MessageResources;
13 import org.sourceforge.vlibrary.Constants;
14 import org.sourceforge.vlibrary.exceptions.LibraryException;
15 import org.sourceforge.vlibrary.user.forms.TransactionForm;
16 import org.sourceforge.vlibrary.user.valuebeans.BookMoveTransaction;
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 public class MoveBookAction extends LibraryAction {
34
35
36 private static Logger logger =
37 Logger.getLogger(MoveBookAction.class.getName());
38
39
40
41
42
43
44
45
46
47
48
49
50 public ActionForward executeAction(ActionMapping mapping,
51 ActionForm form,
52 HttpServletRequest request,
53 HttpServletResponse response,
54 MessageResources messages)
55 throws Exception {
56
57 ArrayList<LibraryException> errors = new ArrayList<LibraryException>();
58
59
60 TransactionForm frm = (TransactionForm) form;
61
62 final long book = frm.getBook();
63 final long reader = frm.getReader();
64 final String transactionType = frm.getTransaction();
65 final long location = frm.getLocation();
66
67 BookMoveTransaction t = new BookMoveTransaction();
68 try {
69 t = libraryManager.processExchange(reader, book, transactionType, location);
70 } catch (Throwable e) {
71 errors.add(new LibraryException(e.getMessage(), e));
72
73 logger.error(e.getMessage(), e);
74
75 return standardForward(mapping,request,errors);
76 }
77
78 request.setAttribute(Constants.TRANS,t);
79
80 return standardForward(mapping,request,errors);
81 }
82 }