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

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

Introduction

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

Prototype

public static void cleanDirectory(File directory) throws IOException 

Source Link

Document

Cleans a directory without deleting it.

Usage

From source file:co.runrightfast.vertx.orientdb.impl.embedded.EmbeddedOrientDBServiceWithSSLTest.java

@BeforeClass
public static void setUpClass() throws Exception {
    orientdbHome.mkdirs();//from   w w  w.j  a v a2 s. c  o m
    FileUtils.cleanDirectory(orientdbHome);
    FileUtils.deleteDirectory(orientdbHome);
    log.logp(INFO, CLASS_NAME, "setUpClass",
            String.format("orientdbHome.exists() = %s", orientdbHome.exists()));

    final File configDirSrc = new File("src/test/resources/orientdb/config");
    final File configDirTarget = new File(orientdbHome, "config");
    FileUtils.copyFileToDirectory(new File(configDirSrc, "default-distributed-db-config.json"),
            configDirTarget);
    FileUtils.copyFileToDirectory(new File(configDirSrc, "hazelcast.xml"), configDirTarget);

    final File configCertDirSrc = new File("src/test/resources/orientdb/config/cert");
    final File configCertDirTarget = new File(orientdbHome, "config/cert");
    FileUtils.copyDirectory(configCertDirSrc, configCertDirTarget);

    final ApplicationId appId = ApplicationId.builder().group("co.runrightfast")
            .name("runrightfast-vertx-orientdb").version("1.0.0").build();
    final AppEventLogger appEventLogger = new AppEventJDKLogger(appId);

    final EmbeddedOrientDBServiceConfig config = EmbeddedOrientDBServiceConfig.builder()
            .orientDBRootDir(orientdbHome.toPath()).handler(new OGraphServerHandlerConfig())
            .handler(EmbeddedOrientDBServiceWithSSLTest::oHazelcastPlugin)
            .handler(EmbeddedOrientDBServiceWithSSLTest::oServerSideScriptInterpreter)
            .networkConfig(oServerNetworkConfiguration())
            .user(new OServerUserConfiguration(ROOT_USER, "root", "*"))
            .property(OGlobalConfiguration.DB_POOL_MIN, "1").property(OGlobalConfiguration.DB_POOL_MAX, "50")
            .databasePoolConfig(new OrientDBPoolConfig(CLASS_NAME, "remote:localhost/" + CLASS_NAME, "admin",
                    "admin", 10, ImmutableSet.of(() -> new SetCreatedOnAndUpdatedOn())))
            .lifecycleListener(() -> new RunRightFastOrientDBLifeCycleListener(appEventLogger)).build();

    service = new EmbeddedOrientDBService(config);
    ServiceUtils.start(service);
    initDatabase();
}

From source file:co.runrightfast.vertx.orientdb.impl.embedded.EmbeddedOrientDBServiceWithSSLWithClientAuthTest.java

