From 63cf4d5a601e7e44c22144cdeb98a4357f1bcf16 Mon Sep 17 00:00:00 2001 From: Martyn Taylor Date: Mon, 9 Jan 2017 14:48:28 +0000 Subject: [PATCH] ARTEMIS-912 Fix file configuration migration tool --- .../artemis/tools/migrate/config/Main.java | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/migrate/config/Main.java b/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/migrate/config/Main.java index 754dc15694..692ab9ed8f 100644 --- a/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/migrate/config/Main.java +++ b/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/migrate/config/Main.java @@ -29,7 +29,7 @@ public class Main { File input = new File(args[0]); if (input.isDirectory()) { System.out.println("Scanning directory: " + input.getAbsolutePath()); - recursiveTransform(input); + scanAndTransform(input); } else { if (args.length != 2) { System.err.println("Invalid args"); @@ -37,6 +37,7 @@ public class Main { } else { try { XMLConfigurationMigration migration = new XMLConfigurationMigration(input, new File(args[1])); + migration.transform(); } catch (Exception e) { // Unable to process file, move on. } @@ -51,30 +52,28 @@ public class Main { } } - public static void scanAndTransform(File pFile) throws Exception { + public static void scanAndTransform(File f) throws Exception { try { - for (File f : pFile.listFiles()) { - if (f.isDirectory()) { - scanAndTransform(f); - } else { - try { - if (f.getName().endsWith("xml")) { - File file = new File(f.getAbsolutePath() + ".new"); - XMLConfigurationMigration migration = new XMLConfigurationMigration(f, file); - if (migration.transform()) { - File r = new File(f.getAbsolutePath()); - f.renameTo(new File(f.getAbsolutePath() + ".bk")); - file.renameTo(r); - System.out.println(f + " converted, old file renamed as " + f.getAbsolutePath() + ".bk"); - } + if (f.isDirectory()) { + recursiveTransform(f); + } else { + try { + if (f.getName().endsWith("xml")) { + File file = new File(f.getAbsolutePath() + ".new"); + XMLConfigurationMigration migration = new XMLConfigurationMigration(f, file); + if (migration.transform()) { + File r = new File(f.getAbsolutePath()); + f.renameTo(new File(f.getAbsolutePath() + ".bk")); + file.renameTo(r); + System.out.println(f + " converted, old file renamed as " + f.getAbsolutePath() + ".bk"); } - } catch (Exception e) { - //Unable to process file, continue } + } catch (Exception e) { + //Unable to process file, continue } } } catch (NullPointerException e) { - System.out.println(pFile.getAbsoluteFile()); + System.out.println(f.getAbsoluteFile()); } }