@Test public void deep_wildcard() throws Exception { File f1 = touch("a/file1.txt", 50); File f2 = touch("a/file2.csv", 50); File f3 = touch("a/file3.txt", 50); File f4 = touch("b/file4.csv", 50); File f5 = touch("b/file5.txt", 50); Clean c = createService(100); int exit = c.run(args(1, path("*/*.csv"))); assertThat(exit, is(0)); assertThat(f1.toString(), f1.exists(), is(true)); assertThat(f2.toString(), f2.exists(), is(false)); assertThat(f3.toString(), f3.exists(), is(true)); assertThat(f4.toString(), f4.exists(), is(false)); assertThat(f5.toString(), f5.exists(), is(true)); }
@Override public int run(String[] args) { if (args == null) { throw new IllegalArgumentException("args must not be null"); } Opts opts; try { opts = parseOptions(args); if (opts == null) { return 2; } } catch (Exception e) { LOG.error(MessageFormat.format( "[OT-CLEAN-E00001] Invalid options: {0}", Arrays.toString(args)), e); return 2; } long period = currentTime - (long) (opts.keepDays * TimeUnit.DAYS.toMillis(1)); if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format("Keep switching-time: {0}", new Date(period))); } Context context = new Context(opts.recursive, period, opts.dryRun); for (Path path : opts.paths) { remove(path, context); } if (context.hasError()) { return 1; } return 0; }
Clean extends Configured implements Tool { @Override public int run(String[] args) { if (args == null) { throw new IllegalArgumentException("args must not be null"); } Opts opts; try { opts = parseOptions(args); if (opts == null) { return 2; } } catch (Exception e) { LOG.error(MessageFormat.format( "[OT-CLEAN-E00001] Invalid options: {0}", Arrays.toString(args)), e); return 2; } long period = currentTime - (long) (opts.keepDays * TimeUnit.DAYS.toMillis(1)); if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format("Keep switching-time: {0}", new Date(period))); } Context context = new Context(opts.recursive, period, opts.dryRun); for (Path path : opts.paths) { remove(path, context); } if (context.hasError()) { return 1; } return 0; } }
Clean extends Configured implements Tool { @Override public int run(String[] args) { if (args == null) { throw new IllegalArgumentException("args must not be null"); } Opts opts; try { opts = parseOptions(args); if (opts == null) { return 2; } } catch (Exception e) { LOG.error(MessageFormat.format( "[OT-CLEAN-E00001] Invalid options: {0}", Arrays.toString(args)), e); return 2; } long period = currentTime - (long) (opts.keepDays * TimeUnit.DAYS.toMillis(1)); if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format("Keep switching-time: {0}", new Date(period))); } Context context = new Context(opts.recursive, period, opts.dryRun); for (Path path : opts.paths) { remove(path, context); } if (context.hasError()) { return 1; } return 0; } Clean();   Clean(long currentTime); }
Clean extends Configured implements Tool { @Override public int run(String[] args) { if (args == null) { throw new IllegalArgumentException("args must not be null"); } Opts opts; try { opts = parseOptions(args); if (opts == null) { return 2; } } catch (Exception e) { LOG.error(MessageFormat.format( "[OT-CLEAN-E00001] Invalid options: {0}", Arrays.toString(args)), e); return 2; } long period = currentTime - (long) (opts.keepDays * TimeUnit.DAYS.toMillis(1)); if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format("Keep switching-time: {0}", new Date(period))); } Context context = new Context(opts.recursive, period, opts.dryRun); for (Path path : opts.paths) { remove(path, context); } if (context.hasError()) { return 1; } return 0; } Clean();   Clean(long currentTime); static void main(String... args); static int exec(String... args); @Override int run(String[] args); }
Clean extends Configured implements Tool { @Override public int run(String[] args) { if (args == null) { throw new IllegalArgumentException("args must not be null"); } Opts opts; try { opts = parseOptions(args); if (opts == null) { return 2; } } catch (Exception e) { LOG.error(MessageFormat.format( "[OT-CLEAN-E00001] Invalid options: {0}", Arrays.toString(args)), e); return 2; } long period = currentTime - (long) (opts.keepDays * TimeUnit.DAYS.toMillis(1)); if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format("Keep switching-time: {0}", new Date(period))); } Context context = new Context(opts.recursive, period, opts.dryRun); for (Path path : opts.paths) { remove(path, context); } if (context.hasError()) { return 1; } return 0; } Clean();   Clean(long currentTime); static void main(String... args); static int exec(String... args); @Override int run(String[] args);  }