LOG.debug("removing old document " + oldDoc.getFileURI());
oldDoc.getUpdateLock().acquire(Lock.WRITE_LOCK);
oldDocLocked = true;
if (oldDoc.getResourceType() == DocumentImpl.BINARY_FILE) {
broker.removeBinaryResource(transaction, (BinaryDocument) oldDoc);
<BUG>documents.remove(oldDoc.getFileURI().getRawCollectionPath());
document.getUpdateLock().acquire(Lock.WRITE_LOCK);</BUG>
document.setDocId(broker.getNextResourceId(transaction, this));
addDocument(transaction, broker, document);
} else {

LOG.debug("removing old document " + oldDoc.getFileURI());
oldDoc.getUpdateLock().acquire(Lock.WRITE_LOCK);
oldDocLocked = true;
if (oldDoc.getResourceType() == DocumentImpl.BINARY_FILE) {
broker.removeBinaryResource(transaction, (BinaryDocument) oldDoc);
documents.remove(oldDoc.getFileURI().getRawCollectionPath());
if (transaction != null)
transaction.acquireLock(document.getUpdateLock(), Lock.WRITE_LOCK);
else
document.getUpdateLock().acquire(Lock.WRITE_LOCK);
document.setDocId(broker.getNextResourceId(transaction, this));
addDocument(transaction, broker, document);
} else {
