Search in sources :

Example 36 with NodeEntry

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

the class Restore method persisted.

/**
     * In case of a workspace-restore or 'removeExisting' the complete tree gets
     * invalidated, otherwise the given <code>NodeState</code> that has been
     * updated and all its descendants.
     *
     * @see Operation#persisted()
     */
public void persisted() {
    assert status == STATUS_PENDING;
    status = STATUS_PERSISTED;
    NodeEntry entry;
    if (nodeState == null || removeExisting) {
        // invalidate the complete tree
        // -> start searching root-entry from any version-entry or
        //    from the given nodestate
        entry = (nodeState == null) ? versionStates[0].getNodeEntry() : nodeState.getNodeEntry();
        while (entry.getParent() != null) {
            entry = entry.getParent();
        }
    } else {
        entry = nodeState.getNodeEntry();
    }
    entry.invalidate(true);
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry)

Example 37 with NodeEntry

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

the class WorkspaceImport method persisted.

/**
     * Invalidates the <code>NodeState</code> that has been updated and all
     * its descendants.
     *
     * @see Operation#persisted()
     */
public void persisted() {
    assert status == STATUS_PENDING;
    status = STATUS_PERSISTED;
    NodeEntry entry;
    if (uuidBehaviour == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING || uuidBehaviour == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING) {
        // invalidate the complete tree
        entry = nodeState.getNodeEntry();
        while (entry.getParent() != null) {
            entry = entry.getParent();
        }
        entry.invalidate(true);
    } else {
        // import only added new items below the import target. therefore
        // recursive invalidation is not required. // TODO correct?
        nodeState.getNodeEntry().invalidate(false);
    }
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry)

Example 38 with NodeEntry

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

the class AddLabel method persisted.

/**
     * Invalidates the jcr:versionLabel nodestate present with the given
     * version history. If '<code>moveLabel</code>' is true, all descendant states
     * (property states) are invalidated as well.
     *
     * @see Operation#persisted()
     */
public void persisted() {
    assert status == STATUS_PENDING;
    status = STATUS_PERSISTED;
    try {
        NodeEntry vhEntry = (NodeEntry) versionHistoryState.getHierarchyEntry();
        NodeEntry lnEntry = vhEntry.getNodeEntry(NameConstants.JCR_VERSIONLABELS, Path.INDEX_DEFAULT);
        if (lnEntry != null) {
            lnEntry.invalidate(moveLabel);
        }
    } catch (RepositoryException e) {
        log.debug(e.getMessage());
    }
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) RepositoryException(javax.jcr.RepositoryException)

Example 39 with NodeEntry

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

the class Merge method persisted.

/**
     * Invalidates the target nodestate and all descendants.
     *
     * @see Operation#persisted()
     */
public void persisted() {
    assert status == STATUS_PENDING;
    status = STATUS_PERSISTED;
    if (isActivityMerge()) {
        // TODO be more specific about what needs to be invalidated
        // look for the root entry and invalidate the complete tree
        HierarchyEntry entry = nodeState.getNodeEntry();
        while (entry.getParent() != null) {
            entry = entry.getParent();
        }
        entry.invalidate(true);
    } else {
        try {
            NodeEntry vhe = mgr.getVersionHistoryEntry(nodeState);
            if (vhe != null) {
                vhe.invalidate(true);
            }
        } catch (RepositoryException e) {
            log.warn("Error while retrieving VersionHistory entry: {}", e.getMessage());
        }
        nodeState.getHierarchyEntry().invalidate(true);
    }
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) RepositoryException(javax.jcr.RepositoryException) HierarchyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry)

Example 40 with NodeEntry

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

the class ItemStateValidator method checkCollision.

/**
     *
     * @param parentState
     * @param propertyName
     * @throws ItemExistsException
     * @throws RepositoryException
     */
private void checkCollision(NodeState parentState, Name propertyName) throws ItemExistsException, RepositoryException {
    NodeEntry parentEntry = (NodeEntry) parentState.getHierarchyEntry();
    // NOTE: check for name collisions with existing child node has been
    // removed as with JSR 283 having same-named node and property can be
    // allowed. thus delegate the corresponding validation to the underlying
    // SPI implementation.
    // check for name collisions with an existing property
    PropertyEntry pe = parentEntry.getPropertyEntry(propertyName);
    if (pe != null) {
        try {
            pe.getPropertyState();
            throw new ItemExistsException("Property '" + pe.getName() + "' already exists.");
        } catch (ItemNotFoundException e) {
        // apparently conflicting entry does not exist any more
        // ignore and return
        }
    }
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry) ItemExistsException(javax.jcr.ItemExistsException) 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