long start = System.currentTimeMillis();
    public String getDocument(User user, String name, Hashtable parametri)    throws Exception {        long start = System.currentTimeMillis();        DBBroker broker = null;                Collection collection = null;        DocumentImpl doc = null;        try {            broker = brokerPool.get(user);            //TODO : use dedicated function in XmldbURI            int pos = name.lastIndexOf("/");            String collName = name.substring(0, pos);            String docName = name.substring(pos + 1);                        collection = broker.openCollection(collName, Lock.READ_LOCK);            if (collection == null) {                LOG.debug("collection " + collName + " not found!");                return null;            }            if(!collection.getPermissions().validate(user, Permission.READ)) {                collection.release();                throw new PermissionDeniedException("Insufficient privileges to read resource");            }            doc = collection.getDocumentWithLock(broker, docName);            collection.release();            if (doc == null) {                LOG.debug("document " + name + " not found!");                throw new EXistException("document not found");            }                        if(!doc.getPermissions().validate(user, Permission.READ))                throw new PermissionDeniedException("Insufficient privileges to read resource " + docName);            Serializer serializer = broker.getSerializer();            serializer.setProperties(parametri);            String xml = serializer.serialize(doc);                        return xml;        } catch (NoSuchMethodError nsme) {            nsme.printStackTrace();            return null;        } finally {            if(collection != null)                collection.releaseDocument(doc);            brokerPool.release(broker);        }    }