01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 2005 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: ApplyRemoveAction.java 6842 2005-05-26 15:06:22Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.objectweb.jonas.webapp.jonasadmin.deploy;
25:
26: import java.util.ArrayList;
27: import java.util.Arrays;
28:
29: import javax.servlet.ServletException;
30: import javax.servlet.http.HttpServletRequest;
31: import javax.servlet.http.HttpServletResponse;
32:
33: import org.apache.struts.action.ActionForm;
34: import org.apache.struts.action.ActionForward;
35: import org.apache.struts.action.ActionMapping;
36: import org.apache.struts.action.ActionMessage;
37:
38: /**
39: * Set the list of removed modules choosen by the user
40: * @author Florent Benoit
41: */
42: public class ApplyRemoveAction extends BaseDeployAction {
43:
44: /**
45: * Execute the action with given params
46: * @param actionMapping The ActionMapping used to select this instance
47: * @param actionForm The optional ActionForm bean for this request (if any)
48: * @param request The HTTP request we are processing
49: * @param response The HTTP response we are creating
50: * @return a forward when action is finished
51: * @exception ServletException if business logic throws an exception
52: */
53: public ActionForward executeAction(ActionMapping actionMapping,
54: ActionForm actionForm, HttpServletRequest request,
55: HttpServletResponse response) throws ServletException {
56:
57: String sForward = "Remove Confirm";
58:
59: // Form used
60: RemoveForm removeForm = (RemoveForm) actionForm;
61: try {
62:
63: removeForm.setListToBeRemoved(Arrays.asList(removeForm
64: .getRemoveSelected()));
65: removeForm.setListRemoved(new ArrayList());
66: removeForm
67: .setConfirm(removeForm.getRemoveSelected().length > 0);
68: if (!removeForm.isConfirm()) {
69: m_Errors.add("error.remove.noselect",
70: new ActionMessage("error.remove.noselect"));
71: saveErrors(request, m_Errors);
72: sForward = "Remove";
73: }
74:
75: } catch (Throwable t) {
76: addGlobalError(t);
77: saveErrors(request, m_Errors);
78: return (actionMapping.findForward("Global Error"));
79: }
80: // Forward to the jsp.
81: return (actionMapping.findForward(sForward));
82: }
83: }
|