Search in sources :

Example 16 with NodeEntry

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

the class TransientItemStateManager method createNewPropertyState.

/**
     * Creates a new transient property state for a given <code>parent</code>
     * node state.
     *
     * @param propName the name of the property state to create.
     * @param parent   the node state where to the new property is added.
     * @param definition
     * @return the created property state.
     * @throws ItemExistsException if <code>parent</code> already has a property
     * with the given name.
     * @throws ConstraintViolationException
     * @throws RepositoryException
     */
PropertyState createNewPropertyState(Name propName, NodeState parent, QPropertyDefinition definition, QValue[] values, int propertyType) throws ItemExistsException, ConstraintViolationException, RepositoryException {
    // NOTE: callers must make sure, the property type is not 'undefined'
    NodeEntry nodeEntry = (NodeEntry) parent.getHierarchyEntry();
    PropertyEntry pe = nodeEntry.addNewPropertyEntry(propName, definition, values, propertyType);
    try {
        parent.markModified();
    } catch (RepositoryException e) {
        pe.remove();
        throw e;
    }
    return pe.getPropertyState();
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry) RepositoryException(javax.jcr.RepositoryException)

Example 17 with NodeEntry

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

the class WorkspaceItemStateFactory method getAncestor.

/**
     * @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();
    }
    return parent;
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry)

Example 18 with NodeEntry

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

the class RemoveLabel method persisted.

/**
     * Invalidates the jcr:versionLabel nodestate present with the given
     * version history and all decendant states (property states).
     *
     * @see Operation#persisted()
     */
public void persisted() throws RepositoryException {
    status = STATUS_PERSISTED;
    try {
        NodeEntry vhEntry = (NodeEntry) versionHistoryState.getHierarchyEntry();
        NodeEntry lnEntry = vhEntry.getNodeEntry(NameConstants.JCR_VERSIONLABELS, Path.INDEX_DEFAULT);
        if (lnEntry != null) {
            lnEntry.invalidate(true);
        }
    } catch (RepositoryException e) {
        log.debug(e.getMessage());
    }
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) RepositoryException(javax.jcr.RepositoryException)

Example 19 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 20 with NodeEntry

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

the class ItemImpl method getParent.

/**
     * @see Item#getParent()
     */
public Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException {
    checkStatus();
    // special treatment for root node
    if (state.isNode() && ((NodeState) state).isRoot()) {
        String msg = "Root node doesn't have a parent.";
        log.debug(msg);
        throw new ItemNotFoundException(msg);
    }
    NodeEntry parentEntry = getItemState().getHierarchyEntry().getParent();
    return (Node) getItemManager().getItem(parentEntry);
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) Node(javax.jcr.Node) ItemNotFoundException(javax.jcr.ItemNotFoundException)

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