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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
Aggregations