Search in sources :

Example 21 with NodeState

use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.

the class AccessControlManagerImpl method getPolicies.

public AccessControlPolicy[] getPolicies(String absPath) throws RepositoryException {
    checkValidNodePath(absPath);
    List<AccessControlList> policies = new ArrayList<AccessControlList>();
    NodeState aclNode = getAclNode(absPath);
    AccessControlList acl;
    if (aclNode != null) {
        acl = new AccessControlListImpl(aclNode, absPath, npResolver, qvf, this);
        policies.add(acl);
    }
    return policies.toArray(new AccessControlList[policies.size()]);
}
Also used : AccessControlList(javax.jcr.security.AccessControlList) NodeState(org.apache.jackrabbit.jcr2spi.state.NodeState) ArrayList(java.util.ArrayList)

Example 22 with NodeState

use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.

the class ReorderNodes method create.

//------------------------------------------------------------< Factory >---
public static Operation create(NodeState parentState, Path srcPath, Path beforePath) throws ItemNotFoundException, RepositoryException {
    // make sure the parent hierarchy entry has its child entries loaded
    assertChildNodeEntries(parentState);
    NodeState insert = parentState.getChildNodeState(srcPath.getName(), srcPath.getNormalizedIndex());
    NodeState before = null;
    if (beforePath != null) {
        before = parentState.getChildNodeState(beforePath.getName(), beforePath.getNormalizedIndex());
    }
    return new ReorderNodes(parentState, insert, before);
}
Also used : NodeState(org.apache.jackrabbit.jcr2spi.state.NodeState)

Example 23 with NodeState

use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.

the class NodeEntryImpl method notifyUUIDorMIXINModified.

/**
     * Deals with modified jcr:uuid and jcr:mixinTypes property.
     * See {@link #notifyUUIDorMIXINRemoved(Name)}
     *
     * @param child
     */
private void notifyUUIDorMIXINModified(PropertyEntry child) {
    try {
        if (NameConstants.JCR_UUID.equals(child.getName())) {
            PropertyState ps = child.getPropertyState();
            setUniqueID(ps.getValue().getString());
        } else if (NameConstants.JCR_MIXINTYPES.equals(child.getName())) {
            NodeState state = (NodeState) internalGetItemState();
            if (state != null) {
                PropertyState ps = child.getPropertyState();
                state.setMixinTypeNames(StateUtility.getMixinNames(ps));
            }
        // nodestate not yet loaded -> ignore change
        }
    } catch (ItemNotFoundException e) {
        log.debug("Property with name " + child.getName() + " does not exist (anymore)");
    } catch (RepositoryException e) {
        log.debug("Unable to access child property " + child.getName(), e.getMessage());
    }
}
Also used : NodeState(org.apache.jackrabbit.jcr2spi.state.NodeState) RepositoryException(javax.jcr.RepositoryException) PropertyState(org.apache.jackrabbit.jcr2spi.state.PropertyState) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Example 24 with NodeState

use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.

the class LockManagerImpl method getLockImpl.

/**
     * Returns the Lock that applies to the given node state (directly or
     * by an inherited deep lock) or <code>null</code> if the state is not
     * locked at all.
     *
     * @param nodeState
     * @param lazyLockDiscovery If true, no extra check with the server is made in order to
     * determine, whether there is really no lock present. Otherwise, the server
     * is asked if a lock is present.
     * @return LockImpl that applies to the given state or <code>null</code>.
     * @throws RepositoryException
     */
