Example usage for org.apache.commons.io FileUtils copyDirectory

List of usage examples for org.apache.commons.io FileUtils copyDirectory

Introduction

In this page you can find the example usage for org.apache.commons.io FileUtils copyDirectory.

Prototype

public static void copyDirectory(File srcDir, File destDir) throws IOException 

Source Link

Document

Copies a whole directory to a new location preserving the file dates.

Usage

From source file:jfix.db4o.engine.migration.Db4oToPerst.java

public static void main(String[] args) throws IOException {
    if (args.length == 0) {
        System.out.println("Database name required.");
        return;/*from  w  w w. j a  v  a 2 s .  c  o m*/
    }

    String databaseName = args[0];

    PersistenceEngine db4oEngine = new PersistenceEngineDb4o();
    db4oEngine.open(databaseName);

    ObjectDatabase db4o = new ObjectDatabase(db4oEngine);
    db4o.open();

    PersistenceEngine perstEngine = new PersistenceEnginePerst();
    perstEngine.open(databaseName);

    ObjectDatabase perst = new ObjectDatabase(perstEngine);
    perst.open();

    for (Persistent p : db4o.query(Persistent.class)) {
        perst.save(p);
    }

    FileUtils.copyDirectory(new File(db4o.getBlobDirectory() + File.separator + "blob"),
            new File(perst.getBlobDirectory() + File.separator + "blob"));

    perst.close();
    db4o.close();
}

From source file:jfix.db4o.engine.migration.PerstToDb4o.java

public static void main(String[] args) throws IOException {
    if (args.length == 0) {
        System.out.println("Database name required.");
        return;//from w  ww  .j a  v a2s  .  c  o  m
    }

    String databaseName = args[0];

    PersistenceEngine perstEngine = new PersistenceEnginePerst();
    perstEngine.open(databaseName);

    ObjectDatabase perst = new ObjectDatabase(perstEngine);
    perst.open();

    PersistenceEngine db4oEngine = new PersistenceEngineDb4o();
    db4oEngine.open(databaseName);

    ObjectDatabase db4o = new ObjectDatabase(db4oEngine);
    db4o.open();

    for (Persistent p : perst.query(Persistent.class)) {
        db4o.save(p);
    }

    FileUtils.copyDirectory(new File(perst.getBlobDirectory() + File.separator + "blob"),
            new File(db4o.getBlobDirectory() + File.separator + "blob"));

    db4o.close();
    perst.close();
}

From source file:fr.gael.dhus.database.util.RestoreDatabase.java

/**
 * @param args// www . j a va2 s.  co  m
 * @throws IllegalAccessException 
 * @throws IOException 
 */
public static void main(String[] args) throws IllegalAccessException, IOException {
    if (args.length != 2) {
        throw new IllegalArgumentException(RestoreDatabase.class.getCanonicalName()
                + ": Wrong arguments <source path> <destination path>.");
    }

    File dump = new File(args[0]);
    File db = new File(args[1]);

    logger.info("Restoring " + dump.getPath() + " into " + db.getPath() + ".");

    if (!db.exists())
        throw new IllegalArgumentException(RestoreDatabase.class.getCanonicalName()
                + ": Input database path not found (\"" + db.getPath() + "\").");

    if (!dump.exists())
        throw new IllegalArgumentException(RestoreDatabase.class.getCanonicalName()
                + ": Input database dump path not found (\"" + db.getPath() + "\").");

    FileUtils.deleteDirectory(db);
    FileUtils.copyDirectory(dump, db);

    logger.info("Dump properly restored, please restart system now.");
}

From source file:com.sangupta.keepwalking.MergeRepo.java

/**
 * @param args/*from   w ww. ja  v a 2 s.c o  m*/
 * @throws IOException 
 */
