@Test public void synchronizeFolders() throws IOException { final File root = new File("target/SetupTest/synchronizeFolders/"); Files.delete(root); final File source = org.apache.openejb.loader.Files.mkdirs(new File(root, "conf")); for (int i = 0; i < 10; i++) { final FileWriter w = new FileWriter(new File(source, "file-" + i)); w.write(Integer.toString(i)); w.close(); } Setup.synchronizeFolder(root,new File(root, "conf").getAbsolutePath(), "conf-copy"); final File target = new File(root, "conf-copy"); assertEquals(10, target.listFiles().length); final File subFolder = org.apache.openejb.loader.Files.mkdirs(new File(source, "conf.d")); for (int i = 0; i < 10; i++) { final FileWriter w = new FileWriter(new File(subFolder, "file-" + i)); w.write(Integer.toString(i)); w.close(); } Setup.synchronizeFolder(root,new File(root, "conf").getAbsolutePath(), "conf-copy2"); assertEquals(11, new File(root, "conf-copy2").listFiles().length); assertEquals(10, new File(root, "conf-copy2/conf.d").listFiles().length); }
public static void synchronizeFolder(final File tomeeHome, final String src, final String dir) { if (src != null && !src.isEmpty()) { final File confSrc = new File(src); if (confSrc.exists()) { final File conf = new File(tomeeHome, dir); final Collection<File> files = org.apache.openejb.loader.Files.collect(confSrc, TrueFilter.INSTANCE); files.remove(confSrc); for (final File f : files) { if (f.equals(confSrc) || f.getName().startsWith(".")) { continue; } final String relativize = relativize(f, confSrc); if (f.isDirectory()) { final String path = dir + '/' + relativize; Files.mkdir(new File(tomeeHome, path)); synchronizeFolder(tomeeHome, f.getAbsolutePath(), path); } else { try { final File to = new File(conf, relativize); Files.mkdir(to.getParentFile()); org.apache.openejb.loader.IO.copy(f, to); } catch (final Exception e) { LOGGER.log(Level.WARNING, "Ignoring copy of " + f.getAbsolutePath(), e); } } } } else { LOGGER.warning("Can't find " + confSrc.getAbsolutePath()); } } }
Setup { public static void synchronizeFolder(final File tomeeHome, final String src, final String dir) { if (src != null && !src.isEmpty()) { final File confSrc = new File(src); if (confSrc.exists()) { final File conf = new File(tomeeHome, dir); final Collection<File> files = org.apache.openejb.loader.Files.collect(confSrc, TrueFilter.INSTANCE); files.remove(confSrc); for (final File f : files) { if (f.equals(confSrc) || f.getName().startsWith(".")) { continue; } final String relativize = relativize(f, confSrc); if (f.isDirectory()) { final String path = dir + '/' + relativize; Files.mkdir(new File(tomeeHome, path)); synchronizeFolder(tomeeHome, f.getAbsolutePath(), path); } else { try { final File to = new File(conf, relativize); Files.mkdir(to.getParentFile()); org.apache.openejb.loader.IO.copy(f, to); } catch (final Exception e) { LOGGER.log(Level.WARNING, "Ignoring copy of " + f.getAbsolutePath(), e); } } } } else { LOGGER.warning("Can't find " + confSrc.getAbsolutePath()); } } } }
Setup { public static void synchronizeFolder(final File tomeeHome, final String src, final String dir) { if (src != null && !src.isEmpty()) { final File confSrc = new File(src); if (confSrc.exists()) { final File conf = new File(tomeeHome, dir); final Collection<File> files = org.apache.openejb.loader.Files.collect(confSrc, TrueFilter.INSTANCE); files.remove(confSrc); for (final File f : files) { if (f.equals(confSrc) || f.getName().startsWith(".")) { continue; } final String relativize = relativize(f, confSrc); if (f.isDirectory()) { final String path = dir + '/' + relativize; Files.mkdir(new File(tomeeHome, path)); synchronizeFolder(tomeeHome, f.getAbsolutePath(), path); } else { try { final File to = new File(conf, relativize); Files.mkdir(to.getParentFile()); org.apache.openejb.loader.IO.copy(f, to); } catch (final Exception e) { LOGGER.log(Level.WARNING, "Ignoring copy of " + f.getAbsolutePath(), e); } } } } else { LOGGER.warning("Can't find " + confSrc.getAbsolutePath()); } } }  }
Setup { public static void synchronizeFolder(final File tomeeHome, final String src, final String dir) { if (src != null && !src.isEmpty()) { final File confSrc = new File(src); if (confSrc.exists()) { final File conf = new File(tomeeHome, dir); final Collection<File> files = org.apache.openejb.loader.Files.collect(confSrc, TrueFilter.INSTANCE); files.remove(confSrc); for (final File f : files) { if (f.equals(confSrc) || f.getName().startsWith(".")) { continue; } final String relativize = relativize(f, confSrc); if (f.isDirectory()) { final String path = dir + '/' + relativize; Files.mkdir(new File(tomeeHome, path)); synchronizeFolder(tomeeHome, f.getAbsolutePath(), path); } else { try { final File to = new File(conf, relativize); Files.mkdir(to.getParentFile()); org.apache.openejb.loader.IO.copy(f, to); } catch (final Exception e) { LOGGER.log(Level.WARNING, "Ignoring copy of " + f.getAbsolutePath(), e); } } } } else { LOGGER.warning("Can't find " + confSrc.getAbsolutePath()); } } }  static void exportProperties(final File tomeeHome, final TomEEConfiguration c, final boolean defaultMem); static void updateServerXml(final File tomeeHome, final TomEEConfiguration configuration); static File findHome(File directory); static File findHomeImpl(final File directory); static File downloadAndUnpack(final File dir, final String artifactID, final String defaultTempDir); static File downloadFile(final String artifactName, final String altUrl, final String defaultTempDir); static boolean isRunning(final String host, final int port); static void replace(final Map<String, String> replacements, final File file, final boolean escape); static void removeUselessWebapps(final File tomeeHome, final String... exceptions); static void configureServerXml(final File tomeeHome, final TomEEConfiguration configuration); static void configureSystemProperties(final File tomeeHome, final TomEEConfiguration configuration); static void reloadClientSerializationConfig(); static void synchronizeFolder(final File tomeeHome, final String src, final String dir); static void installArquillianBeanDiscoverer(final File home); static void removeArquillianBeanDiscoverer(final File home); static Map<File, String> addTomEELibraries(final File libFolder, final String additionalLibs, final boolean parseArgs); }
Setup { public static void synchronizeFolder(final File tomeeHome, final String src, final String dir) { if (src != null && !src.isEmpty()) { final File confSrc = new File(src); if (confSrc.exists()) { final File conf = new File(tomeeHome, dir); final Collection<File> files = org.apache.openejb.loader.Files.collect(confSrc, TrueFilter.INSTANCE); files.remove(confSrc); for (final File f : files) { if (f.equals(confSrc) || f.getName().startsWith(".")) { continue; } final String relativize = relativize(f, confSrc); if (f.isDirectory()) { final String path = dir + '/' + relativize; Files.mkdir(new File(tomeeHome, path)); synchronizeFolder(tomeeHome, f.getAbsolutePath(), path); } else { try { final File to = new File(conf, relativize); Files.mkdir(to.getParentFile()); org.apache.openejb.loader.IO.copy(f, to); } catch (final Exception e) { LOGGER.log(Level.WARNING, "Ignoring copy of " + f.getAbsolutePath(), e); } } } } else { LOGGER.warning("Can't find " + confSrc.getAbsolutePath()); } } }  static void exportProperties(final File tomeeHome, final TomEEConfiguration c, final boolean defaultMem); static void updateServerXml(final File tomeeHome, final TomEEConfiguration configuration); static File findHome(File directory); static File findHomeImpl(final File directory); static File downloadAndUnpack(final File dir, final String artifactID, final String defaultTempDir); static File downloadFile(final String artifactName, final String altUrl, final String defaultTempDir); static boolean isRunning(final String host, final int port); static void replace(final Map<String, String> replacements, final File file, final boolean escape); static void removeUselessWebapps(final File tomeeHome, final String... exceptions); static void configureServerXml(final File tomeeHome, final TomEEConfiguration configuration); static void configureSystemProperties(final File tomeeHome, final TomEEConfiguration configuration); static void reloadClientSerializationConfig(); static void synchronizeFolder(final File tomeeHome, final String src, final String dir); static void installArquillianBeanDiscoverer(final File home); static void removeArquillianBeanDiscoverer(final File home); static Map<File, String> addTomEELibraries(final File libFolder, final String additionalLibs, final boolean parseArgs); static final String TOMEE_BEAN_DISCOVERER_JAR; }