Package org.jboss.as.cli.operation

Examples of org.jboss.as.cli.operation.OperationFormatException


                builder.addProperty(argName, ctx.getNamedArgument(argName));
            }
        }

        if(name == null) {
            throw new OperationFormatException("Required argument 'name' is missing.");
        }

        builder.addNode("connection-factory", name);
        ModelNode entriesNode = builder.getModelNode().get("entries");
        if(entriesStr == null) {
View Full Code Here


    public ModelNode buildRequest(CommandContext ctx)
            throws OperationFormatException {

        final String name = ctx.getNamedArgument("name");
        if(name == null) {
            throw new OperationFormatException("Required argument 'name' is missing.");
        }

        DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
        builder.addNode("subsystem", "jms");
        builder.addNode("queue", name);
View Full Code Here

    @Override
    public ModelNode buildRequest(CommandContext ctx)
            throws OperationFormatException {

        if(!ctx.hasArguments()) {
            throw new OperationFormatException("Missing required argument 'name'.");
        }

        String name = ctx.getNamedArgument("name");
        if(name == null) {
            List<String> args = ctx.getArguments();
            if(!args.isEmpty()) {
                name = args.get(0);
            }
        }

        if(name == null) {
            throw new OperationFormatException("Missing required argument 'name'.");
        }

        DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
        builder.addNode("subsystem", "jms");
        builder.addNode("connection-factory", name);
View Full Code Here

        composite.get("operation").set("composite");
        composite.get("address").setEmptyList();
        ModelNode steps = composite.get("steps");

        if(!ctx.hasArguments()) {
            throw new OperationFormatException("Required arguments are missing.");
        }

        String deployment = null;
        List<String> args = ctx.getArguments();
        if(args.size() > 0) {
View Full Code Here

    @Override
    public ModelNode buildRequest(CommandContext ctx)
            throws OperationFormatException {

        if(!ctx.hasArguments()) {
            throw new OperationFormatException("Missing required argument 'name'.");
        }

        String name = ctx.getNamedArgument("name");
        if(name == null) {
            List<String> args = ctx.getArguments();
            if(!args.isEmpty()) {
                name = args.get(0);
            }
        }

        if(name == null) {
            new OperationFormatException("Missing required argument 'name'.");
        }

        DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
        builder.addNode("subsystem", "jms");
        builder.addNode("queue", name);
View Full Code Here

    @Override
    public ModelNode buildRequest(CommandContext ctx) throws OperationFormatException {

        final String name = ctx.getNamedArgument("name");
        if(name == null) {
            throw new OperationFormatException("Required argument 'name' is missing.");
        }

        DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
        builder.addNode("subsystem", "jms");
        builder.addNode("topic", name);
View Full Code Here

    @Override
    public ModelNode buildRequest(CommandContext ctx) throws OperationFormatException {

        if(!ctx.hasArguments()) {
            throw new OperationFormatException("Arguments are missing");
        }

        //String target = null;
        String restype = null;
        //String description = null;
        String propsStr = null;
        //boolean enabled = false;
        String jndiName = null;

        String[] args = ctx.getCommandArguments().split("\\s+");
        int i = 0;
        while(i < args.length) {
            String arg = args[i++];
            if(arg.equals("--restype")) {
                if(i < args.length) {
                    restype = args[i++];
                }
            } else if(arg.equals("--target")) {
//                if(i < args.length) {
//                    target = args[i++];
//                }
            } else if(arg.equals("--description")) {
//                if(i < args.length) {
//                    restype = args[i++];
//                }
            } else if(arg.equals("--property")) {
                if (i < args.length) {
                    propsStr = args[i++];
                }
            } else if(arg.equals("--enabled")) {
//                if (i < args.length) {
//                    enabled = Boolean.parseBoolean(args[i++]);
//                }
            } else {
                jndiName = arg;
            }
        }

        if(restype == null) {
            throw new OperationFormatException("Required parameter --restype is missing.");
        }

        if(jndiName == null) {
            throw new OperationFormatException("JNDI name is missing.");
        }

        String name = null;
        final Map<String, String> props;
        if(propsStr != null) {
            props = new HashMap<String, String>();
            String[] propsArr = propsStr.split(":");
            for(String prop : propsArr) {
                int equalsIndex = prop.indexOf('=');
                if(equalsIndex < 0 || equalsIndex == prop.length() - 1) {
                    throw new OperationFormatException("Failed to parse property '" + prop + "'");
                }

                String propName = prop.substring(0, equalsIndex).trim();
                String propValue = prop.substring(equalsIndex + 1).trim();
                if(propName.isEmpty()) {
                    throw new OperationFormatException("Failed to parse property '" + prop + "'");
                }

                if(propName.equals("imqDestinationName") ||propName.equalsIgnoreCase("name")) {
                    name = propValue;
                } else if("ClientId".equals(propName)) {
                    props.put("client-id", propValue);
                }
            }
        } else {
            props = Collections.emptyMap();
        }

        if(name == null) {
            name = jndiName.replace('/', '_');
        }

        if(restype.equals("javax.jms.Queue")) {

            DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
            builder.addNode("subsystem", "jms");
            builder.addNode("queue", name);
            builder.setOperationName("add");
            builder.getModelNode().get("entries").add(jndiName);

            for(String prop : props.keySet()) {
                builder.addProperty(prop, props.get(prop));
            }

            return builder.buildRequest();

        } else if(restype.equals("javax.jms.Topic")) {

            DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
            builder.addNode("subsystem", "jms");
            builder.addNode("topic", name);
            builder.setOperationName("add");
            builder.getModelNode().get("entries").add(jndiName);

            for(String prop : props.keySet()) {
                builder.addProperty(prop, props.get(prop));
            }

            return builder.buildRequest();

        } else if(restype.equals("javax.jms.ConnectionFactory") ||
                restype.equals("javax.jms.TopicConnectionFactory") ||
                restype.equals("javax.jms.QueueConnectionFactory")) {

            DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
            builder.addNode("subsystem", "jms");
            builder.addNode("connection-factory", name);
            builder.setOperationName("add");
            builder.getModelNode().get("entries").add(jndiName);

            for(String prop : props.keySet()) {
                builder.addProperty(prop, props.get(prop));
            }

            return builder.buildRequest();

        } else {
            throw new OperationFormatException("Resource type " + restype + " isn't supported.");
        }
    }
View Full Code Here

    }

    public ModelNode buildRequest(CommandContext ctx) throws OperationFormatException {

        if (!ctx.hasArguments()) {
            throw new OperationFormatException("Required arguments are missing.");
        }

        String filePath = null;
        String name = null;
        String runtimeName = null;

        for(String arg : ctx.getArguments()) {
            if (filePath == null) {
                filePath = arg;
            } else if (name == null) {
                name = arg;
            } else {
                runtimeName = arg;
            }
        }

        if(filePath == null) {
            throw new OperationFormatException("File path is missing.");
        }

        File f = new File(filePath);
        if(!f.exists()) {
            throw new OperationFormatException(f.getAbsolutePath() + " doesn't exist.");
        }

        if(name == null) {
            name = f.getName();
        }

        if(Util.isDeployed(name, ctx.getModelControllerClient())) {
            if(ctx.hasSwitch("f")) {
                DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();

                // replace
                builder = new DefaultOperationRequestBuilder();
                builder.setOperationName("full-replace-deployment");
                builder.addProperty("name", name);
                if(runtimeName != null) {
                    builder.addProperty("runtime-name", runtimeName);
                }

                byte[] bytes = readBytes(f);
                builder.getModelNode().get("bytes").set(bytes);
                return builder.buildRequest();
            } else {
                throw new OperationFormatException("'" + name + "' is already deployed (use -f to force re-deploy).");
            }
        }

        ModelNode composite = new ModelNode();
        composite.get("operation").set("composite");
View Full Code Here

        try {
            is = new FileInputStream(f);
            bytes = new byte[(int) f.length()];
            int read = is.read(bytes);
            if(read != bytes.length) {
                throw new OperationFormatException("Failed to read bytes from " + f.getAbsolutePath() + ": " + read + " from " + f.length());
            }
        } catch (Exception e) {
            throw new OperationFormatException("Failed to read file " + f.getAbsolutePath(), e);
        } finally {
            StreamUtils.safeClose(is);
        }
        return bytes;
    }
View Full Code Here

    @Override
    public ModelNode buildRequest(CommandContext ctx)
            throws OperationFormatException {

        if(!ctx.hasArguments()) {
            throw new OperationFormatException("Arguments are missing");
        }

        //String target = null;
        String jndiName = null;

        String[] args = ctx.getCommandArguments().split("\\s+");
        int i = 0;
        while(i < args.length) {
            String arg = args[i++];
            if(arg.equals("--target")) {
//                if(i < args.length) {
//                    target = args[i++];
//                }
            } else {
                jndiName = arg;
            }
        }

        if(jndiName == null) {
            throw new OperationFormatException("name is missing.");
        }

        ModelControllerClient client = ctx.getModelControllerClient();
        final String resource;
        if(Util.isTopic(client, jndiName)) {
            resource = "topic";
        } else if(Util.isQueue(client, jndiName)) {
            resource = "queue";
        } else if(Util.isConnectionFactory(client, jndiName)) {
            resource = "connection-factory";
        } else {
            throw new OperationFormatException("'" + jndiName +"' wasn't found among existing JMS resources.");
        }

        DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
        builder.addNode("subsystem", "jms");
        builder.addNode(resource, jndiName);
View Full Code Here

TOP

Related Classes of org.jboss.as.cli.operation.OperationFormatException

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.