/* (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); final ModelControllerClient client = ctx.getModelControllerClient(); final OperationResponse operationResponse; try { operationResponse = client.executeOperation( Operation.Factory.create(request), 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); } }
private void readLogFile(ModelNode opNode) throws IOException { Operation op = OperationBuilder.create(opNode).build(); OperationResponse response = null; try { response = getModelControllerClient().executeOperation(op, OperationMessageHandler.DISCARD); ModelNode respNode = response.getResponseNode(); Assert.assertEquals(respNode.toString(), "success", respNode.get("outcome").asString()); Assert.assertEquals(respNode.toString(), ModelType.STRING, respNode.get("result").getType()); String uuid = respNode.get("result").asString(); List<? extends OperationResponse.StreamEntry> streams = response.getInputStreams(); Assert.assertEquals(1, streams.size()); OperationResponse.StreamEntry se = streams.get(0); Assert.assertEquals(uuid, se.getUUID()); readLogStream(se.getStream()); } finally { StreamUtils.safeClose(response); } }
protected void handleResponse(CommandContext ctx, OperationResponse response, boolean composite) throws CommandLineException { handleResponse(ctx, response.getResponseNode(), composite); handleAttachedFile(ctx, response); }
public ModelNode getDmrResponse() { return response.getResponseNode(); }