Package org.jboss.as.cli.operation

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


            DefaultOperationRequestParser.INSTANCE.parse(type, handler);
        } catch (CommandFormatException e) {
            throw new IllegalArgumentException("Failed to parse nodeType: " + e.getMessage());
        }

        OperationRequestAddress typeAddress = handler.getAddress();
        if(!typeAddress.endsOnType()) {
            return null;
        }

        final String typeName = typeAddress.toParentNode().getType();
        for(OperationRequestAddress.Node node : typeAddress) {
            address.add(node.getType(), node.getName());
        }
        address.add(typeName, "?");
        return request;
View Full Code Here


        } catch (CommandFormatException e) {
            ctx.printLine("Failed to validate input: " + e.getLocalizedMessage());
            return false;
        }

        OperationRequestAddress typeAddress = handler.getAddress();
        if(!typeAddress.endsOnType()) {
            ctx.printLine("Node path '" + typePath + "' doesn't appear to end on a type.");
            return false;
        }

        final String typeName = typeAddress.toParentNode().getType();
        for(OperationRequestAddress.Node node : typeAddress) {
            address.add(node.getType(), node.getName());
        }

        request.get("operation").set("read-children-types");
View Full Code Here

        if (obj == null)
            return false;
        if (!(obj instanceof OperationRequestAddress))
            return false;

        OperationRequestAddress other = (OperationRequestAddress) obj;

        if(isEmpty() != other.isEmpty())
            return false;

        Iterator<Node> thisIterator = iterator();
        Iterator<Node> otherIterator = other.iterator();
        boolean result = true;
        while(result) {
            if(!thisIterator.next().equals(otherIterator.next())) {
                result = false;
            } else {
View Full Code Here

     */
    @Override
    public void handle(CommandContext ctx) {

        String args = ctx.getCommandArguments();
        OperationRequestAddress prefix = ctx.getPrefix();

        if(args == null) {
            ctx.log(ctx.getPrefixFormatter().format(prefix));
            return;
        }
View Full Code Here

    protected void doHandle(CommandContext ctx) throws CommandFormatException {

        final ParsedCommandLine parsedCmd = ctx.getParsedCommandLine();
        String nodePath = this.nodePath.getValue(parsedCmd);

        final OperationRequestAddress address;
        if (nodePath != null) {
            address = new DefaultOperationRequestAddress(ctx.getCurrentNodePath());
            CommandLineParser.CallbackHandler handler = new DefaultCallbackHandler(address);

            // this is for correct parsing of escaped characters
            nodePath = ctx.getArgumentsString();
            if(l.isPresent(parsedCmd)) {
                nodePath = nodePath.trim();
                if(nodePath.startsWith("-l ")) {
                    nodePath = nodePath.substring(3);
                } else {
                    nodePath = nodePath.substring(0, nodePath.length() - 3);
                }
            }
            ctx.getCommandLineParser().parse(nodePath, handler);
        } else {
            address = new DefaultOperationRequestAddress(ctx.getCurrentNodePath());
        }

        List<String> names = null;
        if(address.endsOnType()) {
            final String type = address.getNodeType();
            address.toParentNode();
            names = Util.getNodeNames(ctx.getModelControllerClient(), address, type);
            printList(ctx, names, l.isPresent(parsedCmd));
            return;
        }

        final ModelNode composite = new ModelNode();
        composite.get(Util.OPERATION).set(Util.COMPOSITE);
        composite.get(Util.ADDRESS).setEmptyList();
        final ModelNode steps = composite.get(Util.STEPS);

        {
            final ModelNode typesRequest = new ModelNode();
            typesRequest.get(Util.OPERATION).set(Util.READ_CHILDREN_TYPES);
            final ModelNode addressNode = typesRequest.get(Util.ADDRESS);
            if (address.isEmpty()) {
                addressNode.setEmptyList();
            } else {
                Iterator<Node> iterator = address.iterator();
                while (iterator.hasNext()) {
                    OperationRequestAddress.Node node = iterator.next();
                    if (node.getName() != null) {
                        addressNode.add(node.getType(), node.getName());
                    } else if (iterator.hasNext()) {
                        throw new OperationFormatException(
                                "Expected a node name for type '"
                                        + node.getType()
                                        + "' in path '"
                                        + ctx.getNodePathFormatter().format(
                                                address) + "'");
                    }
                }
            }
            steps.add(typesRequest);
        }

        {
            final ModelNode resourceRequest = new ModelNode();
            resourceRequest.get(Util.OPERATION).set(Util.READ_RESOURCE);
            final ModelNode addressNode = resourceRequest.get(Util.ADDRESS);
            if (address.isEmpty()) {
                addressNode.setEmptyList();
            } else {
                Iterator<Node> iterator = address.iterator();
                while (iterator.hasNext()) {
                    OperationRequestAddress.Node node = iterator.next();
                    if (node.getName() != null) {
                        addressNode.add(node.getType(), node.getName());
                    } else if (iterator.hasNext()) {
View Full Code Here

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

        final String nodePath = this.nodePath.getValue(ctx.getParsedCommandLine());

        OperationRequestAddress prefix = ctx.getCurrentNodePath();

        if(nodePath == null) {
            ctx.printLine(ctx.getNodePathFormatter().format(prefix));
            return;
        }

        final OperationRequestAddress tmp = new DefaultOperationRequestAddress(prefix);
        ctx.getCommandLineParser().parse(ctx.getArgumentsString(), new DefaultCallbackHandler(tmp));
        assertValid(ctx, tmp);

        if(tmp.isEmpty()) {
            prefix.reset();
        } else {
            prefix.reset();
            for(OperationRequestAddress.Node node : tmp) {
                if(node.getName() != null) {
View Full Code Here

    protected void doHandle(CommandContext ctx) throws CommandFormatException {

        final ParsedCommandLine parsedCmd = ctx.getParsedCommandLine();
        String nodePath = this.nodePath.getValue(parsedCmd);

        final OperationRequestAddress address;
        if (nodePath != null) {
            address = new DefaultOperationRequestAddress(ctx.getPrefix());
            CommandLineParser.CallbackHandler handler = new DefaultCallbackHandler(address);

            // this is for correct parsing of escaped characters
            nodePath = ctx.getArgumentsString();
            if(l.isPresent(parsedCmd)) {
                nodePath = nodePath.trim();
                if(nodePath.startsWith("-l ")) {
                    nodePath = nodePath.substring(3);
                } else {
                    nodePath = nodePath.substring(0, nodePath.length() - 3);
                }
            }

            try {
                ctx.getCommandLineParser().parse(nodePath, handler);
            } catch (CommandFormatException e) {
                ctx.error(e.getLocalizedMessage());
            }
        } else {
            address = new DefaultOperationRequestAddress(ctx.getPrefix());
        }

        List<String> names = null;
        if(address.endsOnType()) {
            final String type = address.getNodeType();
            address.toParentNode();
            names = Util.getNodeNames(ctx.getModelControllerClient(), address, type);
        } else {
            final ModelNode composite = new ModelNode();
            composite.get(Util.OPERATION).set(Util.COMPOSITE);
            composite.get(Util.ADDRESS).setEmptyList();
            final ModelNode steps = composite.get(Util.STEPS);

            {
                final ModelNode typesRequest = new ModelNode();
                typesRequest.get(Util.OPERATION).set(Util.READ_CHILDREN_TYPES);
                final ModelNode addressNode = typesRequest.get(Util.ADDRESS);
                if (address.isEmpty()) {
                    addressNode.setEmptyList();
                } else {
                    Iterator<Node> iterator = address.iterator();
                    while (iterator.hasNext()) {
                        OperationRequestAddress.Node node = iterator.next();
                        if (node.getName() != null) {
                            addressNode.add(node.getType(), node.getName());
                        } else if (iterator.hasNext()) {
                            throw new OperationFormatException("Expected a node name for type '" + node.getType()
                                    + "' in path '" + ctx.getPrefixFormatter().format(address) + "'");
                        }
                    }
                }
                steps.add(typesRequest);
            }

            {
                final ModelNode resourceRequest = new ModelNode();
                resourceRequest.get(Util.OPERATION).set(Util.READ_RESOURCE);
                final ModelNode addressNode = resourceRequest.get(Util.ADDRESS);
                if (address.isEmpty()) {
                    addressNode.setEmptyList();
                } else {
                    Iterator<Node> iterator = address.iterator();
                    while (iterator.hasNext()) {
                        OperationRequestAddress.Node node = iterator.next();
                        if (node.getName() != null) {
                            addressNode.add(node.getType(), node.getName());
                        } else if (iterator.hasNext()) {
View Full Code Here

                       ParserUtil.parseOperationRequest(thePath, callback);
                   } catch (CommandFormatException e) {
                       return Collections.emptyList();
                   }

                   OperationRequestAddress typeAddress = callback.getAddress();
                   if (!typeAddress.endsOnType()) {
                       return Collections.emptyList();
                   }
                   return Collections.singletonList(typeAddress.getNodeType());
               }

                if (actionName.equals("remove")) {
                    return getExistingCommands();
                }
View Full Code Here

            ParserUtil.parseOperationRequest(type, callback);
        } catch (CommandFormatException e) {
            throw new IllegalArgumentException("Failed to parse nodeType: " + e.getMessage());
        }

        OperationRequestAddress typeAddress = callback.getAddress();
        if(!typeAddress.endsOnType()) {
            return null;
        }

        final String typeName = typeAddress.toParentNode().getType();
        for(OperationRequestAddress.Node node : typeAddress) {
            address.add(node.getType(), node.getName());
        }
        address.add(typeName, "?");
        return request;
View Full Code Here

        } catch (CommandFormatException e) {
            ctx.error("Failed to validate input: " + e.getLocalizedMessage());
            return false;
        }

        OperationRequestAddress typeAddress = callback.getAddress();
        if(!typeAddress.endsOnType()) {
            ctx.error("Node path '" + typePath + "' doesn't appear to end on a type.");
            return false;
        }

        final String typeName = typeAddress.toParentNode().getType();
        for(OperationRequestAddress.Node node : typeAddress) {
            address.add(node.getType(), node.getName());
        }

        request.get(Util.OPERATION).set(Util.READ_CHILDREN_TYPES);
View Full Code Here

TOP

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

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.