1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package jdbcadmin.web.actions;
21
22 import javax.servlet.http.HttpServletRequest;
23 import javax.servlet.http.HttpServletResponse;
24
25 import jdbcadmin.web.ContexteManager;
26 import jdbcadmin.web.forms.SelectSchemaForm;
27
28 import org.apache.commons.logging.Log;
29 import org.apache.commons.logging.LogFactory;
30 import org.apache.struts.action.ActionError;
31 import org.apache.struts.action.ActionErrors;
32 import org.apache.struts.action.ActionForm;
33 import org.apache.struts.action.ActionForward;
34 import org.apache.struts.action.ActionMapping;
35
36 /***
37 * Select a schema.
38 * @struts.action
39 * name="selectSchemaForm"
40 * path="/selectSchema"
41 * @struts.action-forward
42 * name="main"
43 * path="/menu.jsp"
44 * @author Thomas Recloux (trecloux@norsys.fr)
45 */
46 public class SelectSchemaAction extends IndexedAction {
47
48 /*** Logger */
49 private static Log logger = LogFactory.getLog(SelectSchemaAction.class);
50
51
52 /***
53 * Constructor
54 */
55 public SelectSchemaAction() {
56 super();
57 }
58
59 /*** {@inheritDoc} */
60 public ActionForward indexedExec(
61 ActionMapping mapping,
62 ActionForm form,
63 HttpServletRequest request,
64 HttpServletResponse response)
65 throws Exception {
66
67 ActionErrors errors = new ActionErrors();
68 ActionForward forward = new ActionForward();
69 String strFwd = "main";
70 SelectSchemaForm choixSchemaForm = (SelectSchemaForm) form;
71
72 try {
73 ContexteManager.setCurrentSchema(request, choixSchemaForm.getSchema());
74 } catch (Exception e) {
75 if (logger.isErrorEnabled()) {
76 logger.error("Unexpected error selecting current schema", e);
77 }
78 errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.generic", e));
79 strFwd = "error";
80 }
81
82
83
84
85 if (!errors.isEmpty()) {
86 saveErrors(request, errors);
87 }
88
89 forward = mapping.findForward(strFwd);
90
91
92 return (forward);
93
94 }
95 }