// current workspace node canot be null.
// try and get the child of current node
if (log.isTraceEnabled()) log.trace(" Entering synchronized nodewrapper access for gtx " + gtx);
TreeNode tempChildNode = workspaceNode.getChild(childName);
// if (log.isDebugEnabled()) log.debug(" Entered synchronized workspaceNode " + workspaceNode + " access for gtx " + gtx);
// no child exists with this name
if (tempChildNode == null)
{
if (log.isTraceEnabled()) log.trace("Child node "+childName+" doesn't exist. Creating new node.");
// we put the parent node into the workspace as we are changing it's children
WorkspaceNode tempCheckWrapper = workspace.getNode(workspaceNode.getFqn());
if (tempCheckWrapper == null || tempCheckWrapper.isDeleted())
{
//add a new one or overwrite an existing one that has been deleted
if (log.isTraceEnabled()) log.trace("Parent node "+workspaceNode.getFqn()+" doesn't exist in workspace or has been deleted. Adding to workspace in gtx " + gtx);
workspace.addNode(workspaceNode);
}
else
{
if (log.isTraceEnabled()) log.trace(" Parent node " + workspaceNode.getFqn() + " exists in workspace " + gtx);
}
copy = (Fqn) tmpFqn.clone();
// this does not add it into the real child nodes - but in its
// local child map for the transaction
// get the version passed in, if we need to use explicit versioning.
DataVersion versionToPassIn = null;
if (isTargetFqn && !workspace.isVersioningImplicit()) versionToPassIn = version;
DataNode tempNode = (DataNode) workspaceNode.createChild(childName, copy, workspaceNode.getNode(), cache, versionToPassIn);
childWorkspaceNode = NodeFactory.getInstance().createWorkspaceNode(tempNode, workspace);
childWorkspaceNode.setVersioningImplicit(versionToPassIn == null || !isTargetFqn);
if (log.isTraceEnabled()) log.trace("setting versioning of " + childWorkspaceNode.getFqn() + " to be " + (childWorkspaceNode.isVersioningImplicit() ? "implicit" : "explicit"));
// now add the wrapped child node into the transaction space
workspace.addNode(childWorkspaceNode);
childWorkspaceNode.markAsCreated();
// save in list so we can broadcast our created nodes outside
// the synch block
nodesCreated.add(tmpFqn);
}
else
{
// node does exist but might not be in the workspace
childWorkspaceNode = workspace.getNode(tempChildNode.getFqn());
// wrap it up so we can put it in later if we need to
if (childWorkspaceNode == null || childWorkspaceNode.isDeleted())
{
if (log.isDebugEnabled()) log.debug("Child node "+tempChildNode.getFqn()+" doesn't exist in workspace or has been deleted. Adding to workspace in gtx " + gtx);
childWorkspaceNode = NodeFactory.getInstance().createWorkspaceNode(tempChildNode, workspace);
if (isTargetFqn && !workspace.isVersioningImplicit())
{
childWorkspaceNode.setVersion(version);
childWorkspaceNode.setVersioningImplicit(false);
}
else
{
childWorkspaceNode.setVersioningImplicit(true);
}
if (log.isTraceEnabled()) log.trace("setting versioning of " + childWorkspaceNode.getFqn() + " to be " + (childWorkspaceNode.isVersioningImplicit() ? "implicit" : "explicit"));
}
else
{
if (log.isDebugEnabled()) log.debug(" Already found " + tempChildNode.getFqn() + " node in workspace " + gtx);
}
}
workspaceNode = childWorkspaceNode;
}