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:com.netflix.genie.core.services.impl.FileSystemAttachmentService.java

/**
 * {@inheritDoc}/*from  w ww.  jav a 2 s  .  c om*/
 */
@Override
public void copy(final String jobId, final File destination) throws GenieException {
    if (destination.exists() && !destination.isDirectory()) {
        throw new GeniePreconditionException(destination + " is not a directory and it needs to be.");
    }
    final File source = new File(attachmentDirectory, jobId);
    if (source.exists() && source.isDirectory()) {
        try {
            FileUtils.copyDirectory(source, destination);
        } catch (final IOException ioe) {
            throw new GenieServerException(ioe);
        }
    }
}

From source file:com.collective.celos.GetSchedulerTest.java

@Test
public void testGetScheduler() throws Exception {
    Set<WorkflowID> workflowIDs = celosClient.getWorkflowList();
    Assert.assertTrue(workflowIDs.isEmpty());

    File src = new File(Thread.currentThread().getContextClassLoader()
            .getResource("com/collective/celos/client/wf-list").toURI());
    FileUtils.copyDirectory(src, workflowsDir);

    workflowIDs = celosClient.getWorkflowList();
    Assert.assertTrue(workflowIDs.isEmpty());

    celosClient.clearCache();//  w  w  w.j av a 2  s  . c  om

    HashSet<WorkflowID> expectedResult = Sets.newHashSet(new WorkflowID("workflow-1"),
            new WorkflowID("workflow-2"), new WorkflowID("workflow-Itrntinliztin"),
            new WorkflowID("workflow-4"));
    workflowIDs = celosClient.getWorkflowList();
    Assert.assertEquals(Sets.newHashSet(workflowIDs), expectedResult);

    Scheduler scheduler = Util.requireNonNull(celosServer.getScheduler());
    Set<WorkflowID> schedWfIds = scheduler.getWorkflowConfiguration().getWorkflows().stream()
            .map(x -> x.getID()).collect(Collectors.toSet());

    Assert.assertEquals(schedWfIds, expectedResult);
}

From source file:com.netflix.genie.web.services.impl.FileSystemAttachmentService.java

/**
 * {@inheritDoc}//from   w ww. j a v a2  s .  c o m
 */
@Override
public void copy(final String jobId, final File destination) throws GenieException {
    if (destination.exists() && !destination.isDirectory()) {
        throw new GeniePreconditionException(destination + " is not a directory and it needs to be.");
    }
    final File source = new File(attachmentDirectory, jobId);
    if (source.exists() && source.isDirectory()) {
        try {
            FileUtils.copyDirectory(source, destination);
        } catch (final IOException ioe) {
            throw new GenieServerException("Failed to copy attachment directory", ioe);
        }
    }
}

From source file:de.uzk.hki.da.cb.RetrievalActionTests.java

/**
 *//*  w  w  w  .j a  v  a 2 s  . c  o  m*/
@Before
public void setUp() throws Exception {

    Package pkg1 = o.getLatestPackage();
    Package pkg2 = new Package();
    pkg2.setDelta(2);
    Package pkg3 = new Package();
    pkg3.setDelta(3);
    o.getPackages().add(pkg2);
    o.getPackages().add(pkg3);

    n.setWorkAreaRootPath(workAreaRootPath);
    n.setUserAreaRootPath(userAreaRootPath);

    FileUtils.copyDirectory(
            Path.makeFile(workAreaRootPath, "work", o.getContractor().getShort_name(), "_" + TC.IDENTIFIER),
            Path.makeFile(workAreaRootPath, "work", o.getContractor().getShort_name(), TC.IDENTIFIER));
    Path.makeFile(outgoingFolder).mkdirs();

    pkg1.scanRepRecursively(dataPath, "1+a");
    pkg1.scanRepRecursively(dataPath, "1+b");
    pkg2.scanRepRecursively(dataPath, "2+a");
    pkg2.scanRepRecursively(dataPath, "2+b");
    pkg3.scanRepRecursively(dataPath, "3+a");
    pkg3.scanRepRecursively(dataPath, "3+b");
}

From source file:com.theelix.libreexplorer.FileManager.java

private static void paste(File sourceFile, File destFile) throws IOException, FileNotCreatedException {
    try {// w  ww .  j a  v  a 2s  . c  o m
        if (sourceFile.isDirectory()) {

            FileUtils.copyDirectory(sourceFile, destFile);
        } else {
            FileUtils.copyFile(sourceFile, destFile);
        }
        if (isMoving) {
            if (sourceFile.isDirectory()) {
                FileUtils.deleteDirectory(sourceFile);
            } else {
                sourceFile.delete();
            }
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        throw new FileNotCreatedException();
    }
}

From source file:de.uzk.hki.da.cb.UnpackActionTests.java

/**
 * Sets the up./*from w w  w  .  j  a  v a  2  s.com*/
 * @throws IOException Signals that an I/O exception has occurred.
 */
@Before
public void setUp() throws IOException {
    n.setIngestAreaRootPath(ingestAreaRootPath);
    n.setWorkAreaRootPath(workAreaRootPath);

    new File(CONF).mkdir();
    FileUtils.copyDirectory(Path.makeFile(workAreaRootPath, "ingest_"),
            Path.makeFile(workAreaRootPath, "ingest"));
    FileUtils.copyFileToDirectory(C.PREMIS_XSD_TEST, new File(CONF));
    FileUtils.copyFileToDirectory(C.XLINK_XSD_TEST, new File(CONF));
    FileUtils.copyFileToDirectory(C.CONTRACT_XSD_TEST, new File(CONF));

    gate.setWorkAreaRootPath(workAreaRootPath.toString());
    gate.setFreeDiskSpacePercent(5);
    gate.setFileSizeFactor(3);
    action.setIngestGate(gate);

    this.o.getContractor().setFriendlyFileExtensions(SIDECAR_EXTENSIONS);
}

From source file:de.egore911.versioning.deployer.performer.PerformCheckout.java

private static void performGit(String target, String url) {
    String tmp = target + File.separatorChar + "checkout";
    try {/*from w w  w.  j  a  va 2  s.  co m*/
        File tmpDir = new File(tmp);
        try {
            if (!new File(tmp + "/.git").exists()) {
                Git.cloneRepository().setURI(url).setDirectory(tmpDir).call();
            } else {
                FileRepository fileRepository = new FileRepository(tmp + "/.git");
                Git git = new Git(fileRepository);
                git.pull().setRebase(true).call();
            }
            FileUtils.copyDirectory(tmpDir, new File(target));
        } finally {
            FileUtils.deleteDirectory(tmpDir);
        }
    } catch (GitAPIException | IOException e) {
        LOG.error(e.getMessage(), e);
    }
}

From source file:kr.co.leem.system.FileSystemUtils.java

/**
 *  .//from ww w .j  a  v  a 2s  .c om
 *
 * @param srcDir ?  .
 * @param destDir   .
 * @see FileUtils#copyDirectory(File, File)
 */
public static void copyDirectory(final String srcDir, final String destDir) {
    processIO(new IOCallback<Object>() {
        public Object doInProcessIO() throws IOException, NullPointerException {
            FileUtils.copyDirectory(new File(srcDir), new File(destDir));
            return null;
        }
    });
}

From source file:hudson.plugins.jobConfigHistory.ConfigInfoCollectorTest.java

/**
 * Test of collect method, of class ConfigInfoCollector.
 *//*  w  w  w .j ava 2  s  .c o  m*/
@Test
public void testCollectOther() throws Exception {
    FileUtils.copyDirectory(unpackResourceZip.getResource("config-history/jobs/Test1"),
            unpackResourceZip.getResource("config-history/jobs/Test2"));
    assertThatRootFolderHasYItemsOfTypeZ(13, "other");
}

From source file:com.virtusa.isq.vtaf.report.reporter.Reporter.java

/**
 * Copy report helper files.// w  ww. j a  v a2  s . com
 *
 * @param reportFolderStr the report folder str
 */
private void copyReportHelperFiles(final String reportFolderStr) {
    File reportTemplateHtml = new File(new File(
            "src" + File.separator + "main" + File.separator + "resources" + File.separator + "ReportTemplate")
                    .getAbsolutePath());
    /*File reportTemplateHtml =
        new File(new File("ReportTemplate").getAbsolutePath());*/
    File reportFolder = new File(reportFolderStr);
    try {
        FileUtils.copyDirectory(reportTemplateHtml, reportFolder);
    } catch (IOException e) {
        e.printStackTrace();
    }
}