broker.moveResource(transaction, doc, destination, newName);
broker.moveXMLResource(transaction, doc, destination, newName);
    private void moveOrCopyResource(String sessionId, String docPath, String destinationPath,            String newName, boolean move)        throws RemoteException    {        TransactionManager transact = pool.getTransactionManager();        Txn transaction = transact.beginTransaction();        DBBroker broker = null;		Session session = getSession(sessionId);        Collection collection = null;        Collection destination = null;        DocumentImpl doc = null;        try {            broker = pool.get(session.getUser());            // get source document            int p = docPath.lastIndexOf('/');            if (p < 0 || p == docPath.length() - 1) {                transact.abort(transaction);                throw new RemoteException("Illegal document path");            }            String collectionName = docPath.substring(0, p);            String docName = docPath.substring(p + 1);            collection = broker.openCollection(collectionName, move ? Lock.WRITE_LOCK : Lock.READ_LOCK);            if (collection == null) {                transact.abort(transaction);                throw new RemoteException("Collection " + collectionName                        + " not found");            }            doc = collection.getDocumentWithLock(broker, docName, Lock.WRITE_LOCK);            if(doc == null) {                transact.abort(transaction);                throw new RemoteException("Document " + docPath + " not found");            }                        // get destination collection            destination = broker.openCollection(destinationPath, Lock.WRITE_LOCK);            if(destination == null) {                transact.abort(transaction);                throw new RemoteException("Destination collection " + destinationPath + " not found");            }            if(move)                broker.moveResource(transaction, doc, destination, newName);            else                broker.copyResource(transaction, doc, destination, newName);            transact.commit(transaction);//            documentCache.clear();            return;        } catch (LockException e) {            transact.abort(transaction);            throw new RemoteException("Could not acquire lock on document " + docPath);        } catch (PermissionDeniedException e) {            transact.abort(transaction);            throw new RemoteException("Could not move/copy document " + docPath);        } catch (TransactionException e) {        	throw new RemoteException("Error commiting transaction " + e.getMessage());        } catch (EXistException e) {        	throw new RemoteException(e.getMessage());        } finally {            if(collection != null)                collection.release();            if(destination != null)                destination.release();            if(doc != null)                doc.getUpdateLock().release(Lock.WRITE_LOCK);            pool.release(broker);        }    }