public static void main(String[] args) throws IOException {
    if (args.length != 3) {
        usage();
        return;
    }

    final String previousRepo = args[0];
    final String newerRepo = args[1];
    final String mergedRepo = args[2];

    final File previous = new File(previousRepo);
    final File newer = new File(newerRepo);
    final File merged = new File(mergedRepo);

    if (!(previous.exists() && previous.isDirectory())) {
        System.out.println("The previous version does not exists or is not a directory.");
        return;
    }

    if (!(newer.exists() && newer.isDirectory())) {
        System.out.println("The newer version does not exists or is not a directory.");
        return;
    }

    final IOFileFilter directoryFilter = FileFilterUtils.makeCVSAware(FileFilterUtils.makeSVNAware(null));

    final Collection<File> olderFiles = FileUtils.listFiles(previous, TrueFileFilter.TRUE, directoryFilter);
    final Collection<File> newerFiles = FileUtils.listFiles(newer, TrueFileFilter.TRUE, directoryFilter);

    // build a list of unique paths
    System.out.println("Reading files from older version...");
    List<String> olderPaths = new ArrayList<String>();
    for (File oldFile : olderFiles) {
        olderPaths.add(getRelativePath(oldFile, previous));
    }

    System.out.println("Reading files from newer version...");
    List<String> newerPaths = new ArrayList<String>();
    for (File newerFile : newerFiles) {
        newerPaths.add(getRelativePath(newerFile, newer));
    }

    // find which files have been removed from Perforce depot
    List<String> filesRemoved = new ArrayList<String>(olderPaths);
    filesRemoved.removeAll(newerPaths);
    System.out.println("Files removed in newer version: " + filesRemoved.size());
    for (String removed : filesRemoved) {
        System.out.print("    ");
        System.out.println(removed);
    }

    // find which files have been added in Perforce depot
    List<String> filesAdded = new ArrayList<String>(newerPaths);
    filesAdded.removeAll(olderPaths);
    System.out.println("Files added in newer version: " + filesAdded.size());
    for (String added : filesAdded) {
        System.out.print("    ");
        System.out.println(added);
    }

    // find which files are common 
    // now check if they have modified or not
    newerPaths.retainAll(olderPaths);
    List<String> modified = checkModifiedFiles(newerPaths, previous, newer);
    System.out.println("Files modified in newer version: " + modified.size());
    for (String modify : modified) {
        System.out.print("    ");
        System.out.println(modify);
    }

    // clean any previous existence of merged repo
    System.out.println("Cleaning any previous merged repositories...");
    if (merged.exists() && merged.isDirectory()) {
        FileUtils.deleteDirectory(merged);
    }

    System.out.println("Merging from newer to older repository...");
    // copy the original SVN repo to merged
    FileUtils.copyDirectory(previous, merged);

    // now remove all files that need to be
    for (String removed : filesRemoved) {
        File toRemove = new File(merged, removed);
        toRemove.delete();
    }

    // now add all files that are new in perforce
    for (String added : filesAdded) {
        File toAdd = new File(newer, added);
        File destination = new File(merged, added);
        FileUtils.copyFile(toAdd, destination);
    }

    // now over-write modified files
    for (String changed : modified) {
        File change = new File(newer, changed);
        File destination = new File(merged, changed);
        destination.delete();
        FileUtils.copyFile(change, destination);
    }

    System.out.println("Done merging.");
}

From source file:alluxio.master.backcompat.BackwardsCompatibilityJournalGenerator.java

/**
 * Generates journal files to be used by the backwards compatibility test. The files are named
 * based on the current version defined in ProjectConstants.VERSION. Run this with each release,
 * and commit the created journal and snapshot into the git repository.
 *
 * @param args no args expected//from www.  j  a v a2  s  . c  o  m
 */
