KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > deploy > ApplyDomainDeployAction


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * 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: ApplyDomainDeployAction.java,v 1.1 2005/07/25 21:03:54 pasmith Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin.deploy;
27
28 import java.io.IOException JavaDoc;
29 import java.util.ArrayList JavaDoc;
30 import java.util.HashMap JavaDoc;
31 import java.util.Map JavaDoc;
32 import java.util.TreeMap JavaDoc;
33
34 import javax.management.ObjectName JavaDoc;
35 import javax.servlet.ServletException JavaDoc;
36 import javax.servlet.http.HttpServletRequest JavaDoc;
37 import javax.servlet.http.HttpServletResponse JavaDoc;
38
39 import org.apache.struts.action.ActionForm;
40 import org.apache.struts.action.ActionForward;
41 import org.apache.struts.action.ActionMapping;
42 import org.apache.struts.action.ActionMessage;
43
44 /**
45  * @author Patrick Smith
46  * @author Gregory Lapouchnian
47  */

48 public class ApplyDomainDeployAction extends BaseDeployAction {
49
50     // --------------------------------------------------------- Public Methods
51

52     /**
53      */

54     public ActionForward executeAction(ActionMapping p_Mapping,
55             ActionForm p_Form, HttpServletRequest JavaDoc p_Request,
56             HttpServletResponse JavaDoc p_Response) throws IOException JavaDoc,
57             ServletException JavaDoc {
58
59         String JavaDoc sForward = "Domain Deploy Confirm";
60
61         // Form used
62
DomainDeployForm oForm = (DomainDeployForm) p_Form;
63         oForm.setDeploymentInProgress(false);
64         oForm.setDeploymentComplete(false);
65       
66         try {
67
68             // set the array lists of selected apps and target servers based on
69
// the selections returned by struts
70
ArrayList JavaDoc appList = new ArrayList JavaDoc();
71             ArrayList JavaDoc serverList = new ArrayList JavaDoc();
72             ArrayList JavaDoc serverNamesList = new ArrayList JavaDoc();
73
74             for (int i = 0; i < oForm.getServerSelected().length; i++) {
75                 serverList.add(oForm.getServerSelected()[i]);
76                 serverNamesList.add(ObjectName.getInstance(oForm.getServerSelected()[i]).getKeyProperty("name"));
77             }
78             for (int i = 0; i < oForm.getDeploySelected().length; i++) {
79                 appList.add(oForm.getDeploySelected()[i]);
80             }
81
82             oForm.setListDeploy(appList);
83             oForm.setListTargetServers(serverList);
84             oForm.setListTargetServerNames(serverNamesList);
85
86             // make sure that the action and the replacement option are transferred
87
// to the next action
88
oForm.setSelectedAction(oForm.getSelectedOption());
89             oForm.setReplacementOption(oForm.getReplaceOnTarget());
90
91             // fill up the report with initial values to display 'In Progress'
92
// status
93
Map JavaDoc blankReport = new TreeMap JavaDoc();
94             Map JavaDoc initialStatus = new HashMap JavaDoc();
95             initialStatus.put("In Progress...", "true");
96             for (int i = 0; i < appList.size(); i++) {
97                 HashMap JavaDoc appReport = new HashMap JavaDoc();
98                 for (int j = 0; j < serverList.size(); j++) {
99                     appReport.put(ObjectName.getInstance(
100                             (String JavaDoc) serverList.get(j)).getKeyProperty("name"),
101                            initialStatus);
102                 }
103                 blankReport.put(appList.get(i), appReport);
104             }
105             oForm.setReports(blankReport);
106
107             // at least one entry must be selected from the list of servers and
108
// from the list of applications
109
oForm.setConfirm(oForm.getDeploySelected().length > 0
110                     && oForm.getServerSelected().length > 0);
111
112             if (!oForm.isConfirm()) {
113                 m_Errors.add("error.domain.deploy.noselect",
114                              new ActionMessage("error.domain.deploy.noselect"));
115                 saveErrors(p_Request, m_Errors);
116                 sForward = getForwardEdit();
117             }
118
119         } catch (Throwable JavaDoc t) {
120             addGlobalError(t);
121             saveErrors(p_Request, m_Errors);
122             return (p_Mapping.findForward("Global Error"));
123         }
124
125         // Forward to the jsp.
126
return (p_Mapping.findForward(sForward));
127     }
128 }
129
Popular Tags