activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbert...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-912 Fix file configuration migration tool
Date Mon, 09 Jan 2017 16:13:04 GMT
ARTEMIS-912 Fix file configuration migration tool


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/63cf4d5a
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/63cf4d5a
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/63cf4d5a

Branch: refs/heads/master
Commit: 63cf4d5a601e7e44c22144cdeb98a4357f1bcf16
Parents: ef4efe7
Author: Martyn Taylor <mtaylor@redhat.com>
Authored: Mon Jan 9 14:48:28 2017 +0000
Committer: Justin Bertram <jbertram@apache.org>
Committed: Mon Jan 9 09:50:36 2017 -0600

----------------------------------------------------------------------
 .../artemis/tools/migrate/config/Main.java      | 37 ++++++++++----------
 1 file changed, 18 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/63cf4d5a/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/migrate/config/Main.java
----------------------------------------------------------------------
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 754dc15..692ab9e 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());
       }
    }
 


Mime
View raw message