// try and get the root from the transaction
TransactionWorkspace workspace = transactionEntry.getTransactionWorkSpace();
synchronized( workspace )
{
DataVersion version = null;
if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().getDataVersion() != null)
{
version = ctx.getOptionOverrides().getDataVersion();
workspace.setVersioningImplicit( false );
}
if (log.isDebugEnabled()) log.debug(" Getting root fqn from workspace for gtx " + gtx);
workspaceNode = workspace.getNode(cache.getRoot().getFqn());
// we do not have the root so lets wrap it in case we need to add it
// to the transaction
if (workspaceNode == null)
{
workspaceNode = NodeFactory.getInstance().createWorkspaceNode(cache.getRoot(), workspace);
workspace.addNode(workspaceNode);
if (log.isDebugEnabled()) log.debug(" created root node " + workspaceNode + " in workspace " + gtx);
}
else
{
if (log.isDebugEnabled()) log.debug(" Already found root node " + workspaceNode + " in workspace " + gtx);
}
// we will always have one root node here, by this stage
Fqn tmpFqn = Fqn.ROOT;
Fqn copy;
for (int i = 0; i < treeNodeSize; i++)
{
boolean isTargetFqn = (i == (treeNodeSize - 1));
childName = fqn.get(i);
// build up intermediate node fqn from original Fqn
tmpFqn = new Fqn(tmpFqn, childName);
// 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);