Repository: incubator-batchee
Updated Branches:
  refs/heads/master 79c91e0b1 -> d4ad6b76d


BATCHEE-135 fixed batchee-cli names


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

Branch: refs/heads/master
Commit: d4ad6b76d3013a7eb74fbe062aeac305215d6a36
Parents: 79c91e0
Author: Reinhard Sandtner <[email protected]>
Authored: Fri Nov 30 13:07:44 2018 +0100
Committer: Reinhard Sandtner <[email protected]>
Committed: Fri Nov 30 13:07:44 2018 +0100

----------------------------------------------------------------------
 .../org/apache/batchee/cli/command/Names.java    | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/d4ad6b76/tools/cli/src/main/java/org/apache/batchee/cli/command/Names.java
----------------------------------------------------------------------
diff --git a/tools/cli/src/main/java/org/apache/batchee/cli/command/Names.java 
b/tools/cli/src/main/java/org/apache/batchee/cli/command/Names.java
index a62aa32..a3ce833 100644
--- a/tools/cli/src/main/java/org/apache/batchee/cli/command/Names.java
+++ b/tools/cli/src/main/java/org/apache/batchee/cli/command/Names.java
@@ -31,6 +31,9 @@ import java.util.regex.Pattern;
 
 @Command(name = "names", description = "list known batches")
 public class Names extends JobOperatorCommand {
+
+    private static final Pattern JOB_XML_PATTERN = 
Pattern.compile("META-INF/batch-jobs/(.*)\\.xml");
+
     @Override
     public void doRun() {
         final Set<String> names = operator().getJobNames();
@@ -63,22 +66,28 @@ public class Names extends JobOperatorCommand {
                 }
             }
         }
+        info("-----");
     }
 
     private void findInJar(final File file) {
-        final Pattern pattern = 
Pattern.compile("META\\-INF/batch-jobs/\\(*\\).xml");
         final JarFile jar;
         try {
             jar = new JarFile(file);
         } catch (final IOException e) {
+            info(String.format("could not load jobs in file %s", 
file.getAbsolutePath()));
             return;
         }
         final Enumeration<JarEntry> entries = jar.entries();
         while (entries.hasMoreElements()) {
             final JarEntry entry = entries.nextElement();
-            final Matcher matcher = pattern.matcher(entry.getName());
+
+            if (entry.isDirectory()) {
+                continue;
+            }
+
+            final Matcher matcher = JOB_XML_PATTERN.matcher(entry.getName());
             if (matcher.matches()) {
-                info(matcher.group(1) + "*");
+                info(matcher.group(1));
             }
         }
     }
@@ -92,7 +101,7 @@ public class Names extends JobOperatorCommand {
         });
         if (batches != null) {
             for (final String batch : batches) {
-                info(batch + "*");
+                info(batch);
             }
         }
     }
@@ -101,7 +110,7 @@ public class Names extends JobOperatorCommand {
         final File file;
         final String externalForm = url.toExternalForm();
         if ("jar".equals(url.getProtocol())) {
-            file = new File(externalForm.substring("jar:".length(), 
externalForm.lastIndexOf('!')));
+            file = new File(externalForm.substring("jar:file:".length(), 
externalForm.lastIndexOf('!')));
         } else if ("file".equals(url.getProtocol())) {
             file = new File(externalForm.substring("file:".length()));
         } else {

Reply via email to