001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2005 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: ApplyRemoveConfirmAction.java 6842 2005-05-26 15:06:22Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.webapp.jonasadmin.deploy;
025:
026: import java.util.ArrayList;
027: import java.util.Iterator;
028: import java.util.List;
029:
030: import javax.servlet.ServletException;
031: import javax.servlet.http.HttpServletRequest;
032: import javax.servlet.http.HttpServletResponse;
033:
034: import org.apache.struts.action.ActionForm;
035: import org.apache.struts.action.ActionForward;
036: import org.apache.struts.action.ActionMapping;
037: import org.apache.struts.action.ActionMessage;
038:
039: /**
040: * Remove selected modules (after user confirm)
041: * @author Florent Benoit
042: */
043:
044: public class ApplyRemoveConfirmAction extends BaseDeployAction {
045:
046: /**
047: * Execute the action with given params
048: * @param actionMapping The ActionMapping used to select this instance
049: * @param actionForm The optional ActionForm bean for this request (if any)
050: * @param request The HTTP request we are processing
051: * @param response The HTTP response we are creating
052: * @return a forward when action is finished
053: * @exception ServletException if business logic throws an exception
054: */
055: public ActionForward executeAction(ActionMapping actionMapping,
056: ActionForm actionForm, HttpServletRequest request,
057: HttpServletResponse response) throws ServletException {
058:
059: String sForward = "Remove Confirm";
060:
061: // Form used
062: RemoveForm removeForm = (RemoveForm) actionForm;
063: List updatedRemovedList = new ArrayList(removeForm
064: .getListToBeRemoved());
065: // list of selected modules
066: for (Iterator it = removeForm.getListToBeRemoved().iterator(); it
067: .hasNext();) {
068: String fileName = (String) it.next();
069: try {
070: boolean b = removeFile(fileName);
071: if (b) {
072: updatedRemovedList.remove(fileName);
073: removeForm.getListRemoved().add(fileName);
074: } else {
075: m_Errors.add("error.remove", new ActionMessage(
076: "error.remove", "File '" + fileName
077: + "' has not be removed."));
078: saveErrors(request, m_Errors);
079: }
080: } catch (Exception e) {
081: m_Errors.add("error.remove", new ActionMessage(
082: "error.remove", fileName, e.getMessage()));
083: saveErrors(request, m_Errors);
084: }
085: }
086: // Elements removed should be exclude of the list
087: removeForm.setListToBeRemoved(updatedRemovedList);
088:
089: // Confirm status
090: removeForm.setConfirm(false);
091: // Refresh Tree in memory
092: try {
093: refreshTree(request);
094: } catch (Exception e) {
095: addGlobalError(e);
096: saveErrors(request, m_Errors);
097: return (actionMapping.findForward("Global Error"));
098: }
099:
100: // Forward to the jsp.
101: return (actionMapping.findForward(sForward));
102: }
103: }
|