Source:
public void handle(CommandContext ctx) throws CommandLineException { ModelControllerClient client = ctx.getModelControllerClient(); if(client == null) { throw new CommandFormatException("You are disconnected at the moment." + " Type 'connect' to connect to the server" + " or 'help' for the list of supported commands."); } RequestWithAttachments reqWithAttachments = (RequestWithAttachments) ctx.get(Scope.REQUEST, "OP_REQ"); if (reqWithAttachments == null) { throw new CommandLineException("Parsed request isn't available."); } ModelNode request = reqWithAttachments.getRequest(); OperationBuilder opBuilder = new OperationBuilder(request, true); for (String path : reqWithAttachments.getAttachedFiles()) { opBuilder.addFileAsAttachment(new File(path)); } Operation op = opBuilder.build(); if(ctx.getConfig().isValidateOperationRequests()) { ModelNode opDescOutcome = Util.validateRequest(ctx, request); if (opDescOutcome != null) { Util.replaceFilePathsWithBytes(request, opDescOutcome); } } try { CliLogger.ROOT_LOGGER.executingOperationRequest(op.getOperation().toString()); final ModelNode result = ctx.execute(op, "Operation request"); if (Util.isSuccess(result)) { ctx.printLine(result.toString()); } else { throw new CommandLineException(result.toString()); } } catch(NoSuchElementException e) { throw new CommandLineException("ModelNode request is incomplete", e); } catch (CancellationException e) { throw new CommandLineException("The result couldn't be retrieved (perhaps the task was cancelled", e); } catch (IOException e) { if (e.getCause() != null && !(e.getCause() instanceof InterruptedException)) { ctx.disconnectController(); } throw new CommandLineException("Communication error", e); } catch (RuntimeException e) { throw new CommandLineException("Failed to execute operation.", e); } }

Target:
public void handle(CommandContext ctx) throws CommandLineException { ModelControllerClient client = ctx.getModelControllerClient(); if(client == null) { throw new CommandFormatException("You are disconnected at the moment." + " Type 'connect' to connect to the server" + " or 'help' for the list of supported commands."); } RequestWithAttachments reqWithAttachments = (RequestWithAttachments) ctx.get(Scope.REQUEST, "OP_REQ"); if (reqWithAttachments == null) { throw new CommandLineException("Parsed request isn't available."); } ModelNode request = reqWithAttachments.getRequest(); OperationBuilder opBuilder = new OperationBuilder(request, true); for (String path : reqWithAttachments.getAttachedFiles()) { opBuilder.addFileAsAttachment(new File(path)); } Operation op = opBuilder.build(); if(ctx.getConfig().isValidateOperationRequests()) { ModelNode opDescOutcome = Util.validateRequest(ctx, request); if (opDescOutcome != null) { Util.replaceFilePathsWithBytes(request, opDescOutcome); } } try { CliLogger.ROOT_LOGGER.debugf("Executing operation request:%n%s", op.getOperation()); final ModelNode result = ctx.execute(op, "Operation request"); if (Util.isSuccess(result)) { ctx.printLine(result.toString()); } else { throw new CommandLineException(result.toString()); } } catch(NoSuchElementException e) { throw new CommandLineException("ModelNode request is incomplete", e); } catch (CancellationException e) { throw new CommandLineException("The result couldn't be retrieved (perhaps the task was cancelled", e); } catch (IOException e) { if (e.getCause() != null && !(e.getCause() instanceof InterruptedException)) { ctx.disconnectController(); } throw new CommandLineException("Communication error", e); } catch (RuntimeException e) { throw new CommandLineException("Failed to execute operation.", e); } }