Collection destination = null;
DocumentImpl doc = null;
try {
//TODO : use transaction.registerLock(collection.getLock(), Lock.WRITE_LOCK);
broker = factory.getBrokerPool().get(user);
collection = broker.openCollection(docUri.removeLastSegment(), move ? Lock.WRITE_LOCK : Lock.READ_LOCK);
if (collection == null) {
transact.abort(transaction);
throw new EXistException("Collection " + docUri.removeLastSegment() + " not found");
}
doc = collection.getDocumentWithLock(broker, docUri.lastSegment(), Lock.WRITE_LOCK);