private LockImpl getLockImpl(NodeState nodeState, boolean lazyLockDiscovery) throws RepositoryException {
    NodeState nState = nodeState;
    // access first non-NEW state
    while (nState.getStatus() == Status.NEW) {
        nState = nState.getParent();
    }
    // shortcut: check if a given state holds a lock, which has been
    // store in the lock map. see below (LockImpl) for the conditions that
    // must be met in order a lock can be stored.
    LockImpl l = getLockFromMap(nState);
    if (l != null && l.lockState.appliesToNodeState(nodeState)) {
        return l;
    }
    LockState lState;
    if (lazyLockDiscovery) {
        // try to retrieve a state (ev. a parent state) that holds a lock.
        NodeState lockHoldingState = getLockHoldingState(nState);
        if (lockHoldingState == null) {
            // assume no lock is present (might not be correct due to incomplete hierarchy)
            return null;
        } else {
            // check lockMap again with the lock-holding state
            l = getLockFromMap(nState);
            if (l != null) {
                return l;
            }
            lState = buildLockState(lockHoldingState);
        }
    } else {
        // need precise information about lock status -> retrieve lockInfo
        // from the persistent layer.
        lState = buildLockState(nState);
    }
    if (lState != null) {
        // Test again if a Lock object is stored in the lockmap. Otherwise
        // build the lock object and retrieve lock holding node. note that this
        // may fail if the session does not have permission to see this node.
        LockImpl lock = getLockFromMap(lState.lockHoldingState);
        if (lock != null) {
            lock.lockState.setLockInfo(lState.lockInfo);
        } else {
            Item lockHoldingNode = itemManager.getItem(lState.lockHoldingState.getHierarchyEntry());
            lock = new LockImpl(lState, (Node) lockHoldingNode);
        }
        // test if lock applies to the original nodestate
        if (lState.appliesToNodeState(nodeState)) {
            return lock;
        } else {
            // lock exists but doesn't apply to the given state
            return null;
        }
    } else {
        // no lock at all
        return null;
    }
}
Also used : Item(javax.jcr.Item) NodeState(org.apache.jackrabbit.jcr2spi.state.NodeState) Node(javax.jcr.Node)

Example 25 with NodeState

use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.

the class WorkspaceImpl method getImportContentHandler.

/**
     * @see javax.jcr.Workspace#getImportContentHandler(String, int)
     */
public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, RepositoryException {
    session.checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
    session.checkIsAlive();
    Path parentPath = session.getQPath(parentAbsPath);
    NodeState parentState = getHierarchyManager().getNodeState(parentPath);
    // make sure the given import target is accessible, not locked and checked out.
    int options = ItemStateValidator.CHECK_ACCESS | ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
    getValidator().checkIsWritable(parentState, options);
    // build the content handler
    return new WorkspaceContentHandler(this, parentAbsPath, uuidBehavior);
}
Also used : Path(org.apache.jackrabbit.spi.Path) NodeState(org.apache.jackrabbit.jcr2spi.state.NodeState) WorkspaceContentHandler(org.apache.jackrabbit.jcr2spi.xml.WorkspaceContentHandler)

Aggregations

NodeState (org.apache.jackrabbit.jcr2spi.state.NodeState)31 Name (org.apache.jackrabbit.spi.Name)8 ItemNotFoundException (javax.jcr.ItemNotFoundException)5 RepositoryException (javax.jcr.RepositoryException)5 PropertyState (org.apache.jackrabbit.jcr2spi.state.PropertyState)5 Path (org.apache.jackrabbit.spi.Path)5 NodeEntry (org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry)4 ItemExistsException (javax.jcr.ItemExistsException)3 Operation (org.apache.jackrabbit.jcr2spi.operation.Operation)3 NodeId (org.apache.jackrabbit.spi.NodeId)3 Item (javax.jcr.Item)2 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)2 AccessControlException (javax.jcr.security.AccessControlException)2 Privilege (javax.jcr.security.Privilege)2 Version (javax.jcr.version.Version)2 VersionException (javax.jcr.version.VersionException)2 AddNode (org.apache.jackrabbit.jcr2spi.operation.AddNode)2 QNodeDefinition (org.apache.jackrabbit.spi.QNodeDefinition)2 QValue (org.apache.jackrabbit.spi.QValue)2 ArrayList (java.util.ArrayList)1