ActionResponse actionResponse) throws PortletException, IOException {
try {
String mode = actionRequest.getParameter("mode");
String connectorURI = actionRequest.getParameter("connectorURI");
String brokerURI = actionRequest.getParameter("brokerURI");
JMSManager manager = PortletManager.getCurrentServer(actionRequest).getJMSManagers()[0]; //todo: handle multiple
if(mode.equals("new")) {
// User selected to add a new connector, need to show criteria portlet
actionResponse.setRenderParameter("mode", "new");
String protocol = actionRequest.getParameter("protocol");
actionResponse.setRenderParameter("protocol", protocol);
actionResponse.setRenderParameter("brokerURI", brokerURI);
} else if(mode.equals("add")) { // User just submitted the form to add a new connector
// Get submitted values
//todo: lots of validation
String protocol = actionRequest.getParameter("protocol");
String host = actionRequest.getParameter("host");
int port = Integer.parseInt(actionRequest.getParameter("port"));
String name = actionRequest.getParameter("name");
AbstractName brokerAbstractName = new AbstractName(URI.create(brokerURI));
// Create and configure the connector
JMSConnector connector = PortletManager.createJMSConnector(actionRequest, manager, brokerAbstractName, name, protocol, host, port);
// 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"));
// Identify and update the connector
AbstractName connectorAbstractName = new AbstractName(URI.create(connectorURI));
JMSConnector connector = (JMSConnector)PortletManager.getManagedBean(actionRequest, connectorAbstractName);
if(connector != null) {
connector.setHost(host);
connector.setPort(port);
}
actionResponse.setRenderParameter("mode", "list");
} else if(mode.equals("start")) {
AbstractName connectorAbstractName = new AbstractName(URI.create(connectorURI));
try {
PortletManager.getManagedBean(actionRequest, connectorAbstractName).startRecursive();
} catch (Exception e) {
throw new PortletException(e);
}
actionResponse.setRenderParameter("mode", "list");
} else if(mode.equals("stop")) {
AbstractName connectorAbstractName = new AbstractName(URI.create(connectorURI));
try {
PortletManager.getManagedBean(actionRequest, connectorAbstractName).stop();
} catch (Exception e) {
throw new PortletException(e);
}
actionResponse.setRenderParameter("mode", "list");
} else if(mode.equals("edit")) {
actionResponse.setRenderParameter("connectorURI", connectorURI);
actionResponse.setRenderParameter("brokerURI", brokerURI);
actionResponse.setRenderParameter("mode", "edit");
} else if(mode.equals("delete")) {
AbstractName connectorAbstractName = new AbstractName(URI.create(connectorURI));
manager.removeConnector(connectorAbstractName);
actionResponse.setRenderParameter("mode", "list");
}
} catch (Throwable e) {
log.error("Unable to process portlet action", e);
if(e instanceof PortletException) {