// Get submitted values
//todo: lots of validation
String connectorURI = actionRequest.getParameter(PARM_CONNECTOR_URI);
// Identify and update the connector
AbstractName connectorName = new AbstractName(URI.create(connectorURI));
NetworkConnector connector = PortletManager.getNetworkConnector(actionRequest, connectorName);
if(connector != null) {
WebManager manager = PortletManager.getWebManager(actionRequest, new AbstractName(URI.create(managerURI)));
ConnectorType connectorType = manager.getConnectorType(connectorName);
// set the connector attributes from the form post
for (ConnectorAttribute attribute : manager.getConnectorAttributes(connectorType)) {
String name = attribute.getAttributeName();
String value = actionRequest.getParameter(name);
// handle booelan type special
if (attribute.getAttributeClass().equals(Boolean.class)) {
// browser sends value of checked checkbox as "on" or "checked"
if ("on".equalsIgnoreCase(value) || "checked".equalsIgnoreCase(value)) {
value=Boolean.toString(true);
} else {
value=Boolean.toString(false);
}
}
// set the string form of the attribute's value as submitted by the browser
if (value == null || value.trim().length()<1) {
// special case for KeystoreManager gbean
if ("trustStore".equals(attribute.getAttributeName())) {
setProperty(connector,name,null);
}
} else {
// set the string value on the ConnectorAttribute so
// it can handle type conversion via getValue()
try {
attribute.setStringValue(value);
setProperty(connector,name,attribute.getValue());
} catch (Exception e) {
log.error("Unable to set property " + attribute.getAttributeName(), e);
}
}
}
// set the keystore properties if its a secure connector
setKeystoreProperties(actionRequest, connectorName);
}
actionResponse.setRenderParameter(PARM_MODE, "list");
} else if(mode.equals("start")) {
String connectorURI = actionRequest.getParameter(PARM_CONNECTOR_URI);
// work with the current connector to start it.
NetworkConnector connector = PortletManager.getNetworkConnector(actionRequest, new AbstractName(URI.create(connectorURI)));
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(PARM_CONNECTOR_URI, connectorURI);
actionResponse.setRenderParameter(PARM_MODE, "list");
} else if(mode.equals("stop")) {
String connectorURI = actionRequest.getParameter(PARM_CONNECTOR_URI);
// work with the current connector to stop it.
NetworkConnector connector = PortletManager.getNetworkConnector(actionRequest, new AbstractName(URI.create(connectorURI)));
if(connector != null) {
try {
((GeronimoManagedBean)connector).stop();
} catch (Exception e) {
log.error("Unable to stop connector", e); //todo: get into rendered page somehow?
}
}
else {
log.error("Incorrect connector reference"); //Replace this with correct error processing
}
actionResponse.setRenderParameter(PARM_CONNECTOR_URI, connectorURI);
actionResponse.setRenderParameter(PARM_MODE, "list");
} else if(mode.equals("restart")) {
String connectorURI = actionRequest.getParameter(PARM_CONNECTOR_URI);
// work with the current connector to restart it.
NetworkConnector connector = PortletManager.getNetworkConnector(actionRequest, new AbstractName(URI.create(connectorURI)));
if(connector != null) {
try {
((GeronimoManagedBean)connector).stop();
((GeronimoManagedBean)connector).start();
} catch (Exception e) {