if (rollbackOperationIfServerNotActive(context, operation)) {
return;
}
final HornetQServerControl serverControl = getServerControl(context, operation);
try {
if (GET_CONNECTORS_AS_JSON.equals(operationName)) {
String json = serverControl.getConnectorsAsJSON();
context.getResult().set(json);
} else if (RESET_ALL_MESSAGE_COUNTERS.equals(operationName)) {
serverControl.resetAllMessageCounters();
context.getResult();
} else if (RESET_ALL_MESSAGE_COUNTER_HISTORIES.equals(operationName)) {
serverControl.resetAllMessageCounterHistories();
context.getResult();
} else if (LIST_PREPARED_TRANSACTIONS.equals(operationName)) {
String[] list = serverControl.listPreparedTransactions();
reportListOfStrings(context, list);
} else if (LIST_PREPARED_TRANSACTION_DETAILS_AS_JSON.equals(operationName)) {
String json = serverControl.listPreparedTransactionDetailsAsJSON();
context.getResult().set(json);
} else if (LIST_PREPARED_TRANSACTION_DETAILS_AS_HTML.equals(operationName)) {
String html = serverControl.listPreparedTransactionDetailsAsHTML();
context.getResult().set(html);
} else if (LIST_HEURISTIC_COMMITTED_TRANSACTIONS.equals(operationName)) {
String[] list = serverControl.listHeuristicCommittedTransactions();
reportListOfStrings(context, list);
} else if (LIST_HEURISTIC_ROLLED_BACK_TRANSACTIONS.equals(operationName)) {
String[] list = serverControl.listHeuristicRolledBackTransactions();
reportListOfStrings(context, list);
} else if (COMMIT_PREPARED_TRANSACTION.equals(operationName)) {
String txId = TRANSACTION_AS_BASE_64.resolveModelAttribute(context, operation).asString();
boolean committed = serverControl.commitPreparedTransaction(txId);
context.getResult().set(committed);
} else if (ROLLBACK_PREPARED_TRANSACTION.equals(operationName)) {
String txId = TRANSACTION_AS_BASE_64.resolveModelAttribute(context, operation).asString();
boolean committed = serverControl.rollbackPreparedTransaction(txId);
context.getResult().set(committed);
} else if (LIST_REMOTE_ADDRESSES.equals(operationName)) {
ModelNode address = OPTIONAL_IP_ADDRESS.resolveModelAttribute(context, operation);
String[] list = address.isDefined() ? serverControl.listRemoteAddresses(address.asString()) : serverControl.listRemoteAddresses();
reportListOfStrings(context, list);
} else if (CLOSE_CONNECTIONS_FOR_ADDRESS.equals(operationName)) {
String address = REQUIRED_IP_ADDRESS.resolveModelAttribute(context, operation).asString();
boolean closed = serverControl.closeConnectionsForAddress(address);
context.getResult().set(closed);
} else if (CLOSE_CONNECTIONS_FOR_USER.equals(operationName)) {
String user = USER.resolveModelAttribute(context, operation).asString();
boolean closed = serverControl.closeConnectionsForUser(user);
context.getResult().set(closed);
} else if (CLOSE_CONSUMER_CONNECTIONS_FOR_ADDRESS.equals(operationName)) {
String address = ADDRESS_MATCH.resolveModelAttribute(context, operation).asString();
boolean closed = serverControl.closeConsumerConnectionsForAddress(address);
context.getResult().set(closed);
} else if (LIST_CONNECTION_IDS.equals(operationName)) {
String[] list = serverControl.listConnectionIDs();
reportListOfStrings(context, list);
} else if (LIST_PRODUCERS_INFO_AS_JSON.equals(operationName)) {
String json = serverControl.listProducersInfoAsJSON();
context.getResult().set(json);
} else if (LIST_SESSIONS.equals(operationName)) {
String connectionID = CONNECTION_ID.resolveModelAttribute(context, operation).asString();
String[] list = serverControl.listSessions(connectionID);
reportListOfStrings(context, list);
} else if (GET_ROLES.equals(operationName)) {
String addressMatch = ADDRESS_MATCH.resolveModelAttribute(context, operation).asString();
String json = serverControl.getRolesAsJSON(addressMatch);
reportRoles(context, json);
} else if (GET_ROLES_AS_JSON.equals(operationName)) {
String addressMatch = ADDRESS_MATCH.resolveModelAttribute(context, operation).asString();
String json = serverControl.getRolesAsJSON(addressMatch);
reportRolesAsJSON(context, json);
} else if (GET_ADDRESS_SETTINGS_AS_JSON.equals(operationName)) {
String addressMatch = ADDRESS_MATCH.resolveModelAttribute(context, operation).asString();
String json = serverControl.getAddressSettingsAsJSON(addressMatch);
context.getResult().set(json);
} else if (FORCE_FAILOVER.equals(operationName)) {
serverControl.forceFailover();
context.getResult();
} else {
// Bug
throw MessagingLogger.ROOT_LOGGER.unsupportedOperation(operationName);
}