Package org.apache.jackrabbit.jcr2spi.hierarchy

Examples of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry


        // Calculate relative path of missing entries
        Path anyParentPath = anyParent.getWorkspacePath();
        Path relPath = anyParentPath.computeRelativePath(info.getPath());
        Path.Element[] missingElems = relPath.getElements();

        NodeEntry entry = anyParent;
        int last = missingElems.length - 1;
        for (int i = 0; i <= last; i++) {
            if (missingElems[i].denotesParent()) {
                // Walk up the hierarchy for 'negative' paths
                // until the smallest common root is found
                entry = entry.getParent();
            } else if (missingElems[i].denotesName()) {
                // Add missing elements starting from the smallest common root
                Name name = missingElems[i].getName();
                int index = missingElems[i].getNormalizedIndex();

                if (i == last && !info.denotesNode()) {
                    return entry.getOrAddPropertyEntry(name);
                } else {
                    entry = createNodeEntry(entry, name, index);
                }
            }
        }
View Full Code Here


     * @param entry
     * @param degree
     * @return the ancestor entry at the specified degree.
     */
    private static NodeEntry getAncestor(HierarchyEntry entry, int degree) {
        NodeEntry parent = entry.getParent();
        degree--;
        while (parent != null && degree > 0) {
            parent = parent.getParent();
            degree--;
        }
        if (degree != 0) {
            log.error("Parent of degree {} does not exist.", degree);
            throw new IllegalArgumentException();
View Full Code Here

    /**
     * @see ItemManager#getNode(Path)
     */
    public synchronized Node getNode(Path path) throws PathNotFoundException, RepositoryException {
        NodeEntry nodeEntry = hierMgr.getNodeEntry(path);
        try {
            return (Node) getItem(nodeEntry);
        } catch (ItemNotFoundException infe) {
            throw new PathNotFoundException(LogUtil.safeGetJCRPath(path, session.getPathResolver()));
        }
View Full Code Here

        Iterator<NodeEntry> iter = parentEntry.getNodeEntries();
        while (iter.hasNext()) {
            try {
                // check read access by accessing the nodeState (implicit validation check)
                NodeEntry entry = iter.next();
                entry.getNodeState();
                return true;
            } catch (ItemNotFoundException e) {
                // should not occur. ignore
                log.debug("Failed to access node state.", e);
            }
View Full Code Here

     */
    public void visit(SetMixin operation) throws ConstraintViolationException, AccessDeniedException, NoSuchNodeTypeException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
        // NOTE: nodestate is only modified upon save of the changes!
        Name[] mixinNames = operation.getMixinNames();
        NodeState nState = operation.getNodeState();
        NodeEntry nEntry = nState.getNodeEntry();

        // assert the existence of the property entry and set the array of
        // mixinNames to be set on the corresponding property state
        PropertyEntry mixinEntry = nEntry.getPropertyEntry(NameConstants.JCR_MIXINTYPES);
        if (mixinNames.length > 0) {
            // update/create corresponding property state
            if (mixinEntry != null) {
                // execute value of existing property
                PropertyState pState = mixinEntry.getPropertyState();
View Full Code Here

     */
    public void visit(SetPrimaryType operation) throws ConstraintViolationException, RepositoryException {
        // NOTE: nodestate is only modified upon save of the changes!
        Name primaryName = operation.getPrimaryTypeName();
        NodeState nState = operation.getNodeState();
        NodeEntry nEntry = nState.getNodeEntry();

        // detect obvious node type conflicts

        EffectiveNodeTypeProvider entProvider = mgrProvider.getEffectiveNodeTypeProvider();

        // try to build new effective node type (will throw in case of conflicts)
        Name[] mixins = nState.getMixinTypeNames();
        List<Name> all = new ArrayList<Name>(Arrays.asList(mixins));
        all.add(primaryName);
        // retrieve effective to assert validity of arguments
        entProvider.getEffectiveNodeType(all.toArray(new Name[all.size()]));

        // modify the value of the jcr:primaryType property entry without
        // changing the node state itself
        PropertyEntry pEntry = nEntry.getPropertyEntry(NameConstants.JCR_PRIMARYTYPE);
        PropertyState pState = pEntry.getPropertyState();
        setPropertyStateValue(pState, getQValues(new Name[] {primaryName}, qValueFactory), PropertyType.NAME, operation.getOptions());

        // mark the affected node state modified and remember the operation
        nState.markModified();
View Full Code Here

     * @throws ItemNotFoundException
     * @throws RepositoryException
     */
    public NodeState getParent() throws ItemNotFoundException, RepositoryException {
        // safeguard against root node's null parent
        NodeEntry parent = getHierarchyEntry().getParent();
        if (parent != null) {
            return getHierarchyEntry().getParent().getNodeState();
        }
        return null;
    }
View Full Code Here

     * @return The <code>NodeState</code> with the specified name and index
     * @throws ItemNotFoundException
     * @throws RepositoryException
     */
    public NodeState getChildNodeState(Name nodeName, int index) throws ItemNotFoundException, RepositoryException {
        NodeEntry ne = getNodeEntry().getNodeEntry(nodeName, index, true);
        if (ne != null) {
            return ne.getNodeState();
        } else {
            // does not exist (any more) or is a property
            throw new ItemNotFoundException("Child node "+ nodeName +" with index " + index + " does not exist.");
        }
    }
View Full Code Here

     * <code>beforeNode</code> is not a child node of this <code>NodeState</code>.
     */
    synchronized void reorderChildNodeEntries(NodeState insertNode, NodeState beforeNode)
        throws ItemNotFoundException, RepositoryException {

        NodeEntry before = (beforeNode == null) ? null : beforeNode.getNodeEntry();
        insertNode.getNodeEntry().orderBefore(before);

        // mark this state as modified
        markModified();
    }
View Full Code Here

    /**
     * @see Node#getNode(String)
     */
    public Node getNode(String relPath) throws PathNotFoundException, RepositoryException {
        checkStatus();
        NodeEntry nodeEntry = resolveRelativeNodePath(relPath);
        if (nodeEntry == null) {
            throw new PathNotFoundException(relPath);
        }
        try {
            return (Node) getItemManager().getItem(nodeEntry);
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry

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.