List of usage examples for org.apache.commons.io FileUtils cleanDirectory
public static void cleanDirectory(File directory) throws IOException
From source file:org.act.index.server.MetaService.java
public int createCoreWithNoSegment(int coreId) { // TODO Auto-generated method stub try {/*from ww w.j a v a 2s .c o m*/ if (indexServer.getSolrServers().containsKey(coreId)) return GlobalMessage.ISS_ERROR; String dir = indexServer.getUrl() + "/core" + String.valueOf(coreId); //LOG.debug("dir:" + dir); indexServer.addSolrServer(coreId); FileUtils.forceMkdir(new File(dir)); FileUtils.forceMkdir(new File(dir + "/conf")); String configPath = dir + "/conf/solrconfig.xml"; String schemaPath = dir + "/conf/schema.xml"; createSolrConfig(configPath); createSchema(schemaPath, coreId); //indexServer.addSolrServer(coreId); //CoreAdminRequest.createCore(String.valueOf(coreId), "core" // + String.valueOf(coreId), indexServer.getSolrServer()); CoreAdminRequest.createCore(String.valueOf(coreId), "core" + String.valueOf(coreId), indexServer.getSolrServer()); //CoreAdminRequest.createCore("10", "core10", server, configPath, schemaPath); //FileUtils.forceMkdir(new File(dir + "/data")); //FileUtils.forceMkdir(new File(dir + "/data/index")); FileUtils.cleanDirectory(new File(dir + "/data/index")); SolrService service = new SolrService(indexServer.getSolrServer(coreId)); //solrServices.put(coreId, service); //int port = ServerParam.LOCAL_SERVER_PORT + serverId * ServerParam.MAX_CORE_COUNT_PER_SERVER + coreId + 1; int serverId = indexServer.getServerInfo().getServerId(); String ip = Inet4Address.getLocalHost().getHostAddress(); int port = indexServer.getServerAddr().getPort() + coreId + 1; LocateRegistry.createRegistry(port); String name = "rmi://" + ip + ":" + port + "/core" + coreId + "@server" + serverId; Naming.rebind(name, service); LOG.info("rmi:solrserver( " + name + ") is ready!"); } catch (SolrServerException e) { // TODO: handle exception e.printStackTrace(); } catch (IOException e) { // TODO: handle exception e.printStackTrace(); } return GlobalMessage.ISS_SUCCESS; }
From source file:org.ado.biblio.install.InstallPresenter.java
private void cleanDirectory(File directory) { LOGGER.info("clean directory [{}]", directory.getAbsoluteFile()); try {//from ww w . ja v a 2 s . c o m FileUtils.cleanDirectory(directory); } catch (IOException e) { LOGGER.error(String.format("Cannot clean directory \"%s\".", directory), e); e.printStackTrace(); } }
From source file:org.ado.minesync.minecraft.MinecraftUtils.java
/** * Retrieves the local world directory for the given <code>zipFilename</code>. * * @param zipFilename the zip file's name. * @return the world's directory./*w w w .j a v a 2s . co m*/ * @throws java.io.IOException if the directory can't be clear or created. * @since 1.2.0 */ public static File getWorldDirectory(String zipFilename) throws IOException { File outputDir = new File(MINECRAFT_WORLDS, getDirectoryName(zipFilename)); if (outputDir.exists()) { FileUtils.cleanDirectory(outputDir); } else { ALog.i(TAG, "Create new world directory [" + outputDir.getName() + "]."); FileUtils.forceMkdir(outputDir); } return outputDir; }
From source file:org.ado.minesync.minecraft.MinecraftWorldManager.java
private File getWorldDirectory(String filename) throws MineSyncException { try {//from w w w. j a va 2 s .c o m File outputDir = new File(MINECRAFT_WORLDS, getDirectoryName(filename)); if (outputDir.exists()) { FileUtils.cleanDirectory(outputDir); } else { ALog.i(TAG, "Create new world directory [%s].", outputDir.getName()); FileUtils.forceMkdir(outputDir); } return outputDir; } catch (IOException e) { throw new MineSyncException("Unable to retrieve local world directory for file \"" + filename + "\".", e); } }
From source file:org.alfresco.repo.content.caching.cleanup.CachedContentCleanupJobTest.java
@Before public void setUp() throws IOException { cachingStore = (CachingContentStore) ctx.getBean("cachingContentStore"); cache = (ContentCacheImpl) ctx.getBean("contentCache"); cacheRoot = cache.getCacheRoot();//from ww w. ja v a 2 s.c o m cleaner = (CachedContentCleaner) ctx.getBean("cachedContentCleaner"); cleaner.setMinFileAgeMillis(0); cleaner.setMaxDeleteWatchCount(0); // Clear the cache from disk and memory cache.removeAll(); FileUtils.cleanDirectory(cacheRoot); }
From source file:org.alfresco.repo.content.caching.quota.StandardQuotaStrategyTest.java
@Before public void setUp() throws Exception { store = (CachingContentStore) ctx.getBean("cachingContentStore"); store.setCacheOnInbound(true);//from w ww . ja v a 2 s . co m cache = (ContentCacheImpl) ctx.getBean("contentCache"); cacheRoot = cache.getCacheRoot(); quota = (StandardQuotaStrategy) ctx.getBean("quotaManager"); quota.setCurrentUsageBytes(0); // No file size limit quota.setMaxFileSizeMB(0); cleaner = (CachedContentCleaner) ctx.getBean("cachedContentCleaner"); // Empty the in-memory cache cache.removeAll(); FileUtils.cleanDirectory(cacheRoot); }
From source file:org.ancoron.osgi.test.glassfish.GlassfishHelper.java
public static void configureGlassfish(final String installPath) throws IOException { final File domainDir = getDomainDir(); if (!domainDir.exists()) { log.log(Level.INFO, "Preparing GlassFish domain: {0}", domainDir.getCanonicalPath()); domainDir.mkdirs();// ww w . jav a2s.co m File orig = new File(installPath, "glassfish3/glassfish/domains/domain1"); FileUtils.copyDirectory(orig, domainDir, false); File tmp = new File(domainDir, "applications"); if (tmp.exists()) { FileUtils.cleanDirectory(tmp); } tmp = new File(domainDir, "generated"); if (tmp.exists()) { FileUtils.cleanDirectory(tmp); } tmp = new File(domainDir, "osgi-cache"); if (tmp.exists()) { FileUtils.cleanDirectory(tmp); } tmp = new File(domainDir, "logs"); if (tmp.exists()) { FileUtils.cleanDirectory(tmp); } File config = getDomainDirOverlay(); if (config != null) { FileUtils.copyDirectory(config, domainDir, false); } } else { log.log(Level.INFO, "Reusing existing GlassFish domain at: {0}", domainDir.getCanonicalPath()); } System.setProperty("com.sun.aas.instanceRoot", domainDir.getCanonicalPath()); }
From source file:org.apache.activemq.broker.region.cursors.KahaDBPendingMessageCursorTest.java
@Override protected void setUpBroker(boolean clearDataDir) throws Exception { if (clearDataDir && dataFileDir.getRoot().exists()) FileUtils.cleanDirectory(dataFileDir.getRoot()); super.setUpBroker(clearDataDir); }
From source file:org.apache.activemq.store.kahadb.MultiKahaDBMessageStoreSizeTest.java
@Override protected void createStore(boolean deleteAllMessages, String directory) throws Exception { MultiKahaDBPersistenceAdapter multiStore = new MultiKahaDBPersistenceAdapter(); store = multiStore;//www. j av a2 s.co m File fileDir = new File(directory); if (deleteAllMessages && fileDir.exists()) { FileUtils.cleanDirectory(new File(directory)); } KahaDBPersistenceAdapter localStore = new KahaDBPersistenceAdapter(); localStore.setJournalMaxFileLength(1024 * 512); localStore.setDirectory(new File(directory)); FilteredKahaDBPersistenceAdapter filtered = new FilteredKahaDBPersistenceAdapter(); filtered.setPersistenceAdapter(localStore); filtered.setPerDestination(true); List<FilteredKahaDBPersistenceAdapter> stores = new ArrayList<>(); stores.add(filtered); multiStore.setFilteredPersistenceAdapters(stores); multiStore.setDirectory(fileDir); multiStore.start(); messageStore = store.createQueueMessageStore(destination); messageStore.start(); }
From source file:org.apache.drill.exec.expr.fn.FunctionImplementationRegistry.java
/** * Creates local udf directory, if it doesn't exist. * Checks if local udf directory is a directory and if current application has write rights on it. * Attempts to clean up local udf directory in case jars were left after previous drillbit run. * Local udf directory path is concatenated from drill temporary directory and ${drill.exec.udf.directory.local}. * * @param config drill config/* w ww .j a v a 2 s. c o m*/ * @return path to local udf directory */ private Path getLocalUdfDir(DrillConfig config) { tmpDir = getTmpDir(config); File udfDir = new File(tmpDir, config.getString(ExecConstants.UDF_DIRECTORY_LOCAL)); udfDir.mkdirs(); String udfPath = udfDir.getPath(); Preconditions.checkState(udfDir.exists(), "Local udf directory [%s] must exist", udfPath); Preconditions.checkState(udfDir.isDirectory(), "Local udf directory [%s] must be a directory", udfPath); Preconditions.checkState(udfDir.canWrite(), "Local udf directory [%s] must be writable for application user", udfPath); try { FileUtils.cleanDirectory(udfDir); } catch (IOException e) { throw new DrillRuntimeException("Error during local udf directory clean up", e); } return new Path(udfDir.toURI()); }