Package org.jboss.dna.graph.property

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

This class simplifies working with paths and using a Path is often more efficient that processing and manipulating the equivalent String. This class can easily {@link #iterator() iterate} over the segments, returnthe {@link #size() number of segments}, {@link #compareTo(Path) compare} with other paths, {@link #resolve(Path) resolve}relative paths, return the {@link #getParent() ancestor (or parent)}, determine whether one path is an {@link #isAncestorOf(Path) ancestor} or {@link #isDecendantOf(Path) decendent} of another path, and{@link #getCommonAncestor(Path) finding a common ancestor}.


        if (request == null) return;
        Location from = request.at();
        if (!from.hasPath()) {
            throw new UnsupportedOperationException();
        }
        Path newPath = getExecutionContext().getValueFactories().getPathFactory().create(from.getPath(), request.toName());
        Location to = Location.create(newPath);
        MoveBranchRequest move = new MoveBranchRequest(from, to, request.inWorkspace());
        process(move);
        // Set the actual locations ...
        request.setActualLocations(move.getActualLocationBefore(), move.getActualLocationAfter());
View Full Code Here


     *
     * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.ReadNodeRequest)
     */
    @Override
    public void process( ReadNodeRequest request ) {
        Path federatedPath = request.at().getPath();
        Map<Name, Property> properties = request.getPropertiesByName();
        Map<Name, Integer> childSnsIndexes = new HashMap<Name, Integer>();
        ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest();

        request.setCachePolicy(getDefaultCachePolicy());
View Full Code Here

    protected Location getChildLocationWithCorrectSnsIndex( Location childInSource,
                                                            Path federatedPath,
                                                            Map<Name, Integer> childSnsIndexes,
                                                            Projection projection ) {
        // Project back into the federated repository ...
        Path childPath = childInSource.getPath();
        if (childPath.isRoot() || federatedPath == null) {
            // We've lost the name of the child, so we need to recompute the path ...
            for (Path path : projection.getPathsInRepository(childInSource.getPath(), pathFactory)) {
                childPath = path;
                if (federatedPath == null) federatedPath = path.getParent();
                break;
            }
        }

        // Correct the same-name-sibling index for the child ...
        Name childName = childPath.getLastSegment().getName();
        Integer snsIndex = childSnsIndexes.get(childName);
        if (snsIndex == null) {
            snsIndex = new Integer(1);
            childSnsIndexes.put(childName, snsIndex);
        } else {
            snsIndex = new Integer(snsIndex.intValue() + 1);
            childSnsIndexes.put(childName, snsIndex);
        }
        Path newPath = pathFactory.create(federatedPath, childName, snsIndex.intValue());
        return childInSource.with(newPath);
    }
View Full Code Here

     * @param projected
     */
    protected void setPathNotFound( Request original,
                                    Location originalLocation,
                                    ProjectedRequest projected ) {
        Path lowestExistingInFederated = pathFactory.createRootPath();
        while (projected != null) {
            Request projectedRequest = projected.getRequest();
            Throwable error = projectedRequest.getError();
            if (error instanceof PathNotFoundException) {
                PathNotFoundException notFound = (PathNotFoundException)error;
                Path lowestExisting = notFound.getLowestAncestorThatDoesExist();
                // Project back to the repository level ...
                for (Path federatedPath : projected.getProjection().getPathsInRepository(lowestExisting, pathFactory)) {
                    if (federatedPath.isAtOrBelow(lowestExistingInFederated)) {
                        lowestExistingInFederated = federatedPath;
                    }
View Full Code Here

     *
     * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.ReadAllChildrenRequest)
     */
    @Override
    public void process( ReadAllChildrenRequest request ) {
        Path federatedPath = request.of().getPath();
        Map<Name, Integer> childSnsIndexes = new HashMap<Name, Integer>();
        ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest();

        request.setCachePolicy(getDefaultCachePolicy());
        Location actualLocation = request.of();
View Full Code Here

            if (projection == null) {
                // It must be a placeholder node ...
                return inSource;
            }
            // Get the projection from the source-specific location ...
            Path pathInSource = inSource.getPath();
            for (Path path : projection.getPathsInRepository(pathInSource, pathFactory)) {
                return actual.with(path);
            }
        }
        return actual;
View Full Code Here

    protected Location determineActualLocation( Location actualInSource,
                                                Projection projection ) {
        assert projection != null;
        // Get the projection from the source-specific location ...
        Path pathInSource = actualInSource.getPath();
        for (Path path : projection.getPathsInRepository(pathInSource, pathFactory)) {
            return actualInSource.with(path);
        }
        return actualInSource;
    }
View Full Code Here

                                       Projection projection,
                                       ReadBranchRequest request,
                                       Location parent,
                                       List<Location> children,
                                       Map<Name, Property> propertiesByName ) {
        Path ancestorPath = ancestorInFederation.getPath();
        if (projection == null) {
            // This is a placeholder node ...
            if (children != null) {
                // Add the children (to any existing children) ...
                List<Location> existing = request.getChildren(parent);
                if (existing == null) existing = new ArrayList<Location>(children.size());
                for (Location child : children) {
                    existing.add(child);
                }
                request.setChildren(parent, existing);
            }
            if (propertiesByName != null) {
                // Add the properties to any existing properties ...
                Map<Name, Property> propsByName = request.getPropertiesFor(parent);
                if (propsByName == null) propsByName = new HashMap<Name, Property>();
                for (Property property : propertiesByName.values()) {
                    Property existingProperty = propsByName.get(property.getName());
                    if (existingProperty != null) {
                        // Merge the property values ...
                        property = merge(existingProperty, property, propertyFactory, true);
                    }
                    propsByName.put(property.getName(), property);
                }
                request.setProperties(parent, propsByName.values());
            }
            return;
        }
        for (Path path : projection.getPathsInRepository(parent.getPath(), pathFactory)) {
            if (!path.isAtOrBelow(ancestorPath)) continue;

            // Determine the list of children ...
            Location parentInFederation = parent.with(path);
            if (children != null) {
                // Add the children to any existing children ...
                List<Location> existing = request.getChildren(parentInFederation);
                if (existing == null) existing = new ArrayList<Location>(children.size());
                for (Location child : children) {
                    Path childPath = pathFactory.create(path, child.getPath().getLastSegment());
                    existing.add(child.with(childPath));
                }
                request.setChildren(parentInFederation, existing);
            }
View Full Code Here

     */
    protected Location projectToFederated( Location ancestorInFederation,
                                           Projection projection,
                                           Location actualSourceLocation,
                                           Request originalRequest ) {
        Path ancestorPath = ancestorInFederation.getPath();
        Path actualPathInSource = actualSourceLocation.getPath();
        // Project the actual location ...
        for (Path path : projection.getPathsInRepository(actualPathInSource, pathFactory)) {
            if (path.isAtOrBelow(ancestorPath)) {
                return actualSourceLocation.with(path);
            }
View Full Code Here

     * @return the location in the federated repository
     */
    protected Location projectToFederated( Projection projection,
                                           Location actualSourceLocation,
                                           Request originalRequest ) {
        Path actualPathInSource = actualSourceLocation.getPath();
        // Project the actual location ...
        for (Path path : projection.getPathsInRepository(actualPathInSource, pathFactory)) {
            return actualSourceLocation.with(path);
        }
        // Record that there was an error projecting the results ...
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.property.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.