public static void main(String[] args) throws Exception {
    BackwardsCompatibilityJournalGenerator generator = new BackwardsCompatibilityJournalGenerator();
    new JCommander(generator, args);
    if (!LoginUser.get().getName().equals("root")) {
        System.err.printf("Journals must be generated as root so that they can be replayed by root%n");
        System.exit(-1);
    }
    File journalDst = new File(generator.getOutputDirectory(),
            String.format("journal-%s", ProjectConstants.VERSION));
    if (journalDst.exists()) {
        System.err.printf("%s already exists, delete it first%n", journalDst.getAbsolutePath());
        System.exit(-1);
    }
    File backupDst = new File(generator.getOutputDirectory(),
            String.format("backup-%s", ProjectConstants.VERSION));
    if (backupDst.exists()) {
        System.err.printf("%s already exists, delete it first%n", backupDst.getAbsolutePath());
        System.exit(-1);
    }
    MultiProcessCluster cluster = MultiProcessCluster.newBuilder(PortCoordination.BACKWARDS_COMPATIBILITY)
            .setClusterName("BackwardsCompatibility").setNumMasters(1).setNumWorkers(1).build();
    try {
        cluster.start();
        cluster.notifySuccess();
        cluster.waitForAllNodesRegistered(10 * Constants.SECOND_MS);
        for (TestOp op : OPS) {
            op.apply(cluster.getClients());
        }
        AlluxioURI backup = cluster.getMetaMasterClient()
                .backup(new File(generator.getOutputDirectory()).getAbsolutePath(), true).getBackupUri();
        FileUtils.moveFile(new File(backup.getPath()), backupDst);
        cluster.stopMasters();
        FileUtils.copyDirectory(new File(cluster.getJournalDir()), journalDst);
    } catch (Throwable t) {
        t.printStackTrace();
    } finally {
        cluster.destroy();
    }
    System.out.printf("Artifacts successfully generated at %s and %s%n", journalDst.getAbsolutePath(),
            backupDst.getAbsolutePath());
}

From source file:de.uniwue.dmir.heatmap.EntryPointIncremental.java

@SuppressWarnings({ "rawtypes", "unchecked" })
public static void main(String[] args) throws IOException, ParseException {

    DateFormat df = new SimpleDateFormat(DATE_FORMAT);
    SimpleDateFormat backupDf = new SimpleDateFormat(BACKUP_DATE_FORMAT);

    String workDir = System.getProperty("workDir", ".");
    LOGGER.debug("Work dir: {}", workDir);
    String configDir = System.getProperty("configDir", ".");
    LOGGER.debug("Config dir: {}", configDir);

    File seedDir = new File(workDir, SEED_DIR);
    LOGGER.debug("Seed dir: {}", seedDir);
    File currentDir = new File(workDir, CURRENT_DIR);
    LOGGER.debug("Current dir: {}", currentDir);
    File backupDir = new File(workDir, BACKUP_DIR);
    LOGGER.debug("Backup dir: {}", backupDir);

    String initialMinTimeString = System.getProperty("minTime");
    LOGGER.debug("Initial minimal time parameter: {}", initialMinTimeString);
    Date initialMinTime = initialMinTimeString == null ? new Date(0) : df.parse(initialMinTimeString);
    LOGGER.debug("Initial minimal time: {}", df.format(initialMinTime));

    String absoluteMaxTimeString = System.getProperty("maxTime");
    LOGGER.debug("Absolute maximal time parameter: {}", absoluteMaxTimeString);
    Date absoluteMaxTime = absoluteMaxTimeString == null ? new Date()
            : new SimpleDateFormat(DATE_FORMAT).parse(absoluteMaxTimeString);
    LOGGER.debug("Absolute maximal time: {}", df.format(absoluteMaxTime));

    String incrementalFile = new File("file:" + configDir, INCREMENTAL_FILE).getPath();
    String settingsFile = new File("file:" + configDir, HEATMAP_PROCESSOR__FILE).getPath();

    LOGGER.debug("Initializing incremental control file: {}", incrementalFile);
    FileSystemXmlApplicationContext incrementalContext = new FileSystemXmlApplicationContext(incrementalFile);

    // get point limit
    int pointLimit = Integer
            .parseInt(incrementalContext.getBeanFactory().resolveEmbeddedValue("${point.limit}"));
    LOGGER.debug("Print limit: {}", pointLimit);

    // get backups to keep
    int backupsToKeep = Integer
            .parseInt(incrementalContext.getBeanFactory().resolveEmbeddedValue("${backups.to.keep}"));
    LOGGER.debug("Backups to keep: {}", pointLimit);

    LOGGER.debug("Initializing process components (manager and limiter).");
    IProcessManager processManager = incrementalContext.getBean(IProcessManager.class);
    IProcessLimiter processLimiter = incrementalContext.getBean(IProcessLimiter.class);

    LOGGER.debug("Starting incremental loop.");
    while (true) { // break as soon as no new points are available

        // cleanup --- just in case
        LOGGER.debug("Deleting \"current\" dir.");
        FileUtils.deleteDirectory(currentDir);

        // copy from seed to current
        LOGGER.debug("Copying seed.");
        seedDir.mkdirs();/*ww  w.ja  v  a 2s. com*/
        FileUtils.copyDirectory(seedDir, currentDir);

        // get min time
        LOGGER.debug("Getting minimal time ...");
        Date minTime = initialMinTime;
        ProcessManagerEntry entry = processManager.getEntry();
        if (entry != null && entry.getMaxTime() != null) {
            minTime = entry.getMaxTime();
        }
        LOGGER.debug("Minimal time: {}", new SimpleDateFormat(DATE_FORMAT).format(minTime));

        // break if we processed all available points (minTime is greater than or equal to absoluteMaxTime)
        if (minTime.getTime() >= absoluteMaxTime.getTime()) {
            LOGGER.debug("Processed all points.");
            break;
        }

        // get the maximal time
        LOGGER.debug("Get maximal time.");

        // get the time from the newest point in our point range (pointMaxTime) ...
        Date pointMaxTime = processLimiter.getMaxTime(minTime, pointLimit);

        // ... and possibly break the loop if no new points are available
        if (pointMaxTime == null)
            break;

        // set the max time and make sure we are not taking to many points 
        // (set max time to the minimum of pointMaxTime and absoluteMaxTime)
        Date maxTime = pointMaxTime.getTime() > absoluteMaxTime.getTime() ? absoluteMaxTime : pointMaxTime;

        LOGGER.debug("Maximal time: {}", new SimpleDateFormat(DATE_FORMAT).format(maxTime));

        // start process
        processManager.start(minTime);

        System.setProperty("minTimestamp", new SimpleDateFormat(DATE_FORMAT).format(minTime));

        System.setProperty("maxTimestamp", new SimpleDateFormat(DATE_FORMAT).format(maxTime));

        FileSystemXmlApplicationContext heatmapContext = new FileSystemXmlApplicationContext(settingsFile);

        IHeatmap heatmap = heatmapContext.getBean(HEATMAP_BEAN, IHeatmap.class);

        ITileProcessor tileProcessor = heatmapContext.getBean(WRITER_BEAN, ITileProcessor.class);

        heatmap.processTiles(tileProcessor);

        tileProcessor.close();
        heatmapContext.close();

        // finish process
        processManager.finish(maxTime);

        // move old seed
        if (backupsToKeep > 0) {
            FileUtils.moveDirectory(seedDir, new File(backupDir, backupDf.format(minTime))); // minTime is the maxTime of the seed

            // cleanup backups
            String[] backups = backupDir.list(DirectoryFileFilter.DIRECTORY);
            File oldestBackup = null;
            if (backups.length > backupsToKeep) {
                for (String bs : backups) {
                    File b = new File(backupDir, bs);
                    if (oldestBackup == null || oldestBackup.lastModified() > b.lastModified()) {
                        oldestBackup = b;
                    }
                }
                FileUtils.deleteDirectory(oldestBackup);
            }

        } else {
            FileUtils.deleteDirectory(seedDir);
        }

        // move new seed
        FileUtils.moveDirectory(currentDir, seedDir);

    }

    incrementalContext.close();

}

