Search in sources :

Example 6 with NodeEntry

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

the class ResolveMergeConflict method persisted.

/**
     * Invalidates the <code>NodeState</code> that had a merge conflict pending
     * and all its child properties.
     *
     * @see Operation#persisted()
     */
public void persisted() {
    assert status == STATUS_PENDING;
    status = STATUS_PERSISTED;
    // non-recursive invalidation BUT including all properties
    Iterator<PropertyEntry> propEntries = ((NodeEntry) nodeState.getHierarchyEntry()).getPropertyEntries();
    while (propEntries.hasNext()) {
        PropertyEntry pe = propEntries.next();
        pe.invalidate(false);
    }
    nodeState.getHierarchyEntry().invalidate(false);
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry)

Example 7 with NodeEntry

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

the class SessionImpl method getNodeById.

/**
     * Retrieve the <code>Node</code> with the given id.
     *
     * @param id
     * @return node with the given <code>NodeId</code>.
     * @throws ItemNotFoundException if no such node exists or if this
     * <code>Session</code> does not have permission to access the node.
     * @throws RepositoryException
     */
private Node getNodeById(NodeId id) throws ItemNotFoundException, RepositoryException {
    // check sanity of this session
    checkIsAlive();
    try {
        NodeEntry nodeEntry = getHierarchyManager().getNodeEntry(id);
        Item item = getItemManager().getItem(nodeEntry);
        if (item.isNode()) {
            return (Node) item;
        } else {
            log.error("NodeId '" + id + " does not point to a Node");
            throw new ItemNotFoundException(LogUtil.saveGetIdString(id, getPathResolver()));
        }
    } catch (AccessDeniedException e) {
        throw new ItemNotFoundException(LogUtil.saveGetIdString(id, getPathResolver()));
    }
}
Also used : Item(javax.jcr.Item) AccessDeniedException(javax.jcr.AccessDeniedException) NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) Node(javax.jcr.Node) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Example 8 with NodeEntry

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

the class NodeImpl method checkpoint.

Version checkpoint() throws RepositoryException {
    checkIsVersionable();
    checkHasPendingChanges();
    checkIsLocked();
    if (!isCheckedOut()) {
        checkout();
        return getBaseVersion();
    } else {
        NodeEntry newVersion;
        if (session.isSupportedOption(Repository.OPTION_ACTIVITIES_SUPPORTED)) {
            NodeImpl activity = (NodeImpl) session.getWorkspace().getVersionManager().getActivity();
            NodeId activityId = (activity == null) ? null : activity.getNodeState().getNodeId();
            newVersion = session.getVersionStateManager().checkpoint(getNodeState(), activityId);
        } else {
            newVersion = session.getVersionStateManager().checkpoint(getNodeState());
        }
        return (Version) getItemManager().getItem(newVersion);
    }
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) Version(javax.jcr.version.Version) NodeId(org.apache.jackrabbit.spi.NodeId)

Example 9 with NodeEntry

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

the class NodeImpl method getNode.

/**
     * @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);
    } catch (ItemNotFoundException e) {
        throw new PathNotFoundException(relPath, e);
    }
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) AddNode(org.apache.jackrabbit.jcr2spi.operation.AddNode) Node(javax.jcr.Node) PathNotFoundException(javax.jcr.PathNotFoundException) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Example 10 with NodeEntry

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

the class NodeImpl method resolveRelativeNodePath.

/**
     * Returns the <code>NodeEntry</code> at <code>relPath</code> or
     * <code>null</code> if no node exists at <code>relPath</code>.
     * <p>
     * Note that access rights are not checked.
     *
     * @param relPath relative path of a (possible) node.
     * @return the HierarchyEntry of the node at <code>relPath</code> or
     * <code>null</code> if no node exists at <code>relPath</code>.
     * @throws RepositoryException if <code>relPath</code> is not a valid
     * relative path.
     */
private NodeEntry resolveRelativeNodePath(String relPath) throws RepositoryException {
    NodeEntry targetEntry = null;
    try {
        Path rp = session.getPathResolver().getQPath(relPath);
        // shortcut
        if (rp.getLength() == 1) {
            if (rp.denotesCurrent()) {
                targetEntry = getNodeEntry();
            } else if (rp.denotesParent()) {
                targetEntry = getNodeEntry().getParent();
            } else {
                // try to get child entry + force loading of not known yet
                targetEntry = getNodeEntry().getNodeEntry(rp.getName(), rp.getNormalizedIndex(), true);
            }
        } else {
            // rp length > 1
            Path p = getPath(rp);
            targetEntry = session.getHierarchyManager().getNodeEntry(p.getCanonicalPath());
        }
    } catch (PathNotFoundException e) {
    // item does not exist -> ignore and return null
    } catch (NameException e) {
        String msg = "Invalid relative path: " + relPath;
        log.debug(msg);
        throw new RepositoryException(msg, e);
    }
    return targetEntry;
}
Also used : Path(org.apache.jackrabbit.spi.Path) NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) RepositoryException(javax.jcr.RepositoryException) PathNotFoundException(javax.jcr.PathNotFoundException)

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