From fbd7f9cbff4f22e855b1a9d8906bf0f186ed7b81 Mon Sep 17 00:00:00 2001 From: J-N-K Date: Fri, 12 May 2023 22:22:38 +0200 Subject: [PATCH] Fix UpgradeTool and enable default=all policy (#3607) Signed-off-by: Jan N. Klug --- .../main/java/org/openhab/core/tools/UpgradeTool.java | 10 +++++++--- .../java/org/openhab/core/tools/internal/Upgrader.java | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/upgradetool/src/main/java/org/openhab/core/tools/UpgradeTool.java b/tools/upgradetool/src/main/java/org/openhab/core/tools/UpgradeTool.java index 7df66d741..b310d8139 100644 --- a/tools/upgradetool/src/main/java/org/openhab/core/tools/UpgradeTool.java +++ b/tools/upgradetool/src/main/java/org/openhab/core/tools/UpgradeTool.java @@ -42,7 +42,8 @@ public class UpgradeTool { Options options = new Options(); options.addOption(Option.builder().longOpt(OPT_DIR).desc("directory to process").numberOfArgs(1).build()); - options.addOption(Option.builder().longOpt(OPT_COMMAND).numberOfArgs(1).desc("command to execute").build()); + options.addOption(Option.builder().longOpt(OPT_COMMAND).numberOfArgs(1) + .desc("command to execute (executes all if omitted)").build()); options.addOption(Option.builder().longOpt(OPT_LOG).numberOfArgs(1).desc("log verbosity").build()); options.addOption(Option.builder().longOpt(OPT_FORCE).desc("force execution (even if already done)").build()); @@ -73,9 +74,12 @@ public class UpgradeTool { boolean force = commandLine.hasOption(OPT_FORCE) ? true : false; Upgrader upgrader = new Upgrader(baseDir, force); - if (commandLine.hasOption(ITEM_COPY_UNIT_TO_METADATA)) { + if (!commandLine.hasOption(OPT_COMMAND) + || ITEM_COPY_UNIT_TO_METADATA.equals(commandLine.getOptionValue(OPT_COMMAND))) { upgrader.itemCopyUnitToMetadata(); - } else if (commandLine.hasOption(LINK_UPGRADE_JS_PROFILE)) { + } + if (!commandLine.hasOption(OPT_COMMAND) + || LINK_UPGRADE_JS_PROFILE.equals(commandLine.getOptionValue(OPT_COMMAND))) { upgrader.linkUpgradeJsProfile(); } } diff --git a/tools/upgradetool/src/main/java/org/openhab/core/tools/internal/Upgrader.java b/tools/upgradetool/src/main/java/org/openhab/core/tools/internal/Upgrader.java index be4094ab6..acf12f849 100644 --- a/tools/upgradetool/src/main/java/org/openhab/core/tools/internal/Upgrader.java +++ b/tools/upgradetool/src/main/java/org/openhab/core/tools/internal/Upgrader.java @@ -67,7 +67,7 @@ public class Upgrader { } public void itemCopyUnitToMetadata() { - if (checkUpgradeRecord(ITEM_COPY_UNIT_TO_METADATA)) { + if (!checkUpgradeRecord(ITEM_COPY_UNIT_TO_METADATA)) { return; } Path itemJsonDatabasePath = Path.of(baseDir, "jsondb", "org.openhab.core.items.Item.json"); @@ -125,7 +125,7 @@ public class Upgrader { } public void linkUpgradeJsProfile() { - if (checkUpgradeRecord(LINK_UPGRADE_JS_PROFILE)) { + if (!checkUpgradeRecord(LINK_UPGRADE_JS_PROFILE)) { return; }