int port = Integer.parseInt(actionRequest.getParameter("port"));
int maxThreads = Integer.parseInt(actionRequest.getParameter("maxThreads"));
Integer minThreads = getInteger(actionRequest, "minThreads");
String name = actionRequest.getParameter("name");
// Create and configure the connector
WebConnector connector = PortletManager.createWebConnector(actionRequest, managerName, containerName, name, protocol, host, port);
connector.setMaxThreads(maxThreads);
// todo: more configurable HTTP/Jetty values
if(server.equals(WEB_SERVER_JETTY)) {
if(minThreads != null) {
setProperty(connector, "minThreads", minThreads);
}
}
else if (server.equals(WEB_SERVER_TOMCAT)) {
//todo: Any Tomcat specific processing?
}
else {
//todo: Handle "should not occur" condition
}
if(protocol.equals(WebManager.PROTOCOL_HTTPS)) {
String keystoreType = actionRequest.getParameter("keystoreType");
String keystoreFile = actionRequest.getParameter("keystoreFile");
String privateKeyPass = actionRequest.getParameter("privateKeyPassword");
String keystorePass = actionRequest.getParameter("keystorePassword");
String secureProtocol = actionRequest.getParameter("secureProtocol");
String algorithm = actionRequest.getParameter("algorithm");
String truststoreType = actionRequest.getParameter("truststoreType");
String truststoreFile = actionRequest.getParameter("truststoreFile");
String truststorePass = actionRequest.getParameter("truststorePassword");
boolean clientAuth = isValid(actionRequest.getParameter("clientAuth"));
SecureConnector secure = (SecureConnector) connector;
if(isValid(keystoreType)) {secure.setKeystoreType(keystoreType);}
if(isValid(keystoreFile)) {secure.setKeystoreFileName(keystoreFile);}
if(isValid(keystorePass)) {secure.setKeystorePassword(keystorePass);}
if(isValid(secureProtocol)) {secure.setSecureProtocol(secureProtocol);}
if(isValid(algorithm)) {secure.setAlgorithm(algorithm);}
secure.setClientAuthRequired(clientAuth);
if(server.equals(WEB_SERVER_JETTY)) {
if(isValid(privateKeyPass)) {setProperty(secure, "keyPassword", privateKeyPass);}
}
else if (server.equals(WEB_SERVER_TOMCAT)) {
if(isValid(truststoreType)) {setProperty(secure, "truststoreType", truststoreType);}
if(isValid(truststoreFile)) {setProperty(secure, "truststoreFileName", truststoreFile);}
if(isValid(truststorePass)) {setProperty(secure, "truststorePassword", truststorePass);}
}
else {
//todo: Handle "should not occur" condition
}
}
// Start the connector
try {
((GeronimoManagedBean)connector).startRecursive();
} catch (Exception e) {
log.error("Unable to start connector", e); //todo: get into rendered page somehow?
}
actionResponse.setRenderParameter("mode", "list");
} else if(mode.equals("save")) { // User just submitted the form to update a connector
// Get submitted values
//todo: lots of validation
String host = actionRequest.getParameter("host");
int port = Integer.parseInt(actionRequest.getParameter("port"));
int maxThreads = Integer.parseInt(actionRequest.getParameter("maxThreads"));
Integer minThreads = getInteger(actionRequest, "minThreads");
String objectName = actionRequest.getParameter("objectName");
// Identify and update the connector
WebConnector connector = null;
WebConnector all[] = PortletManager.getWebConnectors(actionRequest, managerName);
for (int i = 0; i < all.length; i++) {
WebConnector conn = all[i];
if(((GeronimoManagedBean)conn).getObjectName().equals(objectName)) {
connector = conn;
break;
}
}
if(connector != null) {
connector.setHost(host);
connector.setPort(port);
connector.setMaxThreads(maxThreads);
if(server.equals(WEB_SERVER_JETTY)) {
if(minThreads != null) {
setProperty(connector,"minThreads",minThreads);
}
else if (server.equals(WEB_SERVER_TOMCAT)) {
//todo: Any Tomcat specific processing?
}
else {
//todo: Handle "should not occur" condition
}
}
if(connector instanceof SecureConnector) {
String keystoreType = actionRequest.getParameter("keystoreType");
String keystoreFile = actionRequest.getParameter("keystoreFile");
String privateKeyPass = actionRequest.getParameter("privateKeyPassword");
String keystorePass = actionRequest.getParameter("keystorePassword");
String secureProtocol = actionRequest.getParameter("secureProtocol");
String algorithm = actionRequest.getParameter("algorithm");
String truststoreType = actionRequest.getParameter("truststoreType");
String truststoreFile = actionRequest.getParameter("truststoreFile");
String truststorePass = actionRequest.getParameter("truststorePassword");
boolean clientAuth = isValid(actionRequest.getParameter("clientAuth"));
SecureConnector secure = (SecureConnector) connector;
if(isValid(keystoreType)) {secure.setKeystoreType(keystoreType);}
if(isValid(keystoreFile)) {secure.setKeystoreFileName(keystoreFile);}
if(isValid(keystorePass)) {secure.setKeystorePassword(keystorePass);}
if(isValid(secureProtocol)) {secure.setSecureProtocol(secureProtocol);}
if(isValid(algorithm)) {secure.setAlgorithm(algorithm);}
secure.setClientAuthRequired(clientAuth);
if(server.equals(WEB_SERVER_JETTY)) {
if(isValid(privateKeyPass)) {setProperty(secure, "keyPassword", privateKeyPass);}
}
else if (server.equals(WEB_SERVER_TOMCAT)) {
if(isValid(truststoreType)) {setProperty(secure, "truststoreType", truststoreType);}
if(isValid(truststorePass)) {setProperty(secure, "truststorePassword", truststorePass);}
if(isValid(truststoreFile)) {setProperty(secure, "truststoreFileName", truststoreFile);}
}
else {
//todo: Handle "should not occur" condition
}
}
}
actionResponse.setRenderParameter("mode", "list");
} else if(mode.equals("start")) {
String objectName = actionRequest.getParameter("name");
// work with the current connector to start it.
WebConnector connector = null;
WebConnector all[] = PortletManager.getWebConnectors(actionRequest, managerName);
for (int i = 0; i < all.length; i++) {
WebConnector conn = all[i];
if(((GeronimoManagedBean)conn).getObjectName().equals(objectName)) {
connector = conn;
break;
}
}
if(connector != null) {
try {
((GeronimoManagedBean)connector).startRecursive();
} catch (Exception e) {
log.error("Unable to start connector", e); //todo: get into rendered page somehow?
}
}
else {
log.error("Incorrect connector reference"); //Replace this with correct error processing
}
actionResponse.setRenderParameter("name", objectName);
actionResponse.setRenderParameter("mode", "list");
} else if(mode.equals("stop")) {
String objectName = actionRequest.getParameter("name");
// work with the current connector to stop it.
WebConnector connector = null;
WebConnector all[] = PortletManager.getWebConnectors(actionRequest, managerName);
for (int i = 0; i < all.length; i++) {
WebConnector conn = all[i];
if(((GeronimoManagedBean)conn).getObjectName().equals(objectName)) {
connector = conn;
break;
}
}