Due to a scheduled upgrade to version 14.10, GitLab will be unavailabe on Monday 30.05., from 19:00 until 20:00.

Commit 8e7b3101 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

fix code styles

parent e795b042
......@@ -20,4 +20,4 @@ package org.memobase
import org.snakeyaml.engine.v2.env.EnvConfig
class CustomEnvConfig : EnvConfig
\ No newline at end of file
class CustomEnvConfig : EnvConfig
......@@ -18,4 +18,4 @@
package org.memobase
class MissingSettingException(setting: String) : Exception("Missing setting $setting in configuration file. Stopping application ...")
\ No newline at end of file
class MissingSettingException(setting: String) : Exception("Missing setting $setting in configuration file. Stopping application ...")
......@@ -17,32 +17,30 @@
*/
package org.memobase
import java.io.File
import java.io.FileInputStream
import java.util.Optional
import java.util.Properties
import kotlin.system.exitProcess
import org.apache.kafka.clients.producer.ProducerConfig
import org.apache.kafka.common.serialization.StringSerializer
import org.apache.logging.log4j.LogManager
import org.snakeyaml.engine.v2.api.Load
import org.snakeyaml.engine.v2.api.LoadSettings
import org.snakeyaml.engine.v2.exceptions.MissingEnvironmentVariableException
import java.io.File
import java.io.FileInputStream
import java.util.*
import kotlin.system.exitProcess
class SettingsLoader {
private val log = LogManager.getLogger("SettingsLoader")
private fun loadYaml(): Any {
val settings = LoadSettings.builder().setEnvConfig(Optional.of(CustomEnvConfig())).build()
val load = Load(settings)
try {
val file = File("/configs/app.yml")
return if (file.isFile) {
load.loadFromInputStream(FileInputStream(file))
}
else {
} else {
log.warn("Loading default properties in app.yml from classpath!")
load.loadFromInputStream(ClassLoader.getSystemResourceAsStream("app.yml"))
}
......@@ -50,7 +48,6 @@ class SettingsLoader {
log.error(ex.message)
exitProcess(1)
}
}
private val rawKafkaProperties: Map<String, String>
......@@ -80,7 +77,6 @@ class SettingsLoader {
ensurePropertyIsSet("user", sftpSettings)
ensurePropertyIsSet("password", sftpSettings)
ensurePropertyIsSet("fingerprint", sftpSettings)
} catch (ex: ClassCastException) {
ex.printStackTrace()
log.error("The properties file has an invalid structure: $ex")
......@@ -94,7 +90,7 @@ class SettingsLoader {
private fun ensurePropertyIsSet(setting: String, settings: Map<String, String>) {
if (settings[setting].isNullOrEmpty()) {
throw MissingSettingException(setting)
throw MissingSettingException(setting)
}
}
......@@ -130,7 +126,6 @@ class SettingsLoader {
setKafkaProperty(ProducerConfig.RECEIVE_BUFFER_CONFIG)
setKafkaProperty(ProducerConfig.RECONNECT_BACKOFF_MAX_MS_CONFIG)
setKafkaProperty(ProducerConfig.RECONNECT_BACKOFF_MS_CONFIG)
}
private fun setKafkaProperty(propertyName: String, defaultValue: Any? = null, abortIfMissing: Boolean = false) {
......@@ -156,5 +151,3 @@ class SettingsLoader {
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment