@Override
protected void handleResponse(CommandContext ctx, ModelNode response, boolean composite) throws CommandLineException {
final ModelNode result = response.get(Util.RESULT);
if(!result.isDefined()) {
throw new CommandLineException("The operation result is not defined: " + result);
}
final List<ModelNode> list = result.asList();
if (!name.isPresent(ctx.getParsedCommandLine())) {
final SimpleTable table = new SimpleTable(new String[] { "NAME", "SOURCE" });
for (ModelNode node : list) {
final ModelNode driverName = node.get(Util.DRIVER_NAME);
if (!driverName.isDefined()) {
throw new CommandLineException(Util.DRIVER_NAME + " is not available: " + node);
}
final String source;
if (node.hasDefined(Util.DEPLOYMENT_NAME)) {
source = node.get(Util.DEPLOYMENT_NAME).asString();
} else if (node.hasDefined(Util.DRIVER_MODULE_NAME)) {
final StringBuilder buf = new StringBuilder();
buf.append(node.get(Util.DRIVER_MODULE_NAME).asString());
if(node.hasDefined(Util.MODULE_SLOT)) {
buf.append('/').append(node.get(Util.MODULE_SLOT).asString());
}
source = buf.toString();
} else {
source = "n/a";
}
table.addLine(new String[] { driverName.asString(), source });
}
ctx.printLine(table.toString(true));
} else {
final String name = this.name.getValue(ctx.getParsedCommandLine());
final SimpleTable table = new SimpleTable(2);
for (ModelNode node : list) {
final ModelNode driverName = node.get(Util.DRIVER_NAME);
if (!driverName.isDefined()) {
throw new CommandLineException(Util.DRIVER_NAME + " is not available: " + node);
}
if(name.equals(driverName.asString())) {
for(String propName : node.keys()) {
final ModelNode value = node.get(propName);
table.addLine(new String[] { propName, value.isDefined() ? value.asString() : "n/a" });