From source file:android.databinding.tool.MakeCopy.java

public static void main(String[] args) {
    if (args.length < 5) {
        System.out.println("required parameters: [-l] manifest adk-dir src-out-dir xml-out-dir "
                + "res-out-dir res-in-dir...");
        System.out.println("Creates an android data binding class and copies resources from");
        System.out.println("res-source to res-target and modifies binding layout files");
        System.out.println("in res-target. Binding data is extracted into XML files");
        System.out.println("and placed in xml-out-dir.");
        System.out.println("  -l          indicates that this is a library");
        System.out.println("  manifest    path to AndroidManifest.xml file");
        System.out.println("  src-out-dir path to where generated source goes");
        System.out.println("  xml-out-dir path to where generated binding XML goes");
        System.out.println("  res-out-dir path to the where modified resources should go");
        System.out.println(// w  w w .j  a  va2 s .c  o  m
                "  res-in-dir  path to source resources \"res\" directory. One" + " or more are allowed.");
        System.exit(1);
    }
    final boolean isLibrary = args[0].equals("-l");
    final int indexOffset = isLibrary ? 1 : 0;
    final String applicationPackage;
    final int minSdk;
    final Document androidManifest = readAndroidManifest(new File(args[MANIFEST_INDEX + indexOffset]));
    try {
        final XPathFactory xPathFactory = XPathFactory.newInstance();
        final XPath xPath = xPathFactory.newXPath();
        applicationPackage = xPath.evaluate("string(/manifest/@package)", androidManifest);
        final Double minSdkNumber = (Double) xPath.evaluate("number(/manifest/uses-sdk/@android:minSdkVersion)",
                androidManifest, XPathConstants.NUMBER);
        minSdk = minSdkNumber == null ? 1 : minSdkNumber.intValue();
    } catch (XPathExpressionException e) {
        e.printStackTrace();
        System.exit(6);
        return;
    }
    final File srcDir = new File(args[SRC_INDEX + indexOffset], APP_SUBPATH);
    if (!makeTargetDir(srcDir)) {
        System.err.println("Could not create source directory " + srcDir);
        System.exit(2);
    }
    final File resTarget = new File(args[RES_OUT_INDEX + indexOffset]);
    if (!makeTargetDir(resTarget)) {
        System.err.println("Could not create resource directory: " + resTarget);
        System.exit(4);
    }
    final File xmlDir = new File(args[XML_INDEX + indexOffset]);
    if (!makeTargetDir(xmlDir)) {
        System.err.println("Could not create xml output directory: " + xmlDir);
        System.exit(5);
    }
    System.out.println("Application Package: " + applicationPackage);
    System.out.println("Minimum SDK: " + minSdk);
    System.out.println("Target Resources: " + resTarget.getAbsolutePath());
    System.out.println("Target Source Dir: " + srcDir.getAbsolutePath());
    System.out.println("Target XML Dir: " + xmlDir.getAbsolutePath());
    System.out.println("Library? " + isLibrary);

    boolean foundSomeResources = false;
    for (int i = RES_IN_INDEX + indexOffset; i < args.length; i++) {
        final File resDir = new File(args[i]);
        if (!resDir.exists()) {
            System.out.println("Could not find resource directory: " + resDir);
        } else {
            System.out.println("Source Resources: " + resDir.getAbsolutePath());
            try {
                FileUtils.copyDirectory(resDir, resTarget);
                addFromFile(resDir, resTarget);
                foundSomeResources = true;
            } catch (IOException e) {
                System.err.println("Could not copy resources from " + resDir + " to " + resTarget + ": "
                        + e.getLocalizedMessage());
                System.exit(3);
            }
        }
    }

    if (!foundSomeResources) {
        System.err.println("No resource directories were found.");
        System.exit(7);
    }
    processLayoutFiles(applicationPackage, resTarget, srcDir, xmlDir, minSdk, isLibrary);
}

From source file:edu.usc.goffish.gofs.tools.GoFSFormat.java

public static void main(String[] args) throws IOException {
    if (args.length < REQUIRED_ARGS) {
        PrintUsageAndQuit(null);//w  ww.  j  a  v  a  2 s .  c o m
    }

    if (args.length == 1 && args[0].equals("-help")) {
        PrintUsageAndQuit(null);
    }

    Path executableDirectory;
    try {
        executableDirectory = Paths
                .get(GoFSFormat.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParent();
    } catch (URISyntaxException e) {
        throw new RuntimeException("Unexpected error retrieving executable location", e);
    }
    Path configPath = executableDirectory.resolve(DEFAULT_CONFIG).normalize();

    boolean copyBinaries = false;

    // parse optional arguments
    int i = 0;
    OptArgLoop: for (i = 0; i < args.length - REQUIRED_ARGS; i++) {
        switch (args[i]) {
        case "-config":
            i++;

            try {
                configPath = Paths.get(args[i]);
            } catch (InvalidPathException e) {
                PrintUsageAndQuit("Config file - " + e.getMessage());
            }

            break;
        case "-copyBinaries":
            copyBinaries = true;
            break;
        default:
            break OptArgLoop;
        }
    }

    if (args.length - i < REQUIRED_ARGS) {
        PrintUsageAndQuit(null);
    }

    // finished parsing args
    if (i < args.length) {
        PrintUsageAndQuit("Unrecognized argument \"" + args[i] + "\"");
    }

    // parse config

    System.out.println("Parsing config...");

    PropertiesConfiguration config = new PropertiesConfiguration();
    config.setDelimiterParsingDisabled(true);
    try {
        config.load(Files.newInputStream(configPath));
    } catch (ConfigurationException e) {
        throw new IOException(e);
    }

    // retrieve data nodes
    ArrayList<URI> dataNodes;
    {
        String[] dataNodesArray = config.getStringArray(GOFS_DATANODES_KEY);
        if (dataNodesArray.length == 0) {
            throw new ConversionException("Config must contain key " + GOFS_DATANODES_KEY);
        }

        dataNodes = new ArrayList<>(dataNodesArray.length);

        if (dataNodesArray.length == 0) {
            throw new ConversionException("Config key " + GOFS_DATANODES_KEY
                    + " has invalid format - must define at least one data node");
        }

        try {
            for (String node : dataNodesArray) {
                URI dataNodeURI = new URI(node);

                if (!"file".equalsIgnoreCase(dataNodeURI.getScheme())) {
                    throw new ConversionException("config key " + GOFS_DATANODES_KEY + " value \"" + dataNodeURI
                            + "\" has invalid format - data node urls must have 'file' scheme");
                } else if (dataNodeURI.getPath() == null || dataNodeURI.getPath().isEmpty()) {
                    throw new ConversionException("config key " + GOFS_DATANODES_KEY + " value \"" + dataNodeURI
                            + "\" has invalid format - data node urls must have an absolute path specified");
                }

                // ensure uri ends with a slash, so we know it is a directory
                if (!dataNodeURI.getPath().endsWith("/")) {
                    dataNodeURI = dataNodeURI.resolve(dataNodeURI.getPath() + "/");
                }

                dataNodes.add(dataNodeURI);
            }
        } catch (URISyntaxException e) {
            throw new ConversionException(
                    "Config key " + GOFS_DATANODES_KEY + " has invalid format - " + e.getMessage());
        }
    }

    // validate serializer type
    Class<? extends ISliceSerializer> serializerType;
    {
        String serializerTypeName = config.getString(GOFS_SERIALIZER_KEY);
        if (serializerTypeName == null) {
            throw new ConversionException("Config must contain key " + GOFS_SERIALIZER_KEY);
        }

        try {
            serializerType = SliceSerializerProvider.loadSliceSerializerType(serializerTypeName);
        } catch (ReflectiveOperationException e) {
            throw new ConversionException(
                    "Config key " + GOFS_SERIALIZER_KEY + " has invalid format - " + e.getMessage());
        }
    }

    // retrieve name node
    IInternalNameNode nameNode;
    try {
        nameNode = NameNodeProvider.loadNameNodeFromConfig(config, GOFS_NAMENODE_TYPE_KEY,
                GOFS_NAMENODE_LOCATION_KEY);
    } catch (ReflectiveOperationException e) {
        throw new RuntimeException("Unable to load name node", e);
    }

    System.out.println("Contacting name node...");

    // validate name node
    if (!nameNode.isAvailable()) {
        throw new IOException("Name node at " + nameNode.getURI() + " is not available");
    }

    System.out.println("Contacting data nodes...");

    // validate data nodes
    for (URI dataNode : dataNodes) {
        // only attempt ssh if host exists
        if (dataNode.getHost() != null) {
            try {
                SSHHelper.SSH(dataNode, "true");
            } catch (IOException e) {
                throw new IOException("Data node at " + dataNode + " is not available", e);
            }
        }
    }

    // create temporary directory
    Path workingDir = Files.createTempDirectory("gofs_format");
    try {
        // create deploy directory
        Path deployDirectory = Files.createDirectory(workingDir.resolve(DATANODE_DIR_NAME));

        // create empty slice directory
        Files.createDirectory(deployDirectory.resolve(DataNode.DATANODE_SLICE_DIR));

        // copy binaries
        if (copyBinaries) {
            System.out.println("Copying binaries...");
            FileUtils.copyDirectory(executableDirectory.toFile(),
                    deployDirectory.resolve(executableDirectory.getFileName()).toFile());
        }

        // write config file
        Path dataNodeConfigFile = deployDirectory.resolve(DataNode.DATANODE_CONFIG);
        try {
            // create config for every data node and scp deploy folder into place
            for (URI dataNodeParent : dataNodes) {
                URI dataNode = dataNodeParent.resolve(DATANODE_DIR_NAME);

                PropertiesConfiguration datanode_config = new PropertiesConfiguration();
                datanode_config.setDelimiterParsingDisabled(true);
                datanode_config.setProperty(DataNode.DATANODE_INSTALLED_KEY, true);
                datanode_config.setProperty(DataNode.DATANODE_NAMENODE_TYPE_KEY,
                        config.getString(GOFS_NAMENODE_TYPE_KEY));
                datanode_config.setProperty(DataNode.DATANODE_NAMENODE_LOCATION_KEY,
                        config.getString(GOFS_NAMENODE_LOCATION_KEY));
                datanode_config.setProperty(DataNode.DATANODE_LOCALHOSTURI_KEY, dataNode.toString());

                try {
                    datanode_config.save(Files.newOutputStream(dataNodeConfigFile));
                } catch (ConfigurationException e) {
                    throw new IOException(e);
                }

                System.out.println("Formatting data node " + dataNode.toString() + "...");

                // scp everything into place on the data node
                SCPHelper.SCP(deployDirectory, dataNodeParent);

                // update name node
                nameNode.addDataNode(dataNode);
            }

            // update name node
            nameNode.setSerializer(serializerType);
        } catch (Exception e) {
            System.out.println(
                    "ERROR: data node formatting interrupted - name node and data nodes are in an inconsistent state and require clean up");
            throw e;
        }

        System.out.println("GoFS format complete");

    } finally {
        FileUtils.deleteQuietly(workingDir.toFile());
    }
}

From source file:com.liferay.maven.plugins.util.FileUtil.java

public static void copyDirectory(File source, File destination) throws IOException {

    FileUtils.copyDirectory(source, destination);
}

From source file:com.liferay.cucumber.util.FileUtil.java

public static void copyDirectory(File sourceDir, File destinationDir) throws IOException {

    FileUtils.copyDirectory(sourceDir, destinationDir);
}