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}.


            return new SubgraphNodeImpl(location, request);
        }

        public SubgraphNode getNode( String pathStr ) {
            CheckArg.isNotEmpty(pathStr, "path");
            Path path = createPath(pathStr);
            path = getAbsolutePath(path);
            return getNode(path);
        }
View Full Code Here


            path = getAbsolutePath(path);
            return getNode(path);
        }

        public SubgraphNode getNode( Name relativePath ) {
            Path path = getGraph().getContext()
                                  .getValueFactories()
                                  .getPathFactory()
                                  .create(getLocation().getPath(), relativePath);
            path = path.getNormalizedPath();
            return getNode(path);
        }
View Full Code Here

            path = path.getNormalizedPath();
            return getNode(path);
        }

        protected Path getAbsolutePath( Path absoluteOrRelative ) {
            Path result = absoluteOrRelative;
            if (!result.isAbsolute()) {
                result = getGraph().getContext().getValueFactories().getPathFactory().create(getLocation().getPath(), result);
                result = result.getNormalizedPath();
            }
            return result;
        }
View Full Code Here

        public Iterator<Location> iterator() {
            return getChildren().iterator();
        }

        public SubgraphNode getNode( Name childName ) {
            Path path = getContext().getValueFactories().getPathFactory().create(location.getPath(), childName);
            Location location = request.getLocationFor(path);
            if (location == null) return null;
            return new SubgraphNodeImpl(location, request);
        }
View Full Code Here

            if (location == null) return null;
            return new SubgraphNodeImpl(location, request);
        }

        public SubgraphNode getNode( Path relativePath ) {
            Path path = getContext().getValueFactories().getPathFactory().create(location.getPath(), relativePath);
            path = path.getNormalizedPath();
            Location location = request.getLocationFor(path);
            if (location == null) return null;
            return new SubgraphNodeImpl(location, request);
        }
View Full Code Here

    public void invalidate( Path path ) {
        assert path != null;

        for (Iterator<Path> iter = nodesByPath.keySet().iterator(); iter.hasNext();) {
            Path key = iter.next();
            if (key.isAtOrBelow(path)) {
                iter.remove();
            }
        }
    }
View Full Code Here

                                                                 boolean loadIfRequired )
        throws PathNotFoundException, AccessControlException {
        Node<Payload, PropertyPayload> node = startingPoint;
        if (!relativePath.isRoot()) {
            // Find the absolute path, which ensures that the relative path is well-formed ...
            Path absolutePath = relativePath.resolveAgainst(startingPoint.getPath());

            // Verify that the user has the appropriate privileges to read these nodes...
            authorizer.checkPermissions(absolutePath, Action.READ);

            // Walk down the path ...
            Iterator<Path.Segment> iter = relativePath.iterator();
            while (iter.hasNext()) {
                Path.Segment segment = iter.next();
                try {
                    if (segment.isSelfReference()) continue;
                    if (segment.isParentReference()) {
                        node = node.getParent();
                        assert node != null; // since the relative path is well-formed
                        continue;
                    }

                    if (node.isLoaded()) {
                        // The child is the next node we need to process ...
                        node = node.getChild(segment);
                    } else {
                        if (!loadIfRequired) return null;
                        // The node has not yet been loaded into the cache, so read this node
                        // from the store as well as all nodes along the path to the node we're really
                        // interested in. We'll do this in a batch, so first create this batch ...
                        Graph.Batch batch = store.batch();

                        // Figure out which nodes along the path need to be loaded from the store ...
                        Path firstPath = node.getPath();
                        batch.read(firstPath);
                        // Now add the path to the child (which is no longer on the iterator) ...
                        Path nextPath = pathFactory.create(firstPath, segment);
                        if (!iter.hasNext() && loadDepth > 1) {
                            batch.readSubgraphOfDepth(loadDepth).at(nextPath);
                        } else {
                            batch.read(nextPath);
                        }
                        // Now add any remaining paths that are still on the iterator ...
                        while (iter.hasNext()) {
                            nextPath = pathFactory.create(nextPath, iter.next());
                            if (!iter.hasNext() && loadDepth > 1) {
                                batch.readSubgraphOfDepth(loadDepth).at(nextPath);
                            } else {
                                batch.read(nextPath);
                            }
                        }

                        // Load all of the nodes (we should be reading at least 2 nodes) ...
                        Results batchResults = batch.execute();

                        // Add the children and properties in the lowest cached node ...
                        Path previousPath = null;
                        Node<Payload, PropertyPayload> topNode = node;
                        Node<Payload, PropertyPayload> previousNode = node;
                        for (org.jboss.dna.graph.Node persistentNode : batchResults) {
                            Location location = persistentNode.getLocation();
                            Path path = location.getPath();
                            if (path.isRoot()) {
                                previousNode = root;
                                root.location = location;
                            } else {
                                if (path.getParent().equals(previousPath)) {
                                    previousNode = previousNode.getChild(path.getLastSegment());
                                } else {
                                    Path subgraphPath = path.relativeTo(topNode.getPath());
                                    previousNode = findNodeRelativeTo(topNode, subgraphPath);
                                }
                                // Set the node that we're looking for ...
                                if (path.getLastSegment().equals(relativePath.getLastSegment()) && path.equals(absolutePath)) {
                                    node = previousNode;
View Full Code Here

    public void immediateMove( Path nodeToMove,
                               Path destination ) throws AccessControlException, RepositorySourceException {
        CheckArg.isNotNull(nodeToMove, "nodeToMove");
        CheckArg.isNotNull(destination, "destination");

        Path newParentPath = destination.getParent();
        Name newName = destination.getLastSegment().getName();

        // Check authorization ...
        authorizer.checkPermissions(newParentPath, Action.ADD_NODE);
        authorizer.checkPermissions(nodeToMove.getParent(), Action.REMOVE);
View Full Code Here

        Location locationOfCopy = request.getActualLocationAfter();

        // Remove from the session all of the nodes that were removed as part of this clone ...
        Set<Path> removedAlready = new HashSet<Path>();
        for (Location removed : request.getRemovedNodes()) {
            Path path = removed.getPath();
            if (isBelow(path, removedAlready)) {
                // This node is below a node we've already removed, so skip it ...
                continue;
            }
            Node<Payload, PropertyPayload> removedNode = findNodeWith(path, false);
View Full Code Here

        // Make sure the builder has finished all the requests ...
        this.requestBuilder.finishPendingRequest();

        // Remove all of the enqueued requests for this branch ...
        Path path = node.getPath();
        LinkedList<Request> branchRequests = new LinkedList<Request>();
        LinkedList<Request> nonBranchRequests = new LinkedList<Request>();
        for (Request request : this.requests) {
            assert request instanceof ChangeRequest;
            ChangeRequest change = (ChangeRequest)request;
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.