n.setDataLoaded(true);
}
private void loadIfNeeded(InvocationContext ctx, Fqn fqn, Object key, boolean allKeys, boolean initNode, boolean acquireWriteLock, boolean recursive, boolean isMove, boolean bypassLoadingData, boolean shouldLoadIfNodeIsNull) throws Throwable
{
NodeSPI n = helper.wrapNodeForReading(ctx, fqn, true);
if (n instanceof NullMarkerNode)
{
ctx.getLookedUpNodes().remove(fqn);
n = null;
}
boolean mustLoad = mustLoad(fqn, n, key, allKeys || isMove, shouldLoadIfNodeIsNull);
if (trace) log.trace("load element " + fqn + " mustLoad=" + mustLoad);
if (mustLoad)
{
if (acquireWriteLock || initNode)
{
boolean isNew = n == null;
n = helper.wrapNodeForWriting(ctx, fqn, true, false, true, false, true); // won't create any nodes but will acquire locks.
if (isNew && n != null) n.setDataLoaded(false);
}
// This is really convoluted
if (n == null || !n.isDeleted())
{
boolean exists;
Map nodeData = null;
if (bypassLoadingData)
{
exists = loader.exists(fqn);
}
else
{
nodeData = loadData(ctx, fqn);
exists = nodeData != null;
}
if (n == null && exists)
{
// just create a dummy node in memory
n = helper.wrapNodeForWriting(ctx, fqn, true, true, true, false, false);
n.setDataLoaded(false);
}
if (nodeData != null && n != null)
{
setNodeState(ctx, fqn, n, nodeData);
}
}
}
// The complete list of children aren't known without loading them
if (recursive && n != null)
{
loadChildren(fqn, n.getDelegationTarget(), recursive, isMove, ctx);
}
}