Search in sources :

Example 11 with NodeEntry

use of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry in project jackrabbit by apache.

the class JcrVersionManager method createActivity.

/**
     * @see javax.jcr.version.VersionManager#createActivity(String)
     */
public Node createActivity(String title) throws UnsupportedRepositoryOperationException, RepositoryException {
    session.checkIsAlive();
    NodeEntry entry = vMgr.createActivity(title);
    return (Node) itemManager.getItem(entry);
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) Node(javax.jcr.Node)

Example 12 with NodeEntry

use of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry in project jackrabbit by apache.

the class ItemManagerImpl method hasChildNodes.

/**
     * @see ItemManager#hasChildNodes(NodeEntry)
     */
public synchronized boolean hasChildNodes(NodeEntry parentEntry) throws ItemNotFoundException, RepositoryException {
    // check sanity of session
    session.checkIsAlive();
    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);
        }
    }
    return false;
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Example 13 with NodeEntry

use of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry in project jackrabbit by apache.

the class LockManagerImpl method buildLockState.

private LockState buildLockState(NodeState nodeState) throws RepositoryException {
    NodeId nId = nodeState.getNodeId();
    NodeState lockHoldingState;
    LockInfo lockInfo = wspManager.getLockInfo(nId);
    if (lockInfo == null) {
        // no lock present
        return null;
    }
    NodeId lockNodeId = lockInfo.getNodeId();
    if (lockNodeId.equals(nId)) {
        lockHoldingState = nodeState;
    } else {
        NodeEntry lockedEntry = wspManager.getHierarchyManager().getNodeEntry(lockNodeId);
        try {
            lockHoldingState = lockedEntry.getNodeState();
        } catch (RepositoryException e) {
            log.warn("Cannot build LockState");
            throw new RepositoryException("Cannot build LockState", e);
        }
    }
    if (lockHoldingState == null) {
        return null;
    } else {
        return new LockState(lockHoldingState, lockInfo);
    }
}
Also used : NodeState(org.apache.jackrabbit.jcr2spi.state.NodeState) NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) NodeId(org.apache.jackrabbit.spi.NodeId) LockInfo(org.apache.jackrabbit.spi.LockInfo) RepositoryException(javax.jcr.RepositoryException)

Example 14 with NodeEntry

use of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry in project jackrabbit by apache.

the class LockManagerImpl method getLockHoldingState.

//------------------------------------------------------------< private >---
/**
     * Search nearest ancestor that is locked. Returns <code>null</code> if neither
     * the given state nor any of its ancestors is locked.
     * Note, that this methods does NOT check if the given node state would
     * be affected by the lock present on an ancestor state.
     * Note, that in certain cases it might not be possible to detect a lock
     * being present due to the fact that the hierarchy might be incomplete or
     * not even readable completely. For this reason it seem equally reasonable
     * to search for jcr:lockIsDeep property only and omitting all kind of
     * verification regarding nodetypes present.
     *
     * @param nodeState <code>NodeState</code> from which searching starts.
     * Note, that the given state must not have an overlaid state.
     * @return a state holding a lock or <code>null</code> if neither the
     * given state nor any of its ancestors is locked.
     */
private NodeState getLockHoldingState(NodeState nodeState) {
    NodeEntry entry = nodeState.getNodeEntry();
    while (!entry.hasPropertyEntry(NameConstants.JCR_LOCKISDEEP)) {
        NodeEntry parent = entry.getParent();
        if (parent == null) {
            // reached root state without finding a locked node
            return null;
        }
        entry = parent;
    }
    try {
        return entry.getNodeState();
    } catch (RepositoryException e) {
        // may occur if the nodeState is not accessible or some generic
        // error occurred.
        // for this case, assume that no lock exists and delegate final
        // validation to the spi-implementation.
        log.warn("Error while accessing lock holding NodeState: {}", e.getMessage());
        return null;
    }
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) RepositoryException(javax.jcr.RepositoryException)

Example 15 with NodeEntry

use of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry in project jackrabbit by apache.

the class Checkin method persisted.

/**
     * Invalidate the target <code>NodeState</code>.
     *
     * @see Operation#persisted()
     */
public void persisted() {
    assert status == STATUS_PENDING;
    status = STATUS_PERSISTED;
    try {
        NodeEntry vhe = mgr.getVersionHistoryEntry(nodeState);
        if (vhe != null) {
            vhe.invalidate(true);
        }
    } catch (RepositoryException e) {
        log.debug("Failed to access Version history entry -> skip invalidation.", e);
    }
    Iterator<PropertyEntry> entries = ((NodeEntry) nodeState.getHierarchyEntry()).getPropertyEntries();
    while (entries.hasNext()) {
        PropertyEntry pe = entries.next();
        pe.invalidate(false);
    }
    nodeState.getHierarchyEntry().invalidate(false);
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry) RepositoryException(javax.jcr.RepositoryException)

Aggregations

NodeEntry (org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry)40 RepositoryException (javax.jcr.RepositoryException)13 PropertyEntry (org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry)10 ItemNotFoundException (javax.jcr.ItemNotFoundException)9 Name (org.apache.jackrabbit.spi.Name)9 Node (javax.jcr.Node)6 ItemExistsException (javax.jcr.ItemExistsException)5 NodeState (org.apache.jackrabbit.jcr2spi.state.NodeState)4 ArrayList (java.util.ArrayList)3 Version (javax.jcr.version.Version)3 NodeId (org.apache.jackrabbit.spi.NodeId)3 Path (org.apache.jackrabbit.spi.Path)3 PathNotFoundException (javax.jcr.PathNotFoundException)2 EffectiveNodeTypeProvider (org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeTypeProvider)2 PropertyState (org.apache.jackrabbit.jcr2spi.state.PropertyState)2 QPropertyDefinition (org.apache.jackrabbit.spi.QPropertyDefinition)2 QValue (org.apache.jackrabbit.spi.QValue)2 NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)2 AccessDeniedException (javax.jcr.AccessDeniedException)1 Item (javax.jcr.Item)1