use of org.jboss.as.cli.Attachments in project wildfly-core by wildfly.
the class BaseOperationCommand method doHandle.
/* (non-Javadoc)
* @see org.jboss.as.cli.handlers.CommandHandlerWithHelp#doHandle(org.jboss.as.cli.CommandContext)
*/
@Override
protected void doHandle(CommandContext ctx) throws CommandLineException {
final ModelNode request = buildRequest(ctx);
Attachments attachments = getAttachments(ctx);
OperationBuilder builder = new OperationBuilder(request, true);
for (String path : attachments.getAttachedFiles()) {
builder.addFileAsAttachment(new File(path));
}
final ModelControllerClient client = ctx.getModelControllerClient();
final OperationResponse operationResponse;
try {
operationResponse = client.executeOperation(builder.build(), OperationMessageHandler.DISCARD);
} catch (Exception e) {
throw new CommandLineException("Failed to perform operation", e);
}
try {
final ModelNode response = operationResponse.getResponseNode();
if (!Util.isSuccess(response)) {
throw new CommandLineException(Util.getFailureDescription(response));
}
handleResponse(ctx, operationResponse, Util.COMPOSITE.equals(request.get(Util.OPERATION).asString()));
operationResponse.close();
} catch (IOException ex) {
throw new CommandLineException("Failed to perform operation", ex);
}
}
Aggregations