UNOMI-150 Ask for confirm before each migration

Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/1bbce3f6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/1bbce3f6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/1bbce3f6

Branch: refs/heads/master
Commit: 1bbce3f63bbde5a69d8e116b963d534efd25c71b
Parents: b463b11
Author: Jarek Lipski <jlip...@jahia.com>
Authored: Thu Feb 8 13:38:53 2018 +0100
Committer: Jarek Lipski <jlip...@jahia.com>
Committed: Thu Feb 8 13:38:53 2018 +0100

----------------------------------------------------------------------
 .../java/org/apache/unomi/shell/migration/actions/Migrate.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/1bbce3f6/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/actions/Migrate.java
----------------------------------------------------------------------
diff --git 
a/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/actions/Migrate.java
 
b/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/actions/Migrate.java
index dd556fb..9b5fa58 100644
--- 
a/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/actions/Migrate.java
+++ 
b/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/actions/Migrate.java
@@ -60,7 +60,11 @@ public class Migrate extends OsgiCommandSupport {
 
             for (Migration migration : migrations) {
                 if (fromVersion.compareTo(migration.getToVersion()) < 0) {
-                    System.out.println("Starting migration to version " + 
migration.getToVersion());
+                    String migrateConfirmation = 
ConsoleUtils.askUserWithAuthorizedAnswer(session,"Starting migration to version 
" + migration.getToVersion() + ", do you want to proceed? (yes/no): ", 
Arrays.asList("yes", "no"));
+                    if (migrateConfirmation.equalsIgnoreCase("no")) {
+                        System.out.println("Migration process aborted");
+                        break;
+                    }
                     migration.execute(session, httpClient, esAddress);
                     System.out.println("Migration to version " + 
migration.getToVersion() + " done successfully");
                 }

Reply via email to