00001
00026 package org.objectweb.jonas.webapp.jonasadmin.catalina;
00027
00028 import java.io.IOException;
00029
00030 import javax.management.ObjectName;
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 import org.objectweb.jonas.jmx.JonasManagementRepr;
00040 import org.objectweb.jonas.webapp.jonasadmin.Jlists;
00041 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
00042
00047 public class EditConnectorAction extends CatalinaBaseAction {
00048
00049
00050
00051 public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form
00052 , HttpServletRequest p_Request, HttpServletResponse p_Response)
00053 throws IOException, ServletException {
00054
00055
00056 ObjectName oObjectName = null;
00057 try {
00058 oObjectName = new ObjectName(p_Request.getParameter("select"));
00059 }
00060 catch (Exception e) {
00061 m_Errors.add("select", new ActionError("error.catalina.connector.select.bad"
00062 , p_Request.getParameter("select")));
00063 addGlobalError(e);
00064 saveErrors(p_Request, m_Errors);
00065 return (p_Mapping.findForward("Global Error"));
00066 }
00067
00068
00069 ConnectorForm oForm = new ConnectorForm();
00070 m_Session.setAttribute("catalinaConnectorForm", oForm);
00071 oForm.setAction("edit");
00072 oForm.setObjectName(oObjectName.toString());
00073 oForm.setDebugLvlVals(Jlists.getDebugLevels());
00074 oForm.setBooleanVals(Jlists.getBooleanValues());
00075
00076
00077 try {
00078
00079
00080 oForm.setScheme(getStringAttribute(oObjectName, "scheme"));
00081 String sHandlerClassName = getStringAttribute(oObjectName, "protocolHandlerClassName");
00082 int period = sHandlerClassName.lastIndexOf('.');
00083 String sHandlerType = sHandlerClassName.substring(period + 1);
00084 oForm.setConnectorType("HTTPS");
00085 if ("JkCoyoteHandler".equalsIgnoreCase(sHandlerType)) {
00086 oForm.setConnectorType("AJP");
00087 } else if (("Http11Protocol".equalsIgnoreCase(sHandlerType))
00088 && ("http".equalsIgnoreCase(oForm.getScheme()))) {
00089 oForm.setConnectorType("HTTP");
00090 }
00091
00092 oForm.setAcceptCountText(toStringIntegerAttribute(oObjectName, "acceptCount"));
00093 oForm.setConnTimeOutText(toStringIntegerAttribute(oObjectName, "connectionTimeout"));
00094 oForm.setDebugLvl(toStringIntegerAttribute(oObjectName, "debug"));
00095 oForm.setBufferSizeText(toStringIntegerAttribute(oObjectName, "bufferSize"));
00096 oForm.setEnableLookups(getBooleanAttribute(oObjectName, "enableLookups"));
00097 oForm.setAddress(getStringAttribute(oObjectName, "address"));
00098
00099
00100 oForm.setPortText(toStringIntegerAttribute(oObjectName, "port"));
00101 oForm.setRedirectPortText(toStringIntegerAttribute(oObjectName, "redirectPort"));
00102
00103
00104 if (oForm.getConnectorType() == "AJP") {
00105 Object oAttribute = JonasManagementRepr.getAttribute(oObjectName, "minProcessors");
00106 if (oAttribute != null) {
00107 oForm.setMinProcessorsText(((Integer) oAttribute).toString());
00108 }
00109 oAttribute = JonasManagementRepr.getAttribute(oObjectName, "maxProcessors");
00110 if (oAttribute != null) {
00111 oForm.setMaxProcessorsText(((Integer) oAttribute).toString());
00112 }
00113 }
00114
00115 Object oAttribute = JonasManagementRepr.getAttribute(oObjectName, "minSpareThreads");
00116 if (oAttribute != null) {
00117 String className = oAttribute.getClass().getName();
00118 if (className.equals("java.lang.String")) {
00119 oForm.setMinSpareThreadsText((String) oAttribute);
00120 } else if (className.equals("java.lang.Integer")) {
00121 oForm.setMinSpareThreadsText(((Integer) oAttribute).toString());
00122 }
00123 }
00124 oAttribute = JonasManagementRepr.getAttribute(oObjectName, "maxSpareThreads");
00125 if (oAttribute != null) {
00126 String className = oAttribute.getClass().getName();
00127 if (className.equals("java.lang.String")) {
00128 oForm.setMaxSpareThreadsText((String) oAttribute);
00129 } else if (className.equals("java.lang.Integer")) {
00130 oForm.setMaxSpareThreadsText(((Integer) oAttribute).toString());
00131 }
00132 }
00133 oAttribute = JonasManagementRepr.getAttribute(oObjectName, "maxThreads");
00134 if (oAttribute != null) {
00135 String className = oAttribute.getClass().getName();
00136 if (className.equals("java.lang.String")) {
00137 oForm.setMaxThreadsText((String) oAttribute);
00138 } else if (className.equals("java.lang.Integer")) {
00139 oForm.setMaxThreadsText(((Integer) oAttribute).toString());
00140 }
00141 }
00142
00143 if (!("AJP".equalsIgnoreCase(oForm.getConnectorType()))) {
00144 oForm.setProxyName(getStringAttribute(oObjectName, "proxyName"));
00145 oForm.setProxyPortText(toStringIntegerAttribute(oObjectName, "proxyPort"));
00146 }
00147
00148 if ("HTTPS".equalsIgnoreCase(oForm.getConnectorType())) {
00149
00150
00151 oForm.setClientAuthentication(getBooleanAttribute(oObjectName, "clientAuth"));
00152 oForm.setKeyStoreFileName(getStringAttribute(oObjectName, "keystoreFile"));
00153 oForm.setKeyStorePassword(getStringAttribute(oObjectName, "keystorePass"));
00154 }
00155
00156 String nodeName = getTreeBranchName(DEPTH_SERVER) + WhereAreYou.NODE_SEPARATOR
00157 + "protocols" + WhereAreYou.NODE_SEPARATOR
00158 + "connectors" + WhereAreYou.NODE_SEPARATOR
00159
00160 + oForm.getPortText();
00161 m_WhereAreYou.selectNameNode(nodeName, true);
00162 }
00163 catch (Throwable t) {
00164 addGlobalError(t);
00165 saveErrors(p_Request, m_Errors);
00166 return (p_Mapping.findForward("Global Error"));
00167 }
00168
00169 return (p_Mapping.findForward("Catalina Connector"));
00170 }
00171 }