Package org.jboss.as.cli.operation

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


        DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
        if(dependsOnProfile && ctx.isDomainMode()) {
            final String profile = this.profile.getValue(args);
            if(profile == null) {
                throw new OperationFormatException("Required argument --profile is missing.");
            }
            builder.addNode("profile", profile);
        }

        final String name = this.name.getValue(ctx.getParsedCommandLine(), true);
View Full Code Here


    public ModelNode buildRequest(CommandContext ctx) throws CommandFormatException {

        ParsedCommandLine args = ctx.getParsedCommandLine();
        if (!args.hasProperties()) {
            throw new OperationFormatException("Required arguments are missing.");
        }

        final String filePath = path.getValue(args);
        String name = this.name.getValue(args);
        String runtimeName = rtName.getValue(args);

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

            if(name == null) {
                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)) {
                DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();

                // replace
                builder = new DefaultOperationRequestBuilder();
                builder.setOperationName(Util.FULL_REPLACE_DEPLOYMENT);
                builder.addProperty(Util.NAME, name);
                if(runtimeName != null) {
                    builder.addProperty(Util.RUNTIME_NAME, runtimeName);
                }

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

        final List<String> serverGroups;
        if (ctx.isDomainMode()) {
            if(allServerGroups.isPresent(args)) {
                serverGroups = Util.getServerGroups(ctx.getModelControllerClient());
            } else {
                String serverGroupsStr = this.serverGroups.getValue(args);
                if(serverGroupsStr == null) {
                    throw new OperationFormatException("Either --all-server-groups or --server-groups must be specified.");
                }
                serverGroups = Arrays.asList(serverGroupsStr.split(","));
            }

            if(serverGroups.isEmpty() && !disabled.isPresent(args)) {
                new OperationFormatException("No server group is available.");
            }
        } else {
            serverGroups = null;
        }
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

        ParsedCommandLine args = ctx.getParsedCommandLine();

        if(ctx.isDomainMode()) {
            String profile = this.profile.getValue(args);
            if(profile == null) {
                throw new OperationFormatException("--profile argument value is missing.");
            }
            builder.addNode("profile",profile);
        }

        final String name = this.name.getValue(args, true);
View Full Code Here

    public ModelNode buildRequest(CommandContext ctx)
            throws OperationFormatException {

        try {
            if(!ctx.getParsedCommandLine().hasProperties()) {
                throw new OperationFormatException("Arguments are missing");
            }
        } catch (CommandFormatException e) {
            throw new OperationFormatException(e.getLocalizedMessage());
        }

        //String target = null;
        String jndiName = null;
        String serverName = "default"; // TODO read server name from props

        String[] args = ctx.getArgumentsString().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 = "jms-topic";
        } else if(Util.isQueue(client, jndiName)) {
            resource = "jms-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", "messaging");
        builder.addNode("hornetq-server", serverName);
View Full Code Here

        DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
        if(ctx.isDomainMode()) {
            final String profile = this.profile.getValue(ctx.getParsedCommandLine());
            if(profile == null) {
                throw new OperationFormatException("Required argument --profile is missing.");
            }
            builder.addNode("profile", profile);
        }

        final String name = this.name.getValue(ctx.getParsedCommandLine(), true);
View Full Code Here

        ModelNode steps = composite.get("steps");

        final ParsedCommandLine args = ctx.getParsedCommandLine();
        final String name = this.name.getValue(args);
        if(name == null) {
            throw new OperationFormatException("Required argument name are missing.");
        }

        ModelControllerClient client = ctx.getModelControllerClient();
        DefaultOperationRequestBuilder builder;

        boolean keepContent;
        try {
            keepContent = this.keepContent.isPresent(args);
        } catch (CommandFormatException e) {
            throw new OperationFormatException(e.getLocalizedMessage());
        }
        if(ctx.isDomainMode()) {
            final List<String> serverGroups;
            try {
                if(allRelevantServerGroups.isPresent(args)) {
                    if(keepContent) {
                        serverGroups = Util.getAllEnabledServerGroups(name, client);
                    } else {
                        serverGroups = Util.getAllReferencingServerGroups(name, client);
                    }
                } else {
                    final String serverGroupsStr = this.serverGroups.getValue(args);
                    if(serverGroupsStr == null) {
                        //throw new OperationFormatException("Either --all-relevant-server-groups or --server-groups must be specified.");
                        serverGroups = Collections.emptyList();
                    } else {
                        serverGroups = Arrays.asList(serverGroupsStr.split(","));
                    }
                }
            } catch (CommandFormatException e) {
                throw new OperationFormatException(e.getLocalizedMessage());
            }

            if(serverGroups.isEmpty()) {
                if(keepContent) {
                    throw new OperationFormatException("None server group is specified or available.");
                }
            } else {
                for (String group : serverGroups){
                    ModelNode groupStep = Util.configureDeploymentOperation(DEPLOYMENT_UNDEPLOY_OPERATION, name, group);
                    steps.add(groupStep);
View Full Code Here

        ParsedCommandLine args = ctx.getParsedCommandLine();

        if(ctx.isDomainMode()) {
            String profile = this.profile.getValue(args);
            if(profile == null) {
                throw new OperationFormatException("--profile argument value is missing.");
            }
            builder.addNode("profile",profile);
        }

View Full Code Here

        ParsedCommandLine args = ctx.getParsedCommandLine();

        if(ctx.isDomainMode()) {
            String profile = this.profile.getValue(args);
            if(profile == null) {
                throw new OperationFormatException("--profile argument value is missing.");
            }
            builder.addNode("profile",profile);
        }

        final String name = this.name.getValue(args, true);
View Full Code Here

        DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
        if(ctx.isDomainMode()) {
            final String profile = this.profile.getValue(ctx.getParsedCommandLine());
            if(profile == null) {
                throw new OperationFormatException("Required argument --profile is missing.");
            }
            builder.addNode("profile", profile);
        }

        final String name = this.name.getValue(ctx.getParsedCommandLine(), true);
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.