@BeforeClass
public static void setUpClass() throws Exception {
    orientdbHome.mkdirs();/*from ww  w . j a v  a 2  s . c om*/
    FileUtils.cleanDirectory(orientdbHome);
    FileUtils.deleteDirectory(orientdbHome);
    log.logp(INFO, CLASS_NAME, "setUpClass",
            String.format("orientdbHome.exists() = %s", orientdbHome.exists()));

    final File configDirSrc = new File("src/test/resources/orientdb/config");
    final File configDirTarget = new File(orientdbHome, "config");
    FileUtils.copyFileToDirectory(new File(configDirSrc, "default-distributed-db-config.json"),
            configDirTarget);
    FileUtils.copyFileToDirectory(new File(configDirSrc, "hazelcast.xml"), configDirTarget);

    final File configCertDirSrc = new File("src/test/resources/orientdb/config/cert");
    final File configCertDirTarget = new File(orientdbHome, "config/cert");
    FileUtils.copyDirectory(configCertDirSrc, configCertDirTarget);

    final ApplicationId appId = ApplicationId.builder().group("co.runrightfast")
            .name("runrightfast-vertx-orientdb").version("1.0.0").build();
    final AppEventLogger appEventLogger = new AppEventJDKLogger(appId);

    setSSLSystemProperties();
    final EmbeddedOrientDBServiceConfig config = EmbeddedOrientDBServiceConfig.builder()
            .orientDBRootDir(orientdbHome.toPath()).handler(new OGraphServerHandlerConfig(false))
            .handler(EmbeddedOrientDBServiceWithSSLWithClientAuthTest::oHazelcastPlugin)
            .handler(EmbeddedOrientDBServiceWithSSLWithClientAuthTest::oServerSideScriptInterpreter)
            .networkConfig(oServerNetworkConfiguration())
            .user(new OServerUserConfiguration(ROOT_USER, "root", "*"))
            .property(OGlobalConfiguration.DB_POOL_MIN, "1").property(OGlobalConfiguration.DB_POOL_MAX, "50")
            .databasePoolConfig(new OrientDBPoolConfig(CLASS_NAME, "remote:localhost/" + CLASS_NAME, "admin",
                    "admin", 10, ImmutableSet.of(() -> new SetCreatedOnAndUpdatedOn())))
            .lifecycleListener(() -> new RunRightFastOrientDBLifeCycleListener(appEventLogger)).build();

    service = new EmbeddedOrientDBService(config);
    ServiceUtils.start(service);
    initDatabase();
}

From source file:edu.uci.ics.hyracks.hdfs.dataflow.DataflowTest.java

@Override
public void setUp() throws Exception {
    cleanupStores();//  w  w w  . j  a v  a2s  . c o  m
    HyracksUtils.init();
    FileUtils.forceMkdir(new File(ACTUAL_RESULT_DIR));
    FileUtils.cleanDirectory(new File(ACTUAL_RESULT_DIR));
    startHDFS();
}

From source file:edu.uci.ics.pregelix.example.dataload.DataLoadTest.java

public void setUp() throws Exception {
    ClusterConfig.setStorePath(PATH_TO_CLUSTER_STORE);
    ClusterConfig.setClusterPropertiesPath(PATH_TO_CLUSTER_PROPERTIES);
    cleanupStores();/*from ww w.jav a 2  s. c  om*/
    PregelixHyracksIntegrationUtil.init();
    LOGGER.info("Hyracks mini-cluster started");
    startHDFS();
    FileUtils.forceMkdir(new File(EXPECT_RESULT_DIR));
    FileUtils.forceMkdir(new File(ACTUAL_RESULT_DIR));
    FileUtils.cleanDirectory(new File(EXPECT_RESULT_DIR));
    FileUtils.cleanDirectory(new File(ACTUAL_RESULT_DIR));
    giraphTestJobGen = new JobGenOuterJoin(job);
}

From source file:io.ucoin.ucoinj.core.client.TestResource.java

protected void initI18n() throws IOException {
    Configuration config = Configuration.instance();

    // --------------------------------------------------------------------//
    // init i18n//w ww  .j ava2 s.co  m
    // --------------------------------------------------------------------//
    File i18nDirectory = new File(config.getDataDirectory(), "i18n");
    if (i18nDirectory.exists()) {
        // clean i18n cache
        FileUtils.cleanDirectory(i18nDirectory);
    }

    FileUtils.forceMkdir(i18nDirectory);

    if (log.isDebugEnabled()) {
        log.debug("I18N directory: " + i18nDirectory);
    }

    Locale i18nLocale = config.getI18nLocale();

    if (log.isInfoEnabled()) {
        log.info(String.format("Starts i18n with locale [%s] at [%s]", i18nLocale, i18nDirectory));
    }
    I18n.init(new UserI18nInitializer(i18nDirectory, new DefaultI18nInitializer(getI18nBundleName())),
            i18nLocale);
}

From source file:com.groupcdg.maven.tidesdk.GenerateMojoTest.java

@Test
public void testCustomSettingsGeneration() throws Exception {
    File target = new File(CUSTOM_SETTINGS_PROJECT, "target");
    if (target.exists())
        FileUtils.cleanDirectory(target);

    rule.configureMojo(new GenerateMojo(), PLUGIN_NAME, pom(CUSTOM_SETTINGS_PROJECT));
    rule.executeMojo(CUSTOM_SETTINGS_PROJECT, GENERATE_GOAL);

    assertIncluded(config(CUSTOM_SETTINGS_PROJECT, "manifest"), "appname: Custom_Settings_Project",
            "publisher: Computing Distribution Group Ltd.", "url: http://groupcdg.com/CustomSettingsProject",
            "image: img/icon.png");
    assertIncluded(config(CUSTOM_SETTINGS_PROJECT, "tiapp.xml"), "<name>Custom Settings Project</name>",
            "<copyright>" + thisYear() + " Computing Distribution Group Ltd.</copyright>",
            "<icon>img/icon.png</icon>", "<width>1024</width>", "<height>768</height>",
            "<resizable>false</resizable>");
}

From source file:com.amazonaws.codepipeline.jenkinsplugin.DownloadCallable.java

private void clearWorkspaceIfSelected(final File workspace, final TaskListener listener) {
    if (clearWorkspace) {
        try {/*  w w w  .  j  a  v a2 s.  c  om*/
            LoggingHelper.log(listener, "Clearing workspace '%s' before download", workspace.getAbsolutePath());
            FileUtils.cleanDirectory(workspace);
        } catch (final IOException ex) {
            LoggingHelper.log(listener, "Unable to clear workspace: %s", ex.getMessage());
        }
    }
}

From source file:com.pason.plugins.artifactorypolling.CheckoutTask.java

/**
 * Function that does the heavy lifting of the checkout. First it gets the metadata about
 * an artifact which includes all the files that are included in that artifact. Then it 
 * proceeds to download each of those files.
 * @param workspace The file where the downloads will go to
 * @param channel The channel back to the job
 * @return True if successful, false otherwise
 * @throws IOException/*from  w  ww.  ja  v  a 2 s .c  om*/
 * @throws InterruptedException
 */
public Boolean invoke(File workspace, VirtualChannel channel) throws IOException, InterruptedException {
    if (doDownload) {
        // Delete any artifacts of previous builds
        File checkoutDir = new File(workspace, localDirectory);
        checkoutDir.mkdirs();
        FileUtils.cleanDirectory(checkoutDir);

        ArtifactoryAPI api = new ArtifactoryAPI(artifactoryURL);
        JSONArray json = api.getArtifactFiles(repo, groupID, artifactID, artifact.getVersion());

        String groupURLPart = groupID.replace('.', '/');
        for (int i = 0; i < json.size(); i++) {
            String uri = json.getString(i);
            LOGGER.log(FINE, "Found child URI: " + uri);
            String resourceURL = artifactoryURL + repo + '/' + groupURLPart + '/' + artifactID + '/'
                    + artifact.getVersion() + '/' + uri;
            LOGGER.log(FINE, "Starting download of " + uri);
            FileUtils.copyURLToFile(new URL(resourceURL), new File(checkoutDir, uri));
            LOGGER.log(FINE, "Finished downloading: " + uri);
        }
    }

    return true;
}

From source file:com.orange.ocara.model.export.AuditExportService.java

private void createAndCleanup(File workingDir) throws IOException {
    workingDir.mkdirs();
    FileUtils.cleanDirectory(workingDir);
}

From source file:ch.admin.suis.msghandler.signer.SignerTest.java

private void cleanOutboxes() throws IOException {
    FileUtils.cleanDirectory(signingOutbox1);
    FileUtils.cleanDirectory(signingOutbox2);
    FileUtils.cleanDirectory(signingOutbox1Processed);
}