001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999-2004 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: ApplyDeployConfirmAction.java 6599 2005-04-21 08:59:54Z kemlerp $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.webapp.jonasadmin.deploy;
025:
026: import java.io.IOException;
027: import java.util.ArrayList;
028:
029: import javax.servlet.ServletException;
030: import javax.servlet.http.HttpServletRequest;
031: import javax.servlet.http.HttpServletResponse;
032:
033: import org.apache.struts.action.ActionMessage;
034: import org.apache.struts.action.ActionForm;
035: import org.apache.struts.action.ActionForward;
036: import org.apache.struts.action.ActionMapping;
037:
038: /**
039: * @author Michel-Ange Anton
040: */
041:
042: public class ApplyDeployConfirmAction extends BaseDeployAction {
043:
044: // --------------------------------------------------------- Public Methods
045:
046: public ActionForward executeAction(ActionMapping p_Mapping,
047: ActionForm p_Form, HttpServletRequest p_Request,
048: HttpServletResponse p_Response) throws IOException,
049: ServletException {
050:
051: ArrayList al;
052: String[] asParam = new String[1];
053: String[] asSignature = new String[1];
054: asSignature[0] = "java.lang.String";
055:
056: // Form used
057: DeployForm oForm = (DeployForm) p_Form;
058:
059: // Undeploy with Remove list
060: al = oForm.getListRemove();
061: for (int i = 0; i < al.size(); i++) {
062: try {
063: undeploy(al.get(i).toString());
064: } catch (Exception e) {
065: m_Errors.add("error.undeploy", new ActionMessage(
066: "error.undeploy", al.get(i).toString(), e
067: .getMessage()));
068: saveErrors(p_Request, m_Errors);
069: }
070: }
071:
072: // Call garbage collector after undeployment
073: if (al.size() > 0) {
074: try {
075: runGC();
076: } catch (Throwable t) {
077: addGlobalError(t);
078: saveErrors(p_Request, m_Errors);
079: }
080: }
081:
082: // Deploy with Add list
083: al = oForm.getListAdd();
084: for (int i = 0; i < al.size(); i++) {
085: try {
086: deploy(al.get(i).toString());
087: } catch (Exception e) {
088: m_Errors.add("error.deploy", new ActionMessage(
089: "error.deploy", al.get(i).toString(), e
090: .getMessage()));
091: saveErrors(p_Request, m_Errors);
092: }
093: }
094:
095: // Build correct lists after deployment
096: try {
097: // Load the new list of deployed files
098: oForm.setListDeployed(getListDeployedFiles());
099: // Build Add list (with items in error status else list empty)
100: ArrayList alAdd = new ArrayList(oForm.getListDeploy());
101: alAdd.removeAll(oForm.getListDeployed());
102: oForm.setListAdd(alAdd);
103: // Build Remove list (with items in error status else list empty)
104: ArrayList alRemove = new ArrayList(oForm.getListUndeploy());
105: alRemove.retainAll(oForm.getListDeployed());
106: oForm.setListRemove(alRemove);
107: // Confirm status
108: oForm.setConfirm((m_Errors.size() == 0)
109: && ((alAdd.size() > 0) || (alRemove.size() > 0)));
110: // Refresh Tree in memory
111: refreshTree(p_Request);
112: } catch (Throwable t) {
113: addGlobalError(t);
114: saveErrors(p_Request, m_Errors);
115: }
116:
117: // Forward to the jsp.
118: return (p_Mapping.findForward("Deploy Confirm"));
119: }
120: }
|