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