saveNode(txn, node.getID(), node);
insertNode(txn, node.getID(), node);
    public void init(File dbHome, Application app) throws DatabaseException {        this.app = app;        nmgr = app.getNodeManager();        dbHomeDir = dbHome;        if (!dbHomeDir.exists() && !dbHomeDir.mkdirs()) {            throw new DatabaseException("Can't create database directory "+dbHomeDir);        }        if (!dbHomeDir.canWrite()) {            throw new DatabaseException("No write permission for database directory "+dbHomeDir);        }        File stylesheet = new File(dbHomeDir, "helma.xsl");        // if style sheet doesn't exist, copy it        if (!stylesheet.exists()) {            copyStylesheet(stylesheet);        }        this.encoding = app.getCharset();        // get the initial id generator value        long idBaseValue;        try {            idBaseValue = Long.parseLong(app.getProperty("idBaseValue", "1"));            // 0 and 1 are reserved for root nodes            idBaseValue = Math.max(1L, idBaseValue);        } catch (NumberFormatException ignore) {            idBaseValue = 1L;        }        ITransaction txn = null;        try {            txn = beginTransaction();            try {                idgen = getIDGenerator(txn);                if (idgen.getValue() < idBaseValue) {                    idgen.setValue(idBaseValue);                }            } catch (ObjectNotFoundException notfound) {                // will start with idBaseValue+1                idgen = new XmlIDGenerator(idBaseValue);            }            // check if we need to set the id generator to a base value            Node node = null;            try {                node = (Node) getNode(txn, "0");            } catch (ObjectNotFoundException notfound) {                node = new Node("root", "0", "Root", nmgr.safe);                node.setDbMapping(app.getDbMapping("root"));                saveNode(txn, node.getID(), node);                // register node with nodemanager cache                nmgr.registerNode(node);            }            try {                node = (Node) getNode(txn, "1");            } catch (ObjectNotFoundException notfound) {                node = new Node("users", "1", null, nmgr.safe);                node.setDbMapping(app.getDbMapping("__userroot__"));                saveNode(txn, node.getID(), node);                // register node with nodemanager cache                nmgr.registerNode(node);            }            commitTransaction(txn);        } catch (Exception x) {            x.printStackTrace();            try {                abortTransaction(txn);            } catch (Exception ignore) {            }            throw (new DatabaseException("Error initializing db"));        }    }