if (!collectionName.startsWith("/db")) collectionName = "/db" + collectionName;
collectionName = NativeBroker.checkPath(collectionName, "/db");
    public String createResourceId(User user, String collectionName)    throws EXistException, PermissionDeniedException {        DBBroker broker = null;        Collection collection = null;        try {            broker = brokerPool.get(user);            if (!collectionName.startsWith("/"))                collectionName = '/' + collectionName;            if (!collectionName.startsWith("/db"))                collectionName = "/db" + collectionName;            collection = broker.openCollection(collectionName, Lock.READ_LOCK);            String id;            Random rand = new Random();            boolean ok;            do {                ok = true;                id = Integer.toHexString(rand.nextInt()) + ".xml";                // check if this id does already exist                if (collection.hasDocument(id))                    ok = false;                                if (collection.hasSubcollection(id))                    ok = false;                            } while (!ok);            return id;        } finally {            if(collection != null)                collection.release();            brokerPool.release(broker);        }    }