if (!itemState.isPersisted())
continue;
long start = System.currentTimeMillis();
TransientItemData data = (TransientItemData) itemState.getData();
WorkspaceStorageConnection conn = null;
if (isSystemDescendant(data.getQPath()))
{
conn = systemConnection == null
// we need system connection but it's not exist
? systemConnection = (systemDataContainer != dataContainer
// if it's different container instances
? systemDataContainer.equals(dataContainer) && thisConnection != null
// but container confugrations are same and non-system connnection open
// reuse this connection as system
? systemDataContainer.reuseConnection(thisConnection)
// or open one new system
: systemDataContainer.openConnection()
// else if it's same container instances (system and this)
: thisConnection == null
// and non-system connection doens't exist - open it
? thisConnection = dataContainer.openConnection()
// if already open - use it
: thisConnection)
// system connection opened - use it
: systemConnection;
}
else
{
conn = thisConnection == null
// we need this conatiner conection
? thisConnection = (systemDataContainer != dataContainer
// if it's different container instances
? dataContainer.equals(systemDataContainer) && systemConnection != null
// but container confugrations are same and system connnection open
// reuse system connection as this
? dataContainer.reuseConnection(systemConnection)
// or open one new
: dataContainer.openConnection()
// else if it's same container instances (system and this)
: systemConnection == null
// and system connection doens't exist - open it
? systemConnection = dataContainer.openConnection()
// if already open - use it
: systemConnection)
// this connection opened - use it
: thisConnection;
}
data.increasePersistedVersion();
if (itemState.isAdded())
{
doAdd(data, conn, addedNodes);
}
else if (itemState.isUpdated())
{
doUpdate(data, conn);
}
else if (itemState.isDeleted())
{
doDelete(data, conn);
}
else if (itemState.isRenamed())
{
doRename(data, conn, addedNodes);
}
if (LOG.isDebugEnabled())
LOG.debug(ItemState.nameFromValue(itemState.getState()) + " " + (System.currentTimeMillis() - start)
+ "ms, " + data.getQPath().getAsString());
}
if (thisConnection != null)
thisConnection.commit();
if (systemConnection != null && !systemConnection.equals(thisConnection))
systemConnection.commit();