override fun start()

in entity-browser-app/src/main/kotlin/jetbrains/xodus/browser/web/db/DBDatabasesStore.kt [37:65]


    override fun start() {
        val config = EnvironmentConfig().also {
            if (isEncrypted) {
                it.cipherBasicIV = iv
                it.setCipherKey(key)
                it.cipherId = cipherId
            }
        }
        try {
            logger.info { "Opening database on '$location'" }
            val env = Environments.newInstance(location, config)
            store = PersistentEntityStores.newInstance(env, "xodus-entity-browser")
            store.executeInTransaction {
                it as PersistentStoreTransaction
                store.getEntityTypeId(it, dbType, true)

                // Validate store
                it.getAll(dbType).toList().forEach { entity ->
                    try {
                        DBEntity(entity).summary()
                    } catch (e: Exception) {
                        entity.delete()
                    }
                }
            }
        } catch (e: Exception) {
            throw IllegalStateException("Can't open database on '$location'", e)
        }
    }