// if this is a newly created node then we expect the underlying node to be null.
// also, if the node has been deleted in the WS and the underlying node is null, this *may* be ok ... will test again later when comparing versions
// if not, we have a problem...
if (underlyingNode == null && !workspaceNode.isCreated() && !workspaceNode.isRemoved())
{
throw new DataVersioningException("Underlying node for " + fqn + " is null, and this node wasn't newly created in this transaction! We have a concurrent deletion event.");
}
// needs to have been created AND modified - we allow concurrent creation if no data is put into the node
if (underlyingNode != null && underlyingNode.isValid() && workspaceNode.isCreated() && workspaceNode.isModified())
{
throw new DataVersioningException("Transaction attempted to create " + fqn + " anew. It has already been created since this transaction started, by another (possibly remote) transaction. We have a concurrent creation event.");
}
if (underlyingNode != null && !underlyingNode.isValid())
{
// we havea tombstone
if (!workspaceNode.isCreated() && !workspaceNode.isRemoved())
throw new DataVersioningException("Underlying node doesn't exist but a tombstone does; workspace node should be marked as created!");
if (underlyingNode.getVersion().newerThan(workspaceNode.getVersion()))
{
// we have an out of date node here
throw new DataVersioningException("Version mismatch for node " + fqn + ": underlying node with version " + workspaceNode.getNode().getVersion() + " is newer than workspace node, with version " + workspaceNode.getVersion());
}
}
if (!workspaceNode.isCreated() && (workspaceNode.isRemoved() || workspaceNode.isModified()))
{
// if the real node is null, throw a DVE
if (underlyingNode == null)
{
// but not if the WSN has also been deleted
if (!workspaceNode.isRemoved())
throw new DataVersioningException("Unable to compare versions since the underlying node has been deleted by a concurrent transaction!");
else if (trace)
log.trace("The data node [" + fqn + "] is null, but this is ok since the workspace node is marked as deleted as well");
}
// if there is a DataVersion type mismatch here, leave it up to the DataVersion impl to barf if necessary. - JBCACHE-962
else if (underlyingNode.getVersion().newerThan(workspaceNode.getVersion()))
{
// we have an out of date node here
throw new DataVersioningException("Version mismatch for node " + fqn + ": underlying node with version " + workspaceNode.getNode().getVersion() + " is newer than workspace node, with version " + workspaceNode.getVersion());
}
}
}
else
{