Package org.apache.jackrabbit.spi.commons.name

Examples of org.apache.jackrabbit.spi.commons.name.PathBuilder


        }

        NodeId parentId = getParentId();
        NodeImpl parentNode = (NodeImpl) getParent();
        Path parentPath = parentNode.getPrimaryPath();
        PathBuilder builder = new PathBuilder(parentPath);

        ChildNodeEntry entry =
            parentNode.getNodeState().getChildNodeEntry(getNodeId());
        if (entry == null) {
            String msg = "failed to build path of " + id + ": "
                    + parentId + " has no child entry for "
                    + id;
            log.debug(msg);
            throw new ItemNotFoundException(msg);
        }
        // add to path
        if (entry.getIndex() == 1) {
            builder.addLast(entry.getName());
        } else {
            builder.addLast(entry.getName(), entry.getIndex());
        }
        return builder.getPath();
    }
View Full Code Here


                                        NodeId parentId,
                                        HierarchyManager hmgr)
            throws ItemStateException {
        try {
            Name name = hmgr.getName(nodeId, parentId);
            PathBuilder builder = new PathBuilder();
            builder.addFirst(name);
            return builder.getPath().getNameElement();
        } catch (RepositoryException e) {
            String msg = "Unable to get name for node with id: " + nodeId;
            throw new ItemStateException(msg, e);
        }
    }
View Full Code Here

                                              NodeId parentId,
                                              ChangeLogBasedHierarchyMgr hmgr)
            throws ItemStateException {
        try {
            Name name = hmgr.getZombieName(nodeId, parentId);
            PathBuilder builder = new PathBuilder();
            builder.addFirst(name);
            return builder.getPath().getNameElement();
        } catch (RepositoryException e) {
            // should never happen actually
            String msg = "Unable to resolve zombie name for item: " + nodeId;
            log.error(msg);
            throw new ItemStateException(msg, e);
View Full Code Here

     */
    private Path prefixPath(Path p) throws RepositoryException {
        if (pathPrefix == null) {
            return p;
        }
        PathBuilder builder = new PathBuilder(pathPrefix.getElements());
        Path.Element[] elements = p.getElements();
        for (int i = 0; i < elements.length; i++) {
            if (elements[i].denotesRoot()) {
                continue;
            }
            builder.addLast(elements[i]);
        }
        return builder.getPath();
    }
View Full Code Here

        // check existence
        if (!hasNode(srcName.getName(), srcName.getIndex())) {
            String name;
            try {
                Path.Element[] path = new Path.Element[] { srcName };
                name = session.getJCRPath(new PathBuilder(path).getPath());
            } catch (NameException e) {
                name = srcName.toString();
            } catch (NamespaceException e) {
                name = srcName.toString();
            }
            throw new ItemNotFoundException(
                    this + " has no child node with name " + name);
        }
        if (dstName != null && !hasNode(dstName.getName(), dstName.getIndex())) {
            String name;
            try {
                Path.Element[] path = new Path.Element[] { dstName };
                name = session.getJCRPath(new PathBuilder(path).getPath());
            } catch (NameException e) {
                name = dstName.toString();
            } catch (NamespaceException e) {
                name = dstName.toString();
            }
View Full Code Here

        }

        NodeId parentId = getParentId();
        NodeImpl parentNode = (NodeImpl) getParent();
        Path parentPath = parentNode.getPrimaryPath();
        PathBuilder builder = new PathBuilder(parentPath);

        ChildNodeEntry entry = ((NodeState) parentNode.getItemState()).
                getChildNodeEntry(getNodeId());
        if (entry == null) {
            String msg = "failed to build path of " + id + ": "
                    + parentId + " has no child entry for "
                    + id;
            log.debug(msg);
            throw new ItemNotFoundException(msg);
        }
        // add to path
        if (entry.getIndex() == 1) {
            builder.addLast(entry.getName());
        } else {
            builder.addLast(entry.getName(), entry.getIndex());
        }
        return builder.getPath();
    }
View Full Code Here

            if (p != null) {
                removedNodeIds.add(itemId);
                int index = p.getNameElement().getNormalizedIndex();
                if (index > Path.INDEX_DEFAULT) {
                    Path.Element[] elems = p.getElements();
                    PathBuilder pb = new PathBuilder();
                    for (int i = 0; i <= elems.length - 2; i++) {
                        pb.addLast(elems[i]);
                    }
                    pb.addLast(p.getNameElement().getName(), index - 1);

                    NodeId prevSibling = idFactory.createNodeId(itemId.getUniqueID(), pb.getPath());
                    if (removedNodeIds.contains(prevSibling)) {
                        nodeId = prevSibling;
                    }
                }
            }
View Full Code Here

     */
    protected ItemId resolvePath(Path.Element[] elements, int next,
                                 ItemId id, int typesAllowed)
            throws ItemStateException, MalformedPathException {

        PathBuilder builder = new PathBuilder();
        for (int i = 0; i < next; i++) {
            builder.addLast(elements[i]);
        }
        for (int i = next; i < elements.length; i++) {
            Path.Element elem = elements[i];
            NodeId parentId = (NodeId) id;
            id = null;

            Name name = elem.getName();
            int index = elem.getIndex();
            if (index == 0) {
                index = 1;
            }
            int typeExpected = typesAllowed;
            if (i < elements.length - 1) {
                // intermediate items must always be nodes
                typeExpected = RETURN_NODE;
            }
            NodeState parentState = (NodeState) getItemState(parentId);
            if ((typeExpected & RETURN_NODE) != 0) {
                ChildNodeEntry nodeEntry =
                        getChildNodeEntry(parentState, name, index);
                if (nodeEntry != null) {
                    id = nodeEntry.getId();
                }
            }
            if (id == null && (typeExpected & RETURN_PROPERTY) != 0) {
                if (parentState.hasPropertyName(name) && (index <= 1)) {
                    // property
                    id = new PropertyId(parentState.getNodeId(), name);
                }
            }
            if (id == null) {
                break;
            }
            builder.addLast(elements[i]);
            pathResolved(id, builder);
        }
        return id;
    }
View Full Code Here

        // shortcut
        if (id.equals(rootNodeId)) {
            return PathFactoryImpl.getInstance().getRootPath();
        }

        PathBuilder builder = new PathBuilder();

        try {
            buildPath(builder, getItemState(id));
            return builder.getPath();
        } catch (NoSuchItemStateException nsise) {
            String msg = "failed to build path of " + id;
            log.debug(msg);
            throw new ItemNotFoundException(msg, nsise);
        } catch (ItemStateException ise) {
View Full Code Here

        if (node.getOperation() == QueryConstants.OPERATION_SIMILAR) {
            // this is a bit ugly:
            // add the name of a dummy property because relPath actually
            // references a property. whereas the relPath of the similar
            // operation references a node
            PathBuilder builder;
            if (relPath == null) {
                builder = new PathBuilder();
            } else {
                builder = new PathBuilder(relPath);
            }
            builder.addLast(NameConstants.JCR_PRIMARYTYPE);
            try {
                relPath = builder.getPath();
            } catch (MalformedPathException e) {
                // will never happen
            }
        }
        String field = "";
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.spi.commons.name.PathBuilder

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.