try { broker = pool.get(session.getUser()); DocumentImpl doc = (DocumentImpl)broker.getDocument(documentName);  if (doc == null) {
try { broker = pool.get(session.getUser());   DocumentImpl doc = (DocumentImpl)broker.getXMLResource(documentName); if (doc == null) {
    public int xupdateResource(java.lang.String sessionId, java.lang.String documentName, java.lang.String xupdate) throws java.rmi.RemoteException {		DBBroker broker = null;		Session session = getSession(sessionId);        TransactionManager transact = pool.getTransactionManager();        Txn transaction = transact.beginTransaction();		try {			broker = pool.get(session.getUser());			DocumentImpl doc = (DocumentImpl)broker.getDocument(documentName);//??			DocumentImpl doc = (DocumentImpl)broker.getXMLResource(documentName);			if (doc == null) {                transact.abort(transaction);				throw new RemoteException(					"document " + documentName + " not found");            }			if(!doc.getPermissions().validate(broker.getUser(), Permission.READ)) {                transact.abort(transaction);				throw new RemoteException("Not allowed to read resource");            }			DocumentSet docs = new DocumentSet();			docs.add(doc);			XUpdateProcessor processor =				new XUpdateProcessor(broker, docs);			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 (ParserConfigurationException e) {            transact.abort(transaction);			throw new RemoteException(e.getMessage(), e);		} catch (IOException e) {            transact.abort(transaction);			throw new RemoteException(e.getMessage(), e);		} catch (EXistException e) {            transact.abort(transaction);			throw new RemoteException(e.getMessage(), e);		} catch (SAXException e) {            transact.abort(transaction);			throw new RemoteException(e.getMessage(), e);		} catch (PermissionDeniedException e) {            transact.abort(transaction);			throw new RemoteException(e.getMessage(), e);		} catch (XPathException e) {            transact.abort(transaction);			throw new RemoteException(e.getMessage(), e);		} catch (LockException e) {            transact.abort(transaction);		    throw new RemoteException(e.getMessage(), e);        } finally {			pool.release(broker);		}    }