@Override protected void addContent(CommandContext context, ModelNode content) throws OperationFormatException { if (unmanaged) { content.get(Util.PATH).set(file.getAbsolutePath()); content.get(Util.ARCHIVE).set(file.isFile()); } else if (context.getBatchManager().isBatchActive()) { Attachments attachments = context.getBatchManager().getActiveBatch().getAttachments(); int index = attachments.addFileAttachment(file.getAbsolutePath()); content.get(Util.INPUT_STREAM_INDEX).set(index); } else { content.get(Util.INPUT_STREAM_INDEX).set(0); } }
@Override protected void executeInternal(String command) throws Exception { try { context.handle(command); } catch (CommandLineException e) { if (context.getBatchManager().isBatchActive()) { context.getBatchManager().discardActiveBatch(); } throw new IllegalArgumentException(String.format("Command execution failed for command '%s'. %s", command, e.getLocalizedMessage()), e); } }
@Override protected void doHandle(CommandContext ctx) throws CommandFormatException { boolean result = ctx.getBatchManager().discardActiveBatch(); if(!result) { throw new CommandFormatException("There is no active batch to discard."); } }
protected void discardBatch(CommandContext ctx, String holdbackBatch) { BatchManager batchManager = ctx.getBatchManager(); batchManager.discardActiveBatch(); if (holdbackBatch != null) { batchManager.activateHeldbackBatch(holdbackBatch); } }
private void discardBatch(CommandContext ctx, String holdbackBatch) { BatchManager batchManager = ctx.getBatchManager(); batchManager.discardActiveBatch(); if (holdbackBatch != null) { batchManager.activateHeldbackBatch(holdbackBatch); } }
protected void discardBatch(CommandContext ctx, String holdbackBatch) { BatchManager batchManager = ctx.getBatchManager(); batchManager.discardActiveBatch(); if (holdbackBatch != null) { batchManager.activateHeldbackBatch(holdbackBatch); } }
@Override public boolean isAvailable(CommandContext ctx) { return ForControlFlow.get(ctx) == null && !ctx.getBatchManager().isBatchActive(); }
private void discardBatch(CommandContext ctx, String holdbackBatch) { BatchManager batchManager = ctx.getBatchManager(); batchManager.discardActiveBatch(); if (holdbackBatch != null) { batchManager.activateHeldbackBatch(holdbackBatch); } }
@Override protected void doHandle(CommandContext ctx) throws CommandFormatException { boolean result = ctx.getBatchManager().discardActiveBatch(); if(!result) { throw new CommandFormatException("There is no active batch to discard."); } }
protected String activateNewBatch(CommandContext ctx) { String currentBatch = null; BatchManager batchManager = ctx.getBatchManager(); if (batchManager.isBatchActive()) { currentBatch = "batch" + System.currentTimeMillis(); batchManager.holdbackActiveBatch(currentBatch); } batchManager.activateNewBatch(); return currentBatch; }
private String activateNewBatch(CommandContext ctx) { String currentBatch = null; BatchManager batchManager = ctx.getBatchManager(); if (batchManager.isBatchActive()) { currentBatch = "batch" + System.currentTimeMillis(); batchManager.holdbackActiveBatch(currentBatch); } batchManager.activateNewBatch(); return currentBatch; }
private String activateNewBatch(CommandContext ctx) { String currentBatch = null; BatchManager batchManager = ctx.getBatchManager(); if (batchManager.isBatchActive()) { currentBatch = "batch" + System.currentTimeMillis(); batchManager.holdbackActiveBatch(currentBatch); } batchManager.activateNewBatch(); return currentBatch; }
protected String activateNewBatch(CommandContext ctx) { String currentBatch = null; BatchManager batchManager = ctx.getBatchManager(); if (batchManager.isBatchActive()) { currentBatch = "batch" + System.currentTimeMillis(); batchManager.holdbackActiveBatch(currentBatch); } batchManager.activateNewBatch(); return currentBatch; }
@Override public boolean isAvailable(CommandContext ctx) { if(TryCatchFinallyControlFlow.get(ctx) != null || ctx.getBatchManager().isBatchActive()) { return false; } return super.isAvailable(ctx); }
@Override protected void doHandle(CommandContext ctx) throws CommandFormatException { Batch batch = ctx.getBatchManager().getActiveBatch(); if(batch == null) { throw new CommandFormatException("No active batch."); } batch.clear(); }
@Override protected void doHandle(CommandContext ctx) throws CommandFormatException { Batch batch = ctx.getBatchManager().getActiveBatch(); if(batch == null) { throw new CommandFormatException("No active batch."); } batch.clear(); }
@Override public boolean isAvailable(CommandContext ctx) { if(TryCatchFinallyControlFlow.get(ctx) != null || ctx.getBatchManager().isBatchActive()) { return false; } return super.isAvailable(ctx); }
@Override public Attachments getAttachments(CommandContext ctx) { final BatchManager batchManager = ctx.getBatchManager(); if (batchManager.isBatchActive()) { final Batch batch = batchManager.getActiveBatch(); return batch.getAttachments(); } return new Attachments(); }
@Override protected void doHandle(CommandContext ctx) throws CommandLineException { final BatchManager batchManager = ctx.getBatchManager(); if(batchManager.isBatchActive()) { throw new CommandFormatException("try is not allowed while in batch mode."); } ctx.registerRedirection(new TryCatchFinallyControlFlow(ctx)); } }
@Override protected void doHandle(CommandContext ctx) throws CommandLineException { final BatchManager batchManager = ctx.getBatchManager(); if(batchManager.isBatchActive()) { throw new CommandFormatException("try is not allowed while in batch mode."); } ctx.registerRedirection(new TryCatchFinallyControlFlow(ctx)); } }