From 7ad25dc734f6ed117fe9baa0130e20ba47601797 Mon Sep 17 00:00:00 2001 From: jomu Date: Wed, 12 Dec 2018 16:36:42 +0100 Subject: [PATCH] allowed removal of existing config values --- .../business/config/boundary/ConfigService.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/account/src/main/java/de/muehlencord/shared/account/business/config/boundary/ConfigService.java b/account/src/main/java/de/muehlencord/shared/account/business/config/boundary/ConfigService.java index ce59c2c..9220054 100644 --- a/account/src/main/java/de/muehlencord/shared/account/business/config/boundary/ConfigService.java +++ b/account/src/main/java/de/muehlencord/shared/account/business/config/boundary/ConfigService.java @@ -164,7 +164,7 @@ public class ConfigService implements Serializable { return false; } if (account == null) { - LOGGER.error("Account for usreName {} not found", accountName); + LOGGER.error("Account for userName {} not found", accountName); return false; } return updateConfigValue(configKey, account, configValue); @@ -174,8 +174,8 @@ public class ConfigService implements Serializable { @Lock(LockType.WRITE) @TransactionAttribute(REQUIRES_NEW) public boolean updateConfigValue(String configKey, Account account, String configValue) { - if ((configKey == null) || (configKey.equals("")) || (configValue == null) || (configValue.equals(""))) { - // null or empty key / values are not possible + if ((configKey == null) || (configKey.equals(""))) { + // null or empty key return false; } @@ -195,10 +195,18 @@ public class ConfigService implements Serializable { } else { if ((currentEntity.getConfigValue() != null) && (currentEntity.getConfigValue().equals(configValue))) { // value is the same - no update + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("configValue {} not changed, keeping {}", configKey, currentEntity.getConfigValue()); + } + return false; } else { + String oldValue = currentEntity.getConfigValue(); currentEntity.setConfigValue(configValue); em.merge(currentEntity); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("configValue for {} updated from {} to {}", configKey, oldValue, configValue); + } return true; } }