branch develop updated (6691833 -> 06f4e11)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository nuiton-config. See https://gitlab.nuiton.org/nuiton/nuiton-config.git from 6691833 [ApplicationConfig] NullPointerException when saving file (Fixes #855) new 06f4e11 Do not store option value for value equals to default option (Fixes #1807) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 06f4e118753e3fddb4454394c78c6e18a4529d05 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Oct 2 10:43:16 2016 +0200 Do not store option value for value equals to default option (Fixes #1807) Summary of changes: .../java/org/nuiton/config/ApplicationConfig.java | 58 +++++++++++++++++++--- 1 file changed, 51 insertions(+), 7 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository nuiton-config. See https://gitlab.nuiton.org/nuiton/nuiton-config.git commit 06f4e118753e3fddb4454394c78c6e18a4529d05 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Oct 2 10:43:16 2016 +0200 Do not store option value for value equals to default option (Fixes #1807) --- .../java/org/nuiton/config/ApplicationConfig.java | 58 +++++++++++++++++++--- 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/nuiton-config/src/main/java/org/nuiton/config/ApplicationConfig.java b/nuiton-config/src/main/java/org/nuiton/config/ApplicationConfig.java index 6af8fb4..fae7728 100644 --- a/nuiton-config/src/main/java/org/nuiton/config/ApplicationConfig.java +++ b/nuiton-config/src/main/java/org/nuiton/config/ApplicationConfig.java @@ -853,7 +853,7 @@ public class ApplicationConfig { * @return the system config file location * @throws ApplicationConfigFileNameNotInitializedException if no config file name found in configuration */ - public File getSystemConfigFile() throws ApplicationConfigFileNameNotInitializedException{ + public File getSystemConfigFile() throws ApplicationConfigFileNameNotInitializedException { String configFileName = getConfigFileName(); if (configFileName == null) { throw new ApplicationConfigFileNameNotInitializedException(); @@ -868,7 +868,7 @@ public class ApplicationConfig { * @return the user config file location * @throws ApplicationConfigFileNameNotInitializedException if no config file name found in configuration */ - public File getUserConfigFile() throws ApplicationConfigFileNameNotInitializedException{ + public File getUserConfigFile() throws ApplicationConfigFileNameNotInitializedException { String configFileName = getConfigFileName(); if (configFileName == null) { throw new ApplicationConfigFileNameNotInitializedException(); @@ -1411,16 +1411,46 @@ public class ApplicationConfig { * @param value property value */ public void setOption(String key, String value) { - Properties props; + + ApplicationConfigScope optionScope; + if (inParseOptionPhase) { - props = getProperties(ApplicationConfigScope.LINE); + optionScope = ApplicationConfigScope.LINE; } else { - props = getProperties(ApplicationConfigScope.OPTIONS); + optionScope = ApplicationConfigScope.OPTIONS; } + + boolean setOption = true; if (value == null) { - props.remove(key); + + setOption = false; + + } else { + + Properties defaults = getProperties(ApplicationConfigScope.DEFAULTS); + if (defaults != null) { + String defaultValue = defaults.getProperty(key); + if (defaultValue != null) { + defaultValue = replaceRecursiveOptions(defaultValue); + if (value.equals(defaultValue)) { + + // on supprime l'option, car c'est la valeur par défaut + setOption = false; + } + } + } + + } + + if (setOption) { + + getProperties(optionScope).setProperty(key, value); + } else { - props.setProperty(key, value); + + // delete from props, or home, or system if not found in previous scope + remove(key, optionScope, ApplicationConfigScope.HOME, ApplicationConfigScope.SYSTEM); + } } @@ -2324,6 +2354,20 @@ public class ApplicationConfig { return msg; } + protected void remove(String key, ApplicationConfigScope... scopes) { + for (ApplicationConfigScope scope : scopes) { + + Properties properties = getProperties(scope); + if (properties == null) { + continue; + } + Object remove = properties.remove(key); + if (remove != null) { + return; + } + } + } + protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { pcs.firePropertyChange(propertyName, oldValue, newValue); -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm