Package org.jboss.dna.graph.commands.basic

Examples of org.jboss.dna.graph.commands.basic.BasicGetChildrenCommand


                throw new FederationException(FederationI18n.federatedRepositoryCannotBeFound.text(repositoryName));
            }

            // Get the first child node of the "dna:cache" node, since this represents the source used as the cache ...
            Path cacheNode = pathFactory.create(configNode, nameFactory.create(DNA_CACHE_SEGMENT));
            BasicGetChildrenCommand getCacheSource = new BasicGetChildrenCommand(cacheNode);

            executor.execute(getCacheSource);
            if (getCacheSource.hasError() || getCacheSource.getChildren().size() < 1) {
                I18n msg = FederationI18n.requiredNodeDoesNotExistRelativeToNode;
                throw new FederationException(msg.text(DNA_CACHE_SEGMENT, configNode));
            }

            // Add a command to get the projection defining the cache ...
            Path pathToCacheRegion = pathFactory.create(cacheNode, getCacheSource.getChildren().get(0));
            BasicGetNodeCommand getCacheRegion = new BasicGetNodeCommand(pathToCacheRegion);
            executor.execute(getCacheRegion);
            Projection cacheProjection = createProjection(context,
                                                          projectionParser,
                                                          getCacheRegion.getPath(),
                                                          getCacheRegion.getPropertiesByName(),
                                                          problems);

            if (getCacheRegion.hasError()) {
                I18n msg = FederationI18n.requiredNodeDoesNotExistRelativeToNode;
                throw new FederationException(msg.text(DNA_CACHE_SEGMENT, configNode));
            }

            // Get the source projections for the repository ...
            Path projectionsNode = pathFactory.create(configNode, nameFactory.create(DNA_PROJECTIONS_SEGMENT));
            BasicGetChildrenCommand getProjections = new BasicGetChildrenCommand(projectionsNode);

            executor.execute(getProjections);
            if (getProjections.hasError()) {
                I18n msg = FederationI18n.requiredNodeDoesNotExistRelativeToNode;
                throw new FederationException(msg.text(DNA_PROJECTIONS_SEGMENT, configNode));
            }

            // Build the commands to get each of the projections (children of the "dna:projections" node) ...
            List<Projection> sourceProjections = new LinkedList<Projection>();
            if (getProjections.hasNoError() && !getProjections.getChildren().isEmpty()) {
                BasicCompositeCommand commands = new BasicCompositeCommand();
                for (Path.Segment child : getProjections.getChildren()) {
                    final Path pathToSource = pathFactory.create(projectionsNode, child);
                    commands.add(new BasicGetNodeCommand(pathToSource));
                }
                // Now execute these commands ...
                executor.execute(commands);
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.commands.basic.BasicGetChildrenCommand

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.