Package org.jboss.dna.graph.properties

Examples of org.jboss.dna.graph.properties.Path


        // Wrap the executor with a logging executor ...
        executor = new LoggingCommandExecutor(executor, context.getLogger(getClass()), Logger.Level.DEBUG);

        // The configuration projection (via "executor") will convert this path into a path that exists in the configuration
        // repository
        Path configNode = pathFactory.create(PATH_TO_CONFIGURATION_INFORMATION);

        try {
            // Get the repository node ...
            BasicGetNodeCommand getRepository = new BasicGetNodeCommand(configNode);
            executor.execute(getRepository);
            if (getRepository.hasError()) {
                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


        if (reposPathStr == null || sourcePathStr == null) return null;
        reposPathStr = reposPathStr.trim();
        sourcePathStr = sourcePathStr.trim();
        if (reposPathStr.length() == 0 || sourcePathStr.length() == 0) return null;
        PathFactory pathFactory = context.getValueFactories().getPathFactory();
        Path repositoryPath = pathFactory.create(reposPathStr);
        Path sourcePath = pathFactory.create(sourcePathStr);

        // Grab the exceptions ...
        List<Path> exceptions = new LinkedList<Path>();
        while (matcher.find()) {
            String exceptionStr = matcher.group(1);
            Path exception = pathFactory.create(exceptionStr);
            exceptions.add(exception);
        }
        return new PathRule(repositoryPath, sourcePath, exceptions);
    }
View Full Code Here

                                       PathFactory factory ) {
        CheckArg.isNotNull(factory, "factory");
        assert canonicalPathInRepository == null ? true : canonicalPathInRepository.equals(canonicalPathInRepository.getCanonicalPath());
        Set<Path> paths = new HashSet<Path>();
        for (Rule rule : getRules()) {
            Path pathInSource = rule.getPathInSource(canonicalPathInRepository, factory);
            if (pathInSource != null) paths.add(pathInSource);
        }
        return paths;
    }
View Full Code Here

                                           PathFactory factory ) {
        CheckArg.isNotNull(factory, "factory");
        assert canonicalPathInSource == null ? true : canonicalPathInSource.equals(canonicalPathInSource.getCanonicalPath());
        Set<Path> paths = new HashSet<Path>();
        for (Rule rule : getRules()) {
            Path pathInRepository = rule.getPathInRepository(canonicalPathInSource, factory);
            if (pathInRepository != null) paths.add(pathInRepository);
        }
        return paths;
    }
View Full Code Here

        // Get the set of repository paths for the rules, and see if they overlap ...
        Set<Path> repositoryPaths = new HashSet<Path>();
        for (Rule rule : rules) {
            if (rule instanceof PathRule) {
                PathRule pathRule = (PathRule)rule;
                Path repoPath = pathRule.getPathInRepository();
                if (!repositoryPaths.isEmpty()) {
                    if (repositoryPaths.contains(repoPath)) return false;
                    for (Path path : repositoryPaths) {
                        if (path.isAtOrAbove(repoPath)) return false;
                        if (repoPath.isAtOrAbove(path)) return false;
                    }
                }
                repositoryPaths.add(repoPath);
            } else {
                return false;
View Full Code Here

            if (this.sourcePath.isAtOrAbove(pathInSource)) {

                // The path is inside the source-specific region, so check the exceptions ...
                List<Path> exceptions = getExceptionsToRule();
                if (exceptions.size() != 0) {
                    Path subpathInSource = pathInSource.relativeTo(this.sourcePath);
                    if (subpathInSource.size() != 0) {
                        for (Path exception : exceptions) {
                            if (subpathInSource.isAtOrBelow(exception)) return false;
                        }
                    }
                }
                return true;
            }
View Full Code Here

        @Override
        public Path getPathInSource( Path pathInRepository,
                                     PathFactory factory ) {
            assert pathInRepository.equals(pathInRepository.getCanonicalPath());
            // Project the repository path into the equivalent source path ...
            Path pathInSource = projectPathInRepositoryToPathInSource(pathInRepository, factory);

            // Check whether the source path is included by this rule ...
            return includes(pathInSource) ? pathInSource : null;
        }
View Full Code Here

         */
        protected Path projectPathInSourceToPathInRepository( Path pathInSource,
                                                              PathFactory factory ) {
            if (!this.sourcePath.isAtOrAbove(pathInSource)) return null;
            // Remove the leading source path ...
            Path relativeSourcePath = pathInSource.relativeTo(this.sourcePath);
            // Prepend the region's root path ...
            Path result = factory.create(this.repositoryPath, relativeSourcePath);
            return result.getNormalizedPath();
        }
View Full Code Here

         */
        protected Path projectPathInRepositoryToPathInSource( Path pathInRepository,
                                                              PathFactory factory ) {
            if (!this.repositoryPath.isAtOrAbove(pathInRepository)) return null;
            // Find the relative path from the root of this region ...
            Path pathInRegion = pathInRepository.relativeTo(this.repositoryPath);
            // Prepend the path in source ...
            Path result = factory.create(this.sourcePath, pathInRegion);
            return result.getNormalizedPath();
        }
View Full Code Here

     *
     * @see org.jboss.dna.graph.commands.executor.AbstractCommandExecutor#execute(org.jboss.dna.graph.commands.GetChildrenCommand)
     */
    @Override
    public void execute( GetChildrenCommand command ) throws RepositorySourceException {
        Path pathInSource = getPathInSource(command.getPath());
        getConnection().execute(this.getExecutionContext(), new ProjectedGetChildrenCommand(command, pathInSource));
    }
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.properties.Path

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.