KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > catalina > EditConnectorAction


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2003-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: EditConnectorAction.java,v 1.13 2005/07/04 13:32:17 kemlerp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin.catalina;
27
28 import java.io.IOException JavaDoc;
29
30 import javax.management.ObjectName JavaDoc;
31 import javax.servlet.ServletException JavaDoc;
32 import javax.servlet.http.HttpServletRequest JavaDoc;
33 import javax.servlet.http.HttpServletResponse JavaDoc;
34
35 import org.apache.struts.action.ActionForm;
36 import org.apache.struts.action.ActionForward;
37 import org.apache.struts.action.ActionMapping;
38 import org.apache.struts.action.ActionMessage;
39 import org.objectweb.jonas.webapp.jonasadmin.Jlists;
40 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
41
42 /**
43  * @author Michel-Ange ANTON
44  * @author Adriana Danes
45  * - update to Tomact 5.0
46  * - update to Tomact 5.5 (04/2005)
47  */

48 public class EditConnectorAction extends CatalinaBaseAction {
49
50 // --------------------------------------------------------- Public Methods
51

52     public ActionForward executeAction(ActionMapping pMapping, ActionForm pForm
53         , HttpServletRequest JavaDoc pRequest, HttpServletResponse JavaDoc pResponse)
54         throws IOException JavaDoc, ServletException JavaDoc {
55
56         // Set up the object names of the MBeans we are manipulating
57
ObjectName JavaDoc oObjectName = null;
58         try {
59             oObjectName = new ObjectName JavaDoc(pRequest.getParameter("select"));
60         } catch (Exception JavaDoc e) {
61             m_Errors.add("select", new ActionMessage("error.catalina.connector.select.bad"
62                 , pRequest.getParameter("select")));
63             addGlobalError(e);
64             saveErrors(pRequest, m_Errors);
65             return (pMapping.findForward("Global Error"));
66         }
67
68         // Fill in the form values for display and editing
69
ConnectorForm oForm = new ConnectorForm();
70         m_Session.setAttribute("catalinaConnectorForm", oForm);
71         oForm.setAction("edit");
72         oForm.setObjectName(oObjectName.toString());
73         oForm.setDebugLvlVals(Jlists.getDebugLevels());
74         oForm.setBooleanVals(Jlists.getBooleanValues());
75
76         // Populate
77
try {
78             // Determine connector type
79
String JavaDoc sHandlerClassName = getStringAttribute(oObjectName, "protocolHandlerClassName");
80             int period = sHandlerClassName.lastIndexOf('.');
81             String JavaDoc sHandlerType = sHandlerClassName.substring(period + 1);
82             if ("JkCoyoteHandler".equalsIgnoreCase(sHandlerType)) {
83                 oForm.setConnectorType("AJP");
84             } else if ("Http11Protocol".equalsIgnoreCase(sHandlerType)) {
85                 if ("http".equalsIgnoreCase(oForm.getScheme())) {
86                     oForm.setConnectorType("HTTP");
87                 } else if ("https".equalsIgnoreCase(oForm.getScheme())) {
88                     oForm.setConnectorType("HTTPS");
89                 }
90             } else {
91                 oForm.setConnectorType("????");
92             }
93             // Common properties
94
oForm.setAllowTrace(getBooleanAttribute(oObjectName, "allowTrace"));
95             oForm.setEmptySessionPath(getBooleanAttribute(oObjectName, "emptySessionPath"));
96             oForm.setEnableLookups(getBooleanAttribute(oObjectName, "enableLookups"));
97             oForm.setMaxPostSizeText(toStringIntegerAttribute(oObjectName, "maxPostSize"));
98             oForm.setProtocol(getStringAttribute(oObjectName, "protocol"));
99             oForm.setProxyName(getStringAttribute(oObjectName, "proxyName"));
100             oForm.setProxyPortText(toStringIntegerAttribute(oObjectName, "proxyPort"));
101             oForm.setRedirectPortText(toStringIntegerAttribute(oObjectName, "redirectPort"));
102             oForm.setScheme(getStringAttribute(oObjectName, "scheme"));
103             oForm.setSecure(getBooleanAttribute(oObjectName, "secure"));
104             oForm.setURIEncoding(getStringAttribute(oObjectName, "URIEncoding"));
105             oForm.setUseBodyEncodingForURI(getBooleanAttribute(oObjectName, "useBodyEncodingForURI"));
106             oForm.setXpoweredBy(getBooleanAttribute(oObjectName, "xpoweredBy"));
107
108             // Coyote Connector properties
109
oForm.setAcceptCountText(toStringIntegerAttribute(oObjectName, "acceptCount"));
110             oForm.setAddress(getStringAttribute(oObjectName, "address"));
111             oForm.setPortText(toStringIntegerAttribute(oObjectName, "port"));
112             oForm.setRedirectPortText(toStringIntegerAttribute(oObjectName, "redirectPort"));
113             oForm.setTcpNoDelay(getBooleanAttribute(oObjectName, "tcpNoDelay"));
114             // ------ Threads management
115
oForm.setMaxThreadsText(toStringIntegerAttribute(oObjectName, "maxThreads"));
116             oForm.setMinSpareThreadsText(toStringIntegerAttribute(oObjectName, "minSpareThreads"));
117             oForm.setMaxSpareThreadsText(toStringIntegerAttribute(oObjectName, "maxSpareThreads"));
118
119             // Supported by HTTP and HTTPS only
120
if (!("AJP".equalsIgnoreCase(oForm.getConnectorType()))) {
121                 oForm.setBufferSizeText(toStringIntegerAttribute(oObjectName, "bufferSize"));
122                 oForm.setCompression(getStringAttribute(oObjectName, "compression"));
123                 oForm.setConnectionLingerText(toStringIntegerAttribute(oObjectName, "connectionLingerText"));
124                 oForm.setConnTimeOutText(toStringIntegerAttribute(oObjectName, "connectionTimeout"));
125                 oForm.setConnectionUploadTimeoutText(toStringIntegerAttribute(oObjectName, "connectionUploadTimeout"));
126                 oForm.setDisableUploadTimeout(getBooleanAttribute(oObjectName, "disableUploadTimeout"));
127                 oForm.setMaxHttpHeaderSizeText(toStringIntegerAttribute(oObjectName, "maxHttpHeaderSize"));
128                 oForm.setMaxKeepAliveRequestsText(toStringIntegerAttribute(oObjectName, "maxKeppAliveRequests"));
129                 oForm.setStrategy(getStringAttribute(oObjectName, "strategy"));
130                 oForm.setThreadPriorityText(toStringIntegerAttribute(oObjectName, "threadPriority"));
131             }
132             // Supported by AJP only
133
if (oForm.getConnectorType() == "AJP") {
134                 oForm.setTomcatAuthentication(getBooleanAttribute(oObjectName, "tomcatAuthentication"));
135             }
136             // SSL Support
137
if ("HTTPS".equalsIgnoreCase(oForm.getConnectorType())) {
138                 // These are set only for SSL connectors.
139
oForm.setAlgorithm(getStringAttribute(oObjectName, "algorithm"));
140                 oForm.setClientAuth(getBooleanAttribute(oObjectName, "clientAuth"));
141                 oForm.setKeystoreFile(getStringAttribute(oObjectName, "keystoreFile"));
142                 oForm.setKeystorePass(getStringAttribute(oObjectName, "keystorePass"));
143                 oForm.setKeystoreType(getStringAttribute(oObjectName, "keystoreType"));
144                 oForm.setSslProtocol(getStringAttribute(oObjectName, "sslProtocol"));
145                 oForm.setCiphers(getStringAttribute(oObjectName, "ciphers"));
146             }
147
148             // Force the node selected in tree
149
String JavaDoc nodeName = getTreeBranchName(DEPTH_SERVER) + WhereAreYou.NODE_SEPARATOR
150                 + "protocols" + WhereAreYou.NODE_SEPARATOR
151                 + "connectors" + WhereAreYou.NODE_SEPARATOR
152                 + m_WhereAreYou.getCurrentCatalinaDomainName() + WhereAreYou.NODE_SEPARATOR
153                 + oForm.getPortText();
154             m_WhereAreYou.selectNameNode(nodeName, true);
155         } catch (Throwable JavaDoc t) {
156             addGlobalError(t);
157             saveErrors(pRequest, m_Errors);
158             return (pMapping.findForward("Global Error"));
159         }
160         // Forward to the connector display page
161
return (pMapping.findForward("Catalina Connector"));
162     }
163 }
164
Popular Tags