From ea8ad4f8ce1208a08efc8557240c5499b06e4b9a Mon Sep 17 00:00:00 2001
From: Kai Reinhard <K.Reinhard@micromata.de>
Date: Sun, 18 Apr 2021 21:09:41 +0000
Subject: [PATCH] Code cleanup, json.prettyprint removed.
---
borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/rest/ConfigurationRest.kt | 27 +++++++++------------------
1 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/rest/ConfigurationRest.kt b/borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/rest/ConfigurationRest.kt
index c0ac4b2..29dba18 100644
--- a/borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/rest/ConfigurationRest.kt
+++ b/borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/rest/ConfigurationRest.kt
@@ -17,16 +17,12 @@
@RequestMapping("/rest/configuration")
class ConfigurationRest {
- /**
- * @param prettyPrinter If true then the json output will be in pretty format.
- * @see JsonUtils.toJson
- */
@GetMapping("config")
- fun getConfig(@RequestParam("prettyPrinter", required = false) prettyPrinter: Boolean?): String {
+ fun getConfig(): ConfigurationInfo {
val configurationInfo = ConfigurationInfo()
configurationInfo.serverConfiguration = ServerConfiguration.get()
- configurationInfo.borgVersion = BorgInstallation.getInstance().getBorgVersion()
- return JsonUtils.toJson(configurationInfo, prettyPrinter)
+ configurationInfo.borgVersion = BorgInstallation.getInstance().borgVersion
+ return configurationInfo
}
@PostMapping("config")
@@ -41,25 +37,20 @@
configurationHandler.save()
}
- /**
- * @param prettyPrinter If true then the json output will be in pretty format.
- * @see JsonUtils.toJson
- */
@GetMapping("user")
- fun getUser(@RequestParam("prettyPrinter", required = false) prettyPrinter: Boolean?): String {
- val user: UserData = RestUtils.getUser()
- return JsonUtils.toJson(user, prettyPrinter)
+ fun getUser(): UserData {
+ return RestUtils.getUser()
}
@PostMapping("user")
fun setUser(@RequestBody user: UserData) {
- if (user.getLocale() != null && StringUtils.isBlank(user.getLocale().getLanguage())) {
+ if (user.locale?.language?.isBlank() == true) {
// Don't set locale with "" as language.
- user.setLocale(null)
+ user.locale = null
}
- if (StringUtils.isBlank(user.getDateFormat())) {
+ if (user.dateFormat?.isBlank() == true) {
// Don't set dateFormat as "".
- user.setDateFormat(null)
+ user.dateFormat = null
}
UserManager.instance().saveUser(user)
}
--
Gitblit v1.10.0