use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.
the class UniqueIdResolver method resolve.
public NodeEntry resolve(NodeId nodeId, NodeEntry rootEntry) throws ItemNotFoundException, RepositoryException {
NodeEntry entry = lookup(nodeId.getUniqueID());
if (entry == null) {
NodeState state = isf.createDeepNodeState(nodeId, rootEntry);
entry = state.getNodeEntry();
}
return entry;
}
use of org.apache.jackrabbit.jcr2spi.state.NodeState 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.state.NodeState in project jackrabbit by apache.
the class NodeEntryImpl method addNewNodeEntry.
/**
* @see NodeEntry#addNewNodeEntry(Name, String, Name, QNodeDefinition)
*/
public NodeEntry addNewNodeEntry(Name nodeName, String uniqueID, Name primaryNodeType, QNodeDefinition definition) throws RepositoryException {
NodeEntry entry = internalAddNodeEntry(nodeName, uniqueID, Path.INDEX_UNDEFINED);
NodeState state = getItemStateFactory().createNewNodeState(entry, primaryNodeType, definition);
entry.setItemState(state);
return entry;
}
use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.
the class Move method create.
//------------------------------------------------------------< Factory >---
public static Operation create(Path srcPath, Path destPath, HierarchyManager hierMgr, PathResolver resolver, boolean sessionMove) throws ItemExistsException, NoSuchNodeTypeException, RepositoryException {
// src must not be ancestor of destination
if (srcPath.isAncestorOf(destPath)) {
String msg = "Invalid destination path: cannot be descendant of source path (" + LogUtil.safeGetJCRPath(destPath, resolver) + "," + LogUtil.safeGetJCRPath(srcPath, resolver) + ")";
log.debug(msg);
throw new RepositoryException(msg);
}
// destination must not contain an index
int index = destPath.getIndex();
if (index != Path.INDEX_UNDEFINED) {
// subscript in name element
String msg = "Invalid destination path: subscript in name element is not allowed (" + LogUtil.safeGetJCRPath(destPath, resolver) + ")";
log.debug(msg);
throw new RepositoryException(msg);
}
// root node cannot be moved:
if (srcPath.denotesRoot() || destPath.denotesRoot()) {
String msg = "Cannot move the root node.";
log.debug(msg);
throw new RepositoryException(msg);
}
NodeState srcState = getNodeState(srcPath, hierMgr);
NodeState srcParentState = getNodeState(srcPath.getAncestor(1), hierMgr);
NodeState destParentState = getNodeState(destPath.getAncestor(1), hierMgr);
Name destName = destPath.getName();
if (sessionMove) {
NodeEntry destEntry = (NodeEntry) destParentState.getHierarchyEntry();
// force child node entries list to be present before the move is executed
// on the hierarchy entry.
assertChildNodeEntries(srcParentState);
assertChildNodeEntries(destParentState);
if (destEntry.hasNodeEntry(destName)) {
NodeEntry existing = destEntry.getNodeEntry(destName, Path.INDEX_DEFAULT);
if (existing != null && sessionMove) {
try {
if (!existing.getNodeState().getDefinition().allowsSameNameSiblings()) {
throw new ItemExistsException("Node existing at move destination does not allow same name siblings.");
}
} catch (ItemNotFoundException e) {
// existing apparent not valid any more -> probably no conflict
}
}
}
}
Move move = new Move(srcState, srcParentState, destParentState, destName, sessionMove);
return move;
}
use of org.apache.jackrabbit.jcr2spi.state.NodeState in project jackrabbit by apache.
the class SessionImpl method getVersionState.
/**
* Returns the NodeState of the given Node and asserts that the state is
* listed in the hierarchy built by this Session. If the version
* was obtained from a different session, the 'corresponding' version
* state for this session is retrieved.
*
* @param version
* @return the NodeState associated with the specified version.
*/
NodeState getVersionState(Version version) throws RepositoryException {
NodeState nodeState;
if (version.getSession() == this) {
nodeState = (NodeState) ((NodeImpl) version).getItemState();
} else {
Path p = getQPath(version.getPath());
Path parentPath = p.getAncestor(1);
HierarchyEntry parentEntry = getHierarchyManager().lookup(parentPath);
if (parentEntry != null) {
// make sure the parent entry is up to date
parentEntry.invalidate(false);
}
nodeState = getHierarchyManager().getNodeState(p);
}
return nodeState;
}
Aggregations