try {
broker = factory.getBrokerPool().get(user);
final Collection collection = broker.getCollection(collUri);
if (collection == null) {
transact.abort(transaction);
throw new EXistException("collection " + collUri + " not found");
}
//TODO : register a lock (which one ?) in the transaction ?
final DocumentSet docs = collection.allDocs(broker, new DefaultDocumentSet(), true);
final XUpdateProcessor processor = new XUpdateProcessor(broker, docs, AccessContext.XMLRPC);
final Modification modifications[] = processor.parse(new InputSource(new StringReader(xupdate)));
long mods = 0;
for (int i = 0; i < modifications.length; i++) {
mods += modifications[i].process(transaction);
broker.flush();
}
transact.commit(transaction);
return (int) mods;
} catch (final ParserConfigurationException e) {
transact.abort(transaction);
throw new EXistException(e.getMessage());
} catch (final IOException e) {
transact.abort(transaction);
throw new EXistException(e.getMessage());
} finally {
transact.close(transaction);
factory.getBrokerPool().release(broker);
}
}