    public void readConfig(Configuration aStorageConfig, File aRepoConfigFile) throws RepositoryException {
        Boolean       createPrefix;
        Configuration repositoryConfig;
        Configuration credentialsConfig;
        Database      database;
        File          databaseHomeDir;
        Service       collectionService;
        String        driverName;
        String        databaseHome;
        String        rootCollection;
        String        pathPrefix;
        String        databaseAddress;
        String        databaseName;
        String        databaseURIPrefix;
        if (aStorageConfig == null || aRepoConfigFile == null)
            throw new RepositoryException("No storage/repository configuration available.");
        try {
            driverName        = aStorageConfig.getChild("driver").getValue("");
            mLog.error("Specified driver name = \"" + driverName + "\".");
            databaseHome      = aStorageConfig.getChild("db-home").getValue(null);
            mLog.error("Specified database home = \"" + databaseHome + "\".");
            rootCollection    = aStorageConfig.getChild("root").getValue("");
            mLog.error("Specified root collection = \"" + rootCollection + "\".");
            pathPrefix        = aStorageConfig.getChild("prefix").getValue("");
            createPrefix      = aStorageConfig.getChild("prefix").getAttributeAsBoolean("createIfNotExists", false);
            mLog.error("Specified collection prefix = \"" + pathPrefix + "\" (create if not exists: \"" + createPrefix + "\").");
            databaseAddress   = aStorageConfig.getChild("address").getValue("");
            mLog.error("Specified database address = \"" + databaseAddress + "\".");
            credentialsConfig = aStorageConfig.getChild("credentials", false);
            if (credentialsConfig != null) {
                mCredentials = new Credentials(credentialsConfig.getChild("username").getValue(""),
                                               credentialsConfig.getChild("password").getValue(""));
                mLog.error("Specified credentials read.");
            }
        } catch (Exception exception) {
            mLog.error(exception);
            throw new RepositoryException(exception.getMessage(), exception);
        }
        if (driverName.equals(""))
            throw new RepositoryException("Database driver not specified.");
        if (rootCollection.equals(""))
            throw new RepositoryException("Database root collection not specified.");
        try {
            database = (Database) Class.forName(driverName).newInstance();
            if (databaseHome != null) {
                databaseHomeDir = new File(databaseHome);
                if (!databaseHomeDir.isAbsolute()) {
                    databaseHomeDir = FileUtil.file(aRepoConfigFile.getParent(), databaseHomeDir.toString());
                }
                mLog.error("Resolved database home directory = \"" + databaseHomeDir + "\"");
                database.setProperty("db-home", databaseHomeDir.toString());
            }
            DatabaseManager.registerDatabase(database);
            databaseName = database.getName();
        } catch (Exception exception) {
            mLog.error(exception);
            throw new RepositoryException(exception.getMessage(), exception);
        }
        databaseURIPrefix = "xmldb:" + databaseName + "://" + databaseAddress  + "/" + rootCollection + "/";
        if (pathPrefix.equals("")) {
            mDatabaseURIPrefix = databaseURIPrefix;
        } else {
            mDatabaseURIPrefix = databaseURIPrefix + "/" + pathPrefix + "/";
        }
        mLog.error("Collection base path = \"" + databaseURIPrefix + "\".");
        mLog.error("Complete collection base path = \"" + mDatabaseURIPrefix + "\".");
        try {
            database.acceptsURI(mDatabaseURIPrefix);
        } catch (XMLDBException exception) {
            mLog.error(exception);
            if (exception.errorCode == org.xmldb.api.base.ErrorCodes.INVALID_URI) {
                throw new RepositoryException("The database does not accept the URI prefix \"" + mDatabaseURIPrefix + "\" as valid. Please make sure that the database host address (\"" + databaseAddress + "\") is correct. Original message: " + exception.getMessage(), exception);
            } else {
                throw new RepositoryException(exception.getMessage(), exception);
            }
        } catch (Exception exception) {
            mLog.error(exception);
            throw new RepositoryException(exception.getMessage(), exception);
        }
        try {
            if (getCollection(databaseURIPrefix) == null)
                throw new RepositoryException("Specified root collection (\"" + rootCollection + "\") does not exist.");
            if (getCollectionRelative(null) == null) {
                if (createPrefix) {
                    try {
                        collectionService = getCollection(databaseURIPrefix).getService("CollectionManagementService", "1.0");
                        ((CollectionManagementService) collectionService).createCollection(pathPrefix);
                        if (getCollectionRelative(null) == null)
                            throw new RepositoryException("Specified collection prefix (\"" + pathPrefix + "\") does not exist.");
                    } catch (Exception exception) {
                        mLog.error(exception);
                        throw new RepositoryException("Failed to create prefix collection (\"" + pathPrefix + "\"). Original message: " + exception.getMessage(), exception);
                    }
                    mLog.error("Created new collection \"" + pathPrefix + "\".");
                } else {
                    throw new RepositoryException("Specified collection prefix (\"" + pathPrefix + "\") does not exist.");
                }
            }
        } catch (Exception exception) {
            try {
                DatabaseManager.deregisterDatabase(database);
            } catch (Exception databaseException) {
                mLog.error(databaseException);
                throw new RepositoryException(databaseException.getMessage(), databaseException);
            }
            throw new RepositoryException(exception.getMessage(), exception);
        }
    }

    public void readConfig(Configuration aStorageConfig, File aRepoConfigFile) throws RepositoryException {
        boolean       createPrefix;
        Configuration repositoryConfig;
        Configuration credentialsConfig;
        Database      database;
        File          databaseHomeDir;
        Service       collectionService;
        String        driverName;
        String        databaseHome;
        String        rootCollection;
        String        pathPrefix;
        String        databaseAddress;
        String        databaseName;
        String        databaseURIPrefix;
        if (aStorageConfig == null || aRepoConfigFile == null)
            throw new RepositoryException("No storage/repository configuration available.");
        try {
            driverName        = aStorageConfig.getChild("driver").getValue("");
            mLog.error("Specified driver name = \"" + driverName + "\".");
            databaseHome      = aStorageConfig.getChild("db-home").getValue(null);
            mLog.error("Specified database home = \"" + databaseHome + "\".");
            rootCollection    = aStorageConfig.getChild("root").getValue("");
            mLog.error("Specified root collection = \"" + rootCollection + "\".");
            pathPrefix        = aStorageConfig.getChild("prefix").getValue("");
            createPrefix      = aStorageConfig.getChild("prefix").getAttributeAsBoolean("createIfNotExists", false);
            mLog.error("Specified collection prefix = \"" + pathPrefix + "\" (create if not exists: \"" + createPrefix + "\").");
            databaseAddress   = aStorageConfig.getChild("address").getValue("");
            mLog.error("Specified database address = \"" + databaseAddress + "\".");
            credentialsConfig = aStorageConfig.getChild("credentials", false);
            if (credentialsConfig != null) {
                mCredentials = new Credentials(credentialsConfig.getChild("username").getValue(""),
                                               credentialsConfig.getChild("password").getValue(""));
                mLog.error("Specified credentials read.");
            }
        } catch (Exception exception) {
            mLog.error(exception);
            throw new RepositoryException(exception.getMessage(), exception);
        }
        if (driverName.equals(""))
            throw new RepositoryException("Database driver not specified.");
        if (rootCollection.equals(""))
            throw new RepositoryException("Database root collection not specified.");
        try {
            database = (Database) Class.forName(driverName).newInstance();
            if (databaseHome != null) {
                databaseHomeDir = new File(databaseHome);
                if (!databaseHomeDir.isAbsolute()) {
                    databaseHomeDir = FileUtil.file(aRepoConfigFile.getParent(), databaseHomeDir.toString());
                }
                mLog.error("Resolved database home directory = \"" + databaseHomeDir + "\"");
                database.setProperty("db-home", databaseHomeDir.toString());
            }
            DatabaseManager.registerDatabase(database);
            databaseName = database.getName();
        } catch (Exception exception) {
            mLog.error(exception);
            throw new RepositoryException(exception.getMessage(), exception);
        }
        databaseURIPrefix = "xmldb:" + databaseName + "://" + databaseAddress  + "/" + rootCollection + "/";
        if (pathPrefix.equals("")) {
            mDatabaseURIPrefix = databaseURIPrefix;
        } else {
            mDatabaseURIPrefix = databaseURIPrefix + "/" + pathPrefix + "/";
        }
        mLog.error("Collection base path = \"" + databaseURIPrefix + "\".");
        mLog.error("Complete collection base path = \"" + mDatabaseURIPrefix + "\".");
        try {
            database.acceptsURI(mDatabaseURIPrefix);
        } catch (XMLDBException exception) {
            mLog.error(exception);
            if (exception.errorCode == org.xmldb.api.base.ErrorCodes.INVALID_URI) {
                throw new RepositoryException("The database does not accept the URI prefix \"" + mDatabaseURIPrefix + "\" as valid. Please make sure that the database host address (\"" + databaseAddress + "\") is correct. Original message: " + exception.getMessage(), exception);
            } else {
                throw new RepositoryException(exception.getMessage(), exception);
            }
        } catch (Exception exception) {
            mLog.error(exception);
            throw new RepositoryException(exception.getMessage(), exception);
        }
        try {
            if (getCollection(databaseURIPrefix) == null)
                throw new RepositoryException("Specified root collection (\"" + rootCollection + "\") does not exist.");
            if (getCollectionRelative(null) == null) {
                if (createPrefix) {
                    try {
                        collectionService = getCollection(databaseURIPrefix).getService("CollectionManagementService", "1.0");
                        ((CollectionManagementService) collectionService).createCollection(pathPrefix);
                        if (getCollectionRelative(null) == null)
                            throw new RepositoryException("Specified collection prefix (\"" + pathPrefix + "\") does not exist.");
                    } catch (Exception exception) {
                        mLog.error(exception);
                        throw new RepositoryException("Failed to create prefix collection (\"" + pathPrefix + "\"). Original message: " + exception.getMessage(), exception);
                    }
                    mLog.error("Created new collection \"" + pathPrefix + "\".");
                } else {
                    throw new RepositoryException("Specified collection prefix (\"" + pathPrefix + "\") does not exist.");
                }
            }
        } catch (Exception exception) {
            try {
                DatabaseManager.deregisterDatabase(database);
            } catch (Exception databaseException) {
                mLog.error(databaseException);
                throw new RepositoryException(databaseException.getMessage(), databaseException);
            }
            throw new RepositoryException(exception.getMessage(), exception);
        }
    }
