Package org.jboss.as.cli

Examples of org.jboss.as.cli.CommandFormatException


                        }

                        @Override
                        public String getValue(ParsedCommandLine args, boolean required) throws CommandFormatException {
                            if(!isPresent(args)) {
                                throw new CommandFormatException("Property '" + argName + "' is missing required value.");
                            }
                            return args.getPropertyValue(argName);
                        }

                        @Override
View Full Code Here


                }

                @Override
                public String getValue(ParsedCommandLine args, boolean required) throws CommandFormatException {
                    if(!isPresent(args)) {
                        throw new CommandFormatException("Property '" + name + "' is missing required value.");
                    }
                    return args.getPropertyValue(name);
                }

                @Override
View Full Code Here

    @Override
    protected void doHandle(CommandContext ctx) throws CommandFormatException {

        Batch batch = ctx.getBatchManager().getActiveBatch();
        if(batch == null) {
            throw new CommandFormatException("No active batch.");
        }
        batch.clear();
    }
View Full Code Here

    @Override
    protected void doHandle(CommandContext ctx) throws CommandFormatException {

        BatchManager batchManager = ctx.getBatchManager();
        if(!batchManager.isBatchActive()) {
            throw new CommandFormatException("No active batch.");
        }

        Batch batch = batchManager.getActiveBatch();
        final int batchSize = batch.size();
        if(batchSize == 0) {
            throw new CommandFormatException("The batch is empty.");
        }

        String argsStr = ctx.getArgumentsString();
        if(argsStr == null) {
            throw new CommandFormatException("Missing line number.");
        }

        int i = 0;
        while(i < argsStr.length()) {
            if(Character.isWhitespace(argsStr.charAt(i))) {
                break;
            }
            ++i;
        }

        if(i == argsStr.length()) {
            throw new CommandFormatException("Missing the new command line after the index.");
        }

        String intStr = argsStr.substring(0, i);
        int lineNumber;
        try {
            lineNumber = Integer.parseInt(intStr);
        } catch(NumberFormatException e) {
            throw new CommandFormatException("Failed to parse line number '" + intStr + "': " + e.getLocalizedMessage());
        }

        if(lineNumber < 1 || lineNumber > batchSize) {
            throw new CommandFormatException(lineNumber + " isn't in range [1.." + batchSize + "].");
        }

        String editedLine = argsStr.substring(i).trim();
        if(editedLine.length() == 0) {
            throw new CommandFormatException("Missing the new command line after the index.");
        }

        if(editedLine.charAt(0) == '"') {
            if(editedLine.length() > 1 && editedLine.charAt(editedLine.length() - 1) == '"') {
                editedLine = editedLine.substring(1, editedLine.length() - 1);
View Full Code Here

     */
    @Override
    protected void doHandle(CommandContext ctx) throws CommandFormatException {
        BatchManager batchManager = ctx.getBatchManager();
        if(!batchManager.isBatchActive()) {
            throw new CommandFormatException("No active batch.");
        }
        Batch activeBatch = batchManager.getActiveBatch();
        List<BatchedCommand> commands = activeBatch.getCommands();
        if (!commands.isEmpty()) {
            for (int i = 0; i < commands.size(); ++i) {
View Full Code Here

    @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.");
        }
    }
View Full Code Here

    @Override
    protected void doHandle(CommandContext ctx) throws CommandFormatException {

        BatchManager batchManager = ctx.getBatchManager();
        if(!batchManager.isBatchActive()) {
            throw new CommandFormatException("No active batch to holdback.");
        }

        String name = null;
        ParsedCommandLine args = ctx.getParsedCommandLine();
        if(args.hasProperties()) {
            name = args.getOtherProperties().get(0);
        }

        if(batchManager.isHeldback(name)) {
            throw new CommandFormatException("There already is " + (name == null ? "unnamed" : "'" + name + "'") + " batch held back.");
        }

        if(!batchManager.holdbackActiveBatch(name)) {
            throw new CommandFormatException("Failed to holdback the batch.");
        }
    }
View Full Code Here

    @Override
    protected void doHandle(CommandContext ctx) throws CommandFormatException {

        BatchManager batchManager = ctx.getBatchManager();
        if(!batchManager.isBatchActive()) {
            throw new CommandFormatException("No active batch.");
        }

        Batch batch = batchManager.getActiveBatch();
        final int batchSize = batch.size();
        if(batchSize == 0) {
            throw new CommandFormatException("The batch is empty.");
        }

        List<String> arguments = ctx.getParsedCommandLine().getOtherProperties();
        if(arguments.isEmpty()) {
            throw new CommandFormatException("Missing line number.");
        }

        if(arguments.size() != 2) {
            throw new CommandFormatException("Expected two arguments but received: " + arguments);
        }

        String intStr = arguments.get(0);
        final int lineNumber;
        try {
            lineNumber = Integer.parseInt(intStr);
        } catch(NumberFormatException e) {
            throw new CommandFormatException("Failed to parse line number '" + intStr + "': " + e.getLocalizedMessage());
        }

        if(lineNumber < 1 || lineNumber > batchSize) {
            throw new CommandFormatException(lineNumber + " isn't in range [1.." + batchSize + "].");
        }

        intStr = arguments.get(1);
        final int toLineNumber;
        try {
            toLineNumber = Integer.parseInt(intStr);
        } catch(NumberFormatException e) {
            throw new CommandFormatException("Failed to parse line number '" + intStr + "': " + e.getLocalizedMessage());
        }

        if(toLineNumber < 1 || toLineNumber > batchSize) {
            throw new CommandFormatException(toLineNumber + " isn't in range [1.." + batchSize + "].");
        }

        batch.move(lineNumber - 1, toLineNumber - 1);
    }
View Full Code Here

    @Override
    protected void doHandle(CommandContext ctx) throws CommandFormatException {

        final BatchManager batchManager = ctx.getBatchManager();
        if(!batchManager.isBatchActive()) {
            throw new CommandFormatException("No active batch.");
        }

        final Batch batch = batchManager.getActiveBatch();
        List<BatchedCommand> currentBatch = batch.getCommands();
        if(currentBatch.isEmpty()) {
            batchManager.discardActiveBatch();
            throw new CommandFormatException("The batch is empty.");
        }

        final ModelNode composite = batch.toRequest();
        ModelNode result;
        try {
            result = ctx.getModelControllerClient().execute(composite);
        } catch (Exception e) {
            throw new CommandFormatException("Failed to execute batch: " + e.getLocalizedMessage());
        }
        if(Util.isSuccess(result)) {
            batchManager.discardActiveBatch();
            ctx.printLine("The batch executed successfully.");
        } else {
            throw new CommandFormatException("Failed to execute batch: " + Util.getFailureDescription(result));
        }
    }
View Full Code Here

    private final String name;
    private final String value;

    public SimpleParsedOperationRequestHeader(String name, String value) throws CommandFormatException {
        if(name == null) {
            throw new CommandFormatException("Header name is null.");
        }
        if(value == null) {
            throw new CommandFormatException("Value for header '" + name + "' is null.");
        }
        this.name = name;
        this.value = value;
    }
View Full Code Here

TOP

Related Classes of org.jboss.as.cli.CommandFormatException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.