final Txn transaction = transact.beginTransaction();
DBBroker broker = null;
Collection collection = null;
try {
broker = factory.getBrokerPool().get(user);
collection = broker.openCollection(docUri.removeLastSegment(), Lock.WRITE_LOCK);
if (collection == null) {
transact.abort(transaction);
throw new EXistException("Collection " + docUri.removeLastSegment() + " not found");
}
// keep the write lock in the transaction