Package org.jboss.as.cli

Examples of org.jboss.as.cli.CommandFormatException


                continue;
            }

            final ArgumentWithValue arg = (ArgumentWithValue) nodeProps.get(argName);
            if(arg == null) {
                throw new CommandFormatException("Unrecognized argument name '" + argName + "'");
            }

            DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
            if (profile != null) {
                builder.addNode(Util.PROFILE, profile);
View Full Code Here


            if(argsMap == null) {
                if(argName.equals(this.name.getFullName())) {
                    continue;
                }
                throw new CommandFormatException("Command '" + operation + "' is not expected to have arguments other than " + this.name.getFullName() + ".");
            }

            final ArgumentWithValue arg = (ArgumentWithValue) argsMap.get(argName);
            if(arg == null) {
                if(argName.equals(this.name.getFullName())) {
                    continue;
                }
                throw new CommandFormatException("Unrecognized argument " + argName + " for command '" + operation + "'.");
            }

            final String propName;
            if(argName.charAt(1) == '-') {
                propName = argName.substring(2);
View Full Code Here

                name = f.getName();
            }
        } else {
            f = null;
            if(name == null) {
                throw new CommandFormatException("Either file path or --name has to be specified.");
            }
        }

        if(Util.isDeploymentInRepository(name, ctx.getModelControllerClient()) && f != null) {
            if(force.isPresent(args)) {
View Full Code Here

    private void validateRequest(CommandContext ctx, ModelNode request) throws CommandFormatException {

        final ModelControllerClient client = ctx.getModelControllerClient();
        if(client == null) {
            throw new CommandFormatException("No connection to the controller.");
        }

        final Set<String> keys = request.keys();

        if(!keys.contains(Util.OPERATION)) {
            throw new CommandFormatException("Request is missing the operation name.");
        }
        final String operationName = request.get(Util.OPERATION).asString();

        if(!keys.contains(Util.ADDRESS)) {
            throw new CommandFormatException("Request is missing the address part.");
        }
        final ModelNode address = request.get(Util.ADDRESS);

        if(keys.size() == 2) { // no props
            return;
        }

        final ModelNode opDescrReq = new ModelNode();
        opDescrReq.get(Util.ADDRESS).set(address);
        opDescrReq.get(Util.OPERATION).set(Util.READ_OPERATION_DESCRIPTION);
        opDescrReq.get(Util.NAME).set(operationName);

        final ModelNode outcome;
        try {
            outcome = client.execute(opDescrReq);
        } catch(Exception e) {
            throw new CommandFormatException("Failed to perform " + Util.READ_OPERATION_DESCRIPTION + " to validate the request: " + e.getLocalizedMessage());
        }
        if (!Util.isSuccess(outcome)) {
            throw new CommandFormatException("Failed to get the list of the operation properties: \"" + Util.getFailureDescription(outcome) + '\"');
        }

        if(!outcome.has(Util.RESULT)) {
            throw new CommandFormatException("Failed to perform " + Util.READ_OPERATION_DESCRIPTION + " to validate the request: result is not available.");
        }
        final ModelNode result = outcome.get(Util.RESULT);
        if(!result.hasDefined(Util.REQUEST_PROPERTIES)) {
            throw new CommandFormatException("Operation '" + operationName + "' does not expect any property.");
        }
        final Set<String> definedProps = result.get("request-properties").keys();
        if(definedProps.isEmpty()) {
            throw new CommandFormatException("Operation '" + operationName + "' does not expect any property.");
        }

        int skipped = 0;
        for(String prop : keys) {
            if(skipped < 2 && (prop.equals(Util.ADDRESS) || prop.equals(Util.OPERATION))) {
                ++skipped;
                continue;
            }
            if(!definedProps.contains(prop)) {
                if(!Util.OPERATION_HEADERS.equals(prop)) {
                    throw new CommandFormatException("'" + prop + "' is not found among the supported properties: " + definedProps);
                }
            }
        }
    }
View Full Code Here

        } else if(ConcurrentSignState.ID.equals(id)) {
            concurrent = true;
        } else if ("NAME_VALUE_SEPARATOR".equals(id)) {
            name = buffer.length() == 0 ? null : buffer.toString().trim();
            if(name == null || name.isEmpty()) {
                throw new CommandFormatException("Property is missing name at index " + ctx.getLocation());
            }

            if(name.equals(Util.IN_SERIES)) {
                ctx.enterState(ServerGroupListState.INSTANCE);
            }
View Full Code Here

        if(id.equals(HeaderValueState.ID)) {
            handler.header(header);
        } else if(PropertyValueState.ID.equals(id)) {
            final String value = buffer.length() == 0 ? null : buffer.toString().trim();
            if(value == null || value.isEmpty()) {
                throw new CommandFormatException("Property '" + name + "' is missing value at index " + ctx.getLocation());
            }

            if(group != null) {
                ((SingleRolloutPlanGroup)group).addProperty(name, value);
            } else {
                header.addProperty(name, value);
            }
            name = null;
        } else if(ServerGroupNameState.ID.equals(id)) {
            final String groupName = buffer.toString().trim();
            if(groupName.isEmpty()) {
                throw new CommandFormatException("Empty group name at index " + ctx.getLocation());
            }
            ((SingleRolloutPlanGroup)group).setGroupName(groupName);
        } else if(ServerGroupState.ID.equals(id)) {
            if(concurrent) {
                header.addConcurrentGroup(group);
View Full Code Here

    @Override
    public void argument(String name, int nameStart, String value, int valueStart, int end) throws CommandFormatException {
        if(name != null) {
            if(handler != null && !handler.hasArgument(name)) {
                throw new CommandFormatException("Unexpected argument name '" + name + "'.");
            }
            namedArgs.put(name, value);
        } else if(value != null) {
            if(handler != null && !handler.hasArgument(otherArgs.size())) {
                throw new CommandFormatException("Unexpected argument '" + value + "'.");
            }
            otherArgs.add(value);
        }
    }
View Full Code Here

            return null;
        }
        if(isPresent(args)) {
            return null;
        }
        throw new CommandFormatException("Required argument '" + fullName + "' is missing value.");
    }
View Full Code Here

                ModelNode nodeValue = new ModelNode();
                String[] props = valueString.split(",");
                for(String prop : props) {
                    int equals = prop.indexOf('=');
                    if(equals == -1) {
                        throw new CommandFormatException("Property '" + prop + "' in '" + valueString + "' is missing the equals sign.");
                    }
                    String propName = prop.substring(0, equals);
                    if(propName.isEmpty()) {
                        throw new CommandFormatException("Property name is missing for '" + prop + "' in '" + valueString + "'");
                    }
                    nodeValue.add(propName, prop.substring(equals + 1));
                }
                builder.getModelNode().get("value").set(nodeValue);
            } else {
View Full Code Here

                ModelNode nodeValue = new ModelNode();
                String[] props = valueString.split(",");
                for(String prop : props) {
                    int equals = prop.indexOf('=');
                    if(equals == -1) {
                        throw new CommandFormatException("Property '" + prop + "' in '" + valueString + "' is missing the equals sign.");
                    }
                    String propName = prop.substring(0, equals);
                    if(propName.isEmpty()) {
                        throw new CommandFormatException("Property name is missing for '" + prop + "' in '" + valueString + "'");
                    }
                    nodeValue.add(propName, prop.substring(equals + 1));
                }
                builder.getModelNode().get(argName).set(nodeValue);
            } else {
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.