From: David ‘Bombe’ Roden Date: Mon, 25 Oct 2010 06:22:17 +0000 (+0200) Subject: Add options to clear the configuration on next restart. X-Git-Tag: 0.1-RC1~33 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=eb2005d35011fd20e044f99cc49be126f31c8373;p=Sone.git Add options to clear the configuration on next restart. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 21d7a80..49cbc8a 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -615,6 +615,7 @@ public class Core extends AbstractService { /** * Loads the configuration. */ + @SuppressWarnings("unchecked") private void loadConfiguration() { logger.entering(Core.class.getName(), "loadConfiguration()"); @@ -627,6 +628,17 @@ public class Core extends AbstractService { })).set(configuration.getIntValue("Option/InsertionDelay").getValue(null)); + options.addBooleanOption("ClearOnNextRestart", new DefaultOption(false)).set(configuration.getBooleanValue("Option/ClearOnNextRestart").getValue(null)); + options.addBooleanOption("ReallyClearOnNextRestart", new DefaultOption(false)).set(configuration.getBooleanValue("Option/ReallyClearOnNextRestart").getValue(null)); + + boolean clearConfiguration = options.getBooleanOption("ClearOnNextRestart").get() && options.getBooleanOption("ReallyClearOnNextRestart").get(); + options.getBooleanOption("ClearOnNextRestart").set(null); + options.getBooleanOption("ReallyClearOnNextRestart").set(null); + if (clearConfiguration) { + /* stop loading the configuration. */ + return; + } + /* parse local Sones. */ logger.log(Level.INFO, "Loading Sones…"); int soneId = 0; @@ -772,6 +784,8 @@ public class Core extends AbstractService { try { /* store the options first. */ configuration.getIntValue("Option/InsertionDelay").setValue(options.getIntegerOption("InsertionDelay").getReal()); + configuration.getBooleanValue("Option/ClearOnNextRestart").setValue(options.getBooleanOption("ClearOnNextRestart").getReal()); + configuration.getBooleanValue("Option/ReallyClearOnNextRestart").setValue(options.getBooleanOption("ReallyClearOnNextRestart").getReal()); /* store all Sones. */ int soneId = 0;