Deduplicate default values in StartupController
This commit is contained in:
parent
e6f09c11ba
commit
795ddc516d
|
@ -77,29 +77,21 @@ class StartupController {
|
|||
val properties = Properties()
|
||||
properties.loadFromXML(FileInputStream(fileConfig))
|
||||
|
||||
cachetAPIKey = try {
|
||||
properties.getProperty("cachetAPIKey")
|
||||
} catch (ex: Exception) {
|
||||
"0"
|
||||
}
|
||||
try {
|
||||
cachetAPIKey = properties.getProperty("cachetAPIKey")
|
||||
} catch (_: Exception) {}
|
||||
|
||||
cachetBaseURL = try {
|
||||
properties.getProperty("cachetBaseURL")
|
||||
} catch (ex: Exception) {
|
||||
"https://status.mosad.xyz"
|
||||
}
|
||||
try {
|
||||
cachetBaseURL = properties.getProperty("cachetBaseURL")
|
||||
} catch (_: Exception) {}
|
||||
|
||||
mensaMenuURL = try {
|
||||
properties.getProperty("mensaMenuURL")
|
||||
} catch (ex: Exception) {
|
||||
"https://www.swfr.de/essen-trinken/speiseplaene/mensa-offenburg/"
|
||||
}
|
||||
try {
|
||||
mensaMenuURL = properties.getProperty("mensaMenuURL")
|
||||
} catch (_: Exception) {}
|
||||
|
||||
mensaName = try {
|
||||
properties.getProperty("mensaName")
|
||||
} catch (ex: Exception) {
|
||||
"Offenburg"
|
||||
}
|
||||
try {
|
||||
mensaName = properties.getProperty("mensaName")
|
||||
} catch (_: Exception) {}
|
||||
|
||||
} catch (ex: Exception) {
|
||||
logger.error("error while loading config", ex)
|
||||
|
@ -111,10 +103,10 @@ class StartupController {
|
|||
private fun createConfig() = try {
|
||||
val properties = Properties()
|
||||
|
||||
properties.setProperty("cachetAPIKey", "0")
|
||||
properties.setProperty("cachetBaseURL", "https://status.mosad.xyz")
|
||||
properties.setProperty("mensaMenuURL", "https://www.swfr.de/essen-trinken/speiseplaene/mensa-offenburg/")
|
||||
properties.setProperty("mensaName", "Offenburg")
|
||||
properties.setProperty("cachetAPIKey", cachetAPIKey)
|
||||
properties.setProperty("cachetBaseURL", cachetBaseURL)
|
||||
properties.setProperty("mensaMenuURL", mensaMenuURL)
|
||||
properties.setProperty("mensaName", mensaName)
|
||||
|
||||
val outputStream = FileOutputStream(fileConfig)
|
||||
properties.storeToXML(outputStream, "tcor configuration")
|
||||
|
|
Loading…
Reference in New Issue