use of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry in project jackrabbit by apache.
the class JcrVersionManager method createActivity.
/**
* @see javax.jcr.version.VersionManager#createActivity(String)
*/
public Node createActivity(String title) throws UnsupportedRepositoryOperationException, RepositoryException {
session.checkIsAlive();
NodeEntry entry = vMgr.createActivity(title);
return (Node) itemManager.getItem(entry);
}
use of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry in project jackrabbit by apache.
the class ItemManagerImpl method hasChildNodes.
/**
* @see ItemManager#hasChildNodes(NodeEntry)
*/
public synchronized boolean hasChildNodes(NodeEntry parentEntry) throws ItemNotFoundException, RepositoryException {
// check sanity of session
session.checkIsAlive();
Iterator<NodeEntry> iter = parentEntry.getNodeEntries();
while (iter.hasNext()) {
try {
// check read access by accessing the nodeState (implicit validation check)
NodeEntry entry = iter.next();
entry.getNodeState();
return true;
} catch (ItemNotFoundException e) {
// should not occur. ignore
log.debug("Failed to access node state.", e);
}
}
return false;
}
use of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry in project jackrabbit by apache.
the class LockManagerImpl method buildLockState.
private LockState buildLockState(NodeState nodeState) throws RepositoryException {
NodeId nId = nodeState.getNodeId();
NodeState lockHoldingState;
LockInfo lockInfo = wspManager.getLockInfo(nId);
if (lockInfo == null) {
// no lock present
return null;
}
NodeId lockNodeId = lockInfo.getNodeId();
if (lockNodeId.equals(nId)) {
lockHoldingState = nodeState;
} else {
NodeEntry lockedEntry = wspManager.getHierarchyManager().getNodeEntry(lockNodeId);
try {
lockHoldingState = lockedEntry.getNodeState();
} catch (RepositoryException e) {
log.warn("Cannot build LockState");
throw new RepositoryException("Cannot build LockState", e);
}
}
if (lockHoldingState == null) {
return null;
} else {
return new LockState(lockHoldingState, lockInfo);
}
}
use of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry in project jackrabbit by apache.
the class LockManagerImpl method getLockHoldingState.
//------------------------------------------------------------< private >---
/**
* Search nearest ancestor that is locked. Returns <code>null</code> if neither
* the given state nor any of its ancestors is locked.
* Note, that this methods does NOT check if the given node state would
* be affected by the lock present on an ancestor state.
* Note, that in certain cases it might not be possible to detect a lock
* being present due to the fact that the hierarchy might be incomplete or
* not even readable completely. For this reason it seem equally reasonable
* to search for jcr:lockIsDeep property only and omitting all kind of
* verification regarding nodetypes present.
*
* @param nodeState <code>NodeState</code> from which searching starts.
* Note, that the given state must not have an overlaid state.
* @return a state holding a lock or <code>null</code> if neither the
* given state nor any of its ancestors is locked.
*/
private NodeState getLockHoldingState(NodeState nodeState) {
NodeEntry entry = nodeState.getNodeEntry();
while (!entry.hasPropertyEntry(NameConstants.JCR_LOCKISDEEP)) {
NodeEntry parent = entry.getParent();
if (parent == null) {
// reached root state without finding a locked node
return null;
}
entry = parent;
}
try {
return entry.getNodeState();
} catch (RepositoryException e) {
// may occur if the nodeState is not accessible or some generic
// error occurred.
// for this case, assume that no lock exists and delegate final
// validation to the spi-implementation.
log.warn("Error while accessing lock holding NodeState: {}", e.getMessage());
return null;
}
}
use of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry in project jackrabbit by apache.
the class Checkin method persisted.
/**
* Invalidate the target <code>NodeState</code>.
*
* @see Operation#persisted()
*/
public void persisted() {
assert status == STATUS_PENDING;
status = STATUS_PERSISTED;
try {
NodeEntry vhe = mgr.getVersionHistoryEntry(nodeState);
if (vhe != null) {
vhe.invalidate(true);
}
} catch (RepositoryException e) {
log.debug("Failed to access Version history entry -> skip invalidation.", e);
}
Iterator<PropertyEntry> entries = ((NodeEntry) nodeState.getHierarchyEntry()).getPropertyEntries();
while (entries.hasNext()) {
PropertyEntry pe = entries.next();
pe.invalidate(false);
}
nodeState.getHierarchyEntry().invalidate(false);
}
Aggregations