ApplyDeployConfirmAction.java

00001 
00026 package org.objectweb.jonas.webapp.jonasadmin.deploy;
00027 
00028 import java.io.IOException;
00029 import java.util.ArrayList;
00030 
00031 import javax.servlet.ServletException;
00032 import javax.servlet.http.HttpServletRequest;
00033 import javax.servlet.http.HttpServletResponse;
00034 
00035 import org.apache.struts.action.ActionError;
00036 import org.apache.struts.action.ActionForm;
00037 import org.apache.struts.action.ActionForward;
00038 import org.apache.struts.action.ActionMapping;
00039 
00044 public class ApplyDeployConfirmAction extends BaseDeployAction {
00045 
00046 // --------------------------------------------------------- Public Methods
00047 
00048     public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form
00049         , HttpServletRequest p_Request, HttpServletResponse p_Response)
00050         throws IOException, ServletException {
00051 
00052         ArrayList al;
00053         String[] asParam = new String[1];
00054         String[] asSignature = new String[1];
00055         asSignature[0] = "java.lang.String";
00056 
00057         // Form used
00058         DeployForm oForm = (DeployForm) p_Form;
00059 
00060         // Undeploy with Remove list
00061         al = oForm.getListRemove();
00062         for (int i = 0; i < al.size(); i++) {
00063             try {
00064                 undeploy(al.get(i).toString());
00065             } catch (Exception e) {
00066                 m_Errors.add("error.undeploy", new ActionError("error.undeploy", al.get(i).toString()
00067                     , e.getMessage()));
00068                 saveErrors(p_Request, m_Errors);
00069             }
00070         }
00071 
00072         // Call garbage collector after undeployment
00073         if (al.size() > 0) {
00074             try {
00075                 runGC();
00076             } catch (Throwable t) {
00077                 addGlobalError(t);
00078                 saveErrors(p_Request, m_Errors);
00079             }
00080         }
00081 
00082         // Deploy with Add list
00083         al = oForm.getListAdd();
00084         for (int i = 0; i < al.size(); i++) {
00085             try {
00086                 deploy(al.get(i).toString());
00087             } catch (Exception e) {
00088                 m_Errors.add("error.deploy", new ActionError("error.deploy", al.get(i).toString()
00089                     , e.getMessage()));
00090                 saveErrors(p_Request, m_Errors);
00091             }
00092         }
00093 
00094         // Build correct lists after deployment
00095         try {
00096             // Load the new list of deployed files
00097             oForm.setListDeployed(getListDeployedFiles());
00098             // Build Add list (with items in error status else list empty)
00099             ArrayList alAdd = new ArrayList(oForm.getListDeploy());
00100             alAdd.removeAll(oForm.getListDeployed());
00101             oForm.setListAdd(alAdd);
00102             // Build Remove list (with items in error status else list empty)
00103             ArrayList alRemove = new ArrayList(oForm.getListUndeploy());
00104             alRemove.retainAll(oForm.getListDeployed());
00105             oForm.setListRemove(alRemove);
00106             // Confirm status
00107             oForm.setConfirm((m_Errors.size() == 0) && ((alAdd.size() > 0) || (alRemove.size() > 0)));
00108             // Refresh Tree in memory
00109             refreshTree(p_Request);
00110         } catch (Throwable t) {
00111             addGlobalError(t);
00112             saveErrors(p_Request, m_Errors);
00113         }
00114 
00115         // Forward to the jsp.
00116         return (p_Mapping.findForward("Deploy Confirm"));
00117     }
00118 }

Generated on Tue Feb 15 15:05:26 2005 for JOnAS by  doxygen 1.3.9.1