Search in sources :

Example 71 with NodeImpl

use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.

the class SessionLockManager method unlock.

/**
 * @see javax.jcr.lock.LockManager#unlock(String)
 */
public void unlock(String absPath) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
    NodeImpl node = (NodeImpl) session.getNode(absPath);
    int options = ItemValidator.CHECK_HOLD | ItemValidator.CHECK_PENDING_CHANGES_ON_NODE;
    context.getItemValidator().checkModify(node, options, Permission.LOCK_MNGMT);
    checkLockable(node);
    synchronized (systemLockMgr) {
        // basic checks if unlock can be called on the node.
        if (!systemLockMgr.holdsLock(node)) {
            throw new LockException("Node not locked: " + node);
        }
        systemLockMgr.checkUnlock(session, node);
        systemLockMgr.unlock(node);
    }
}
Also used : NodeImpl(org.apache.jackrabbit.core.NodeImpl) LockException(javax.jcr.lock.LockException)

Example 72 with NodeImpl

use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.

the class VirtualNodeTypeStateManager method nodeTypesUnregistered.

/**
 * {@inheritDoc}
 */
public void nodeTypesUnregistered(Collection<Name> names) {
    try {
        if (systemSession != null) {
            // generated observation events
            List<EventState> events = new ArrayList<EventState>();
            NodeImpl root = (NodeImpl) systemSession.getItemManager().getItem(rootNodeId);
            for (Name name : names) {
                NodeImpl child = root.getNode(name);
                recursiveRemove(events, root, child);
            }
            obsDispatcher.dispatch(events, systemSession, NODE_TYPES_PATH, null);
        }
        if (virtProvider != null) {
            // allow provider to update
            virtProvider.onNodeTypesRemoved(names);
        }
    } catch (RepositoryException e) {
        log.error("Unable to index removed nodetypes: " + names, e);
    }
}
Also used : EventState(org.apache.jackrabbit.core.observation.EventState) NodeImpl(org.apache.jackrabbit.core.NodeImpl) ArrayList(java.util.ArrayList) RepositoryException(javax.jcr.RepositoryException) Name(org.apache.jackrabbit.spi.Name)

Example 73 with NodeImpl

use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.

the class VirtualNodeTypeStateManager method recursiveRemove.

/**
 * Adds a subtree of itemstates as 'removed' to a list of events
 *
 * @param events
 * @param parent
 * @param node
 * @throws RepositoryException
 */
private void recursiveRemove(List<EventState> events, NodeImpl parent, NodeImpl node) throws RepositoryException {
    events.add(EventState.childNodeRemoved(parent.getNodeId(), parent.getPrimaryPath(), node.getNodeId(), node.getPrimaryPath().getLastElement(), ((NodeTypeImpl) parent.getPrimaryNodeType()).getQName(), parent.getMixinTypeNames(), node.getSession()));
    NodeIterator niter = node.getNodes();
    while (niter.hasNext()) {
        NodeImpl n = (NodeImpl) niter.nextNode();
        recursiveRemove(events, node, n);
    }
}
Also used : NodeIterator(javax.jcr.NodeIterator) NodeTypeImpl(org.apache.jackrabbit.core.nodetype.NodeTypeImpl) NodeImpl(org.apache.jackrabbit.core.NodeImpl)

Example 74 with NodeImpl

use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.

the class VirtualNodeTypeStateManager method recursiveAdd.

/**
 * Adds a subtree of itemstates as 'added' to a list of events
 *
 * @param events
 * @param parent
 * @param node
 * @throws RepositoryException
 */
private void recursiveAdd(List<EventState> events, NodeImpl parent, NodeImpl node) throws RepositoryException {
    events.add(EventState.childNodeAdded(parent.getNodeId(), parent.getPrimaryPath(), node.getNodeId(), node.getPrimaryPath().getLastElement(), ((NodeTypeImpl) parent.getPrimaryNodeType()).getQName(), parent.getMixinTypeNames(), node.getSession()));
    PropertyIterator iter = node.getProperties();
    while (iter.hasNext()) {
        PropertyImpl prop = (PropertyImpl) iter.nextProperty();
        events.add(EventState.propertyAdded((NodeId) node.getId(), node.getPrimaryPath(), prop.getPrimaryPath().getLastElement(), ((NodeTypeImpl) node.getPrimaryNodeType()).getQName(), node.getMixinTypeNames(), node.getSession()));
    }
    NodeIterator niter = node.getNodes();
    while (niter.hasNext()) {
        NodeImpl n = (NodeImpl) niter.nextNode();
        recursiveAdd(events, node, n);
    }
}
Also used : NodeIterator(javax.jcr.NodeIterator) NodeTypeImpl(org.apache.jackrabbit.core.nodetype.NodeTypeImpl) NodeImpl(org.apache.jackrabbit.core.NodeImpl) PropertyIterator(javax.jcr.PropertyIterator) NodeId(org.apache.jackrabbit.core.id.NodeId) PropertyImpl(org.apache.jackrabbit.core.PropertyImpl)

Example 75 with NodeImpl

use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.

the class XAEnvironment method getLockInfo.

/**
 * Return the most appropriate lock information for a node. This is either
 * the lock info for the node itself, if it is locked, or a lock info for
 * one of its parents, if that one is deep locked.
 * @param node node
 * @return LockInfo lock info or <code>null</code> if node is not locked
 * @throws RepositoryException if an error occurs
 */
public LockInfo getLockInfo(NodeImpl node) throws RepositoryException {
    NodeId id = node.getNodeId();
    // check negative set
    if (unlockedNodesMap.containsKey(id)) {
        return null;
    }
    // check positive set, iteratively ascending in hierarchy
    if (!lockedNodesMap.isEmpty()) {
        NodeImpl current = node;
        for (; ; ) {
            XALockInfo info = lockedNodesMap.get(current.getId());
            if (info != null) {
                if (info.getId().equals(id) || info.isDeep()) {
                    return info;
                }
                break;
            }
            if (current.getDepth() == 0) {
                break;
            }
            current = (NodeImpl) current.getParent();
        }
    }
    // ask parent
    return lockMgr.getLockInfo(id);
}
Also used : NodeImpl(org.apache.jackrabbit.core.NodeImpl) NodeId(org.apache.jackrabbit.core.id.NodeId)

Aggregations

NodeImpl (org.apache.jackrabbit.core.NodeImpl)161 RepositoryException (javax.jcr.RepositoryException)34 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)29 NodeId (org.apache.jackrabbit.core.id.NodeId)25 AccessControlPolicy (javax.jcr.security.AccessControlPolicy)18 ArrayList (java.util.ArrayList)17 Value (javax.jcr.Value)16 Name (org.apache.jackrabbit.spi.Name)16 AccessControlEntry (javax.jcr.security.AccessControlEntry)15 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)13 AccessControlManager (javax.jcr.security.AccessControlManager)13 ByteArrayInputStream (java.io.ByteArrayInputStream)12 InputStream (java.io.InputStream)12 NodeIterator (javax.jcr.NodeIterator)12 JackrabbitAccessControlManager (org.apache.jackrabbit.api.security.JackrabbitAccessControlManager)11 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)11 Principal (java.security.Principal)10 Node (javax.jcr.Node)10 ParsingContentHandler (org.apache.jackrabbit.commons.xml.ParsingContentHandler)10 JackrabbitAccessControlList (org.apache.jackrabbit.api.security.JackrabbitAccessControlList)9