} catch(final URISyntaxException e) {
throw new RemoteException("Invalid document URI",e);
}
}
public int xupdateResource(java.lang.String sessionId, XmldbURI documentName, java.lang.String xupdate) throws java.rmi.RemoteException {
DBBroker broker = null;
final Session session = getSession(sessionId);
final TransactionManager transact = pool.getTransactionManager();
final Txn transaction = transact.beginTransaction();
try {
broker = pool.get(session.getUser());
// TODO check XML/Binary resource
// DocumentImpl doc = (DocumentImpl)broker.getDocument(documentName);
final DocumentImpl doc = broker.getXMLResource(documentName, Permission.READ);
if (doc == null) {
transact.abort(transaction);
throw new RemoteException(
"document " + documentName + " not found");
}
final MutableDocumentSet docs = new DefaultDocumentSet();
docs.add(doc);
final XUpdateProcessor processor =
new XUpdateProcessor(broker, docs, AccessContext.SOAP);
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);
// Release lock, as reported http://markmail.org/message/pau6hoaeybg2bvch
doc.getUpdateLock().release(Permission.READ);