Package org.jboss.as.cli

Examples of org.jboss.as.cli.CommandFormatException


            }
            if(!table.isAtLastRow()) {
                table.nextRow();
            }
        }
        throw new CommandFormatException(table.toString());
    }
View Full Code Here


        }
        ModelNode result;
        try {
            result = ctx.getModelControllerClient().execute(composite);
        } catch (IOException e) {
            throw new CommandFormatException("Failed to execute operation request.", e);
        }
        if (!result.hasDefined(Util.RESULT)) {
            return null;
        }
        return result.get(Util.RESULT);
View Full Code Here

    protected void doHandle(CommandContext ctx) throws CommandLineException {

        final ParsedCommandLine parsedCmd = ctx.getParsedCommandLine();
        final String actionValue = action.getValue(parsedCmd);
        if(actionValue == null) {
            throw new CommandFormatException("Action argument is missing: " + ACTION_ADD + " or " + ACTION_REMOVE);
        }

        if(ACTION_ADD.equals(actionValue)) {
            addModule(parsedCmd);
        } else if(ACTION_REMOVE.equals(actionValue)) {
            removeModule(parsedCmd);
        } else {
            throw new CommandFormatException("Unexpected action '" + actionValue + "', expected values: " + ACTION_ADD + ", " + ACTION_REMOVE);
        }
    }
View Full Code Here

            if(propsStr != null) {
                final String[] pairs = propsStr.split(",");
                for (String pair : pairs) {
                    int equals = pair.indexOf('=');
                    if (equals == -1) {
                        throw new CommandFormatException("Property '" + pair + "' in '" + propsStr + "' is missing the equals sign.");
                    }
                    final String propName = pair.substring(0, equals);
                    if (propName.isEmpty()) {
                        throw new CommandFormatException("Property name is missing for '" + pair + "' in '" + propsStr + "'");
                    }
                    config.setProperty(propName, pair.substring(equals + 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 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

        request.get(Util.NAME).set(Util.ADD);
        final ModelNode response;
        try {
            response = ctx.getModelControllerClient().execute(request);
        } catch (IOException e) {
            throw new CommandFormatException("Failed to execute read-operation-description.", e);
        }
        if (!response.hasDefined(Util.RESULT)) {
            return null;
        }
        final ModelNode result = response.get(Util.RESULT);
View Full Code Here

        final ModelControllerClient client = ctx.getModelControllerClient();
        final ModelNode response;
        try {
            response = client.execute(request);
        } catch (Exception e) {
            throw new CommandFormatException("Failed to perform operation: " + e.getLocalizedMessage());
        }
        if (!Util.isSuccess(response)) {
            throw new CommandFormatException(Util.getFailureDescription(response));
        }
        handleResponse(ctx, response, Util.COMPOSITE.equals(request.get(Util.OPERATION).asString()));
    }
View Full Code Here

                                BatchedCommand batchedCmd = new DefaultBatchedCommand(line, request);
                                Batch batch = getBatchManager().getActiveBatch();
                                batch.add(batchedCmd);
                                printLine("#" + batch.size() + " " + batchedCmd.getCommand());
                            } catch (CommandFormatException e) {
                                throw new CommandFormatException("Failed to add to batch '" + line + "'", e);
                            }
                        }
                    } else {
                        handler.handle(this);
                    }
View Full Code Here

            return name;
        }
        @Override
        public void nameSeparator() throws CommandFormatException {
            if(buf == null) {
                throw new CommandFormatException("Property name is null.");
            }
            name = buf.toString();
            buf.setLength(0);
        }
View Full Code Here

    public void handle(CommandContext ctx) throws CommandLineException {
        boolean printCommands;
        try {
            printCommands = commands.isPresent(ctx.getParsedCommandLine());
        } catch (CommandFormatException e) {
            throw new CommandFormatException(e.getLocalizedMessage());
        }

        if(printCommands) {
            final List<String> commands = new ArrayList<String>();
            ctx.getDefaultCommandCompleter().complete(ctx, "", 0, commands);
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.