List of usage examples for org.apache.commons.io FileUtils deleteDirectory
public static void deleteDirectory(File directory) throws IOException
From source file:azkaban.execapp.FlowPreparerTest.java
@After public void tearDown() throws Exception { FileUtils.deleteDirectory(executionsDir); FileUtils.deleteDirectory(projectsDir); }
From source file:edu.stanford.slac.archiverappliance.PlainPB.PlainPBFileNameUtilityTest.java
@After public void tearDown() throws Exception { File rootFolder = new File(rootFolderStr); FileUtils.deleteDirectory(rootFolder); }
From source file:com.telefonica.euro_iaas.sdc.puppetwrapper.services.impl.GitCloneServiceImpl.java
public void download(String url, String moduleName) throws ModuleDownloaderException { // prepare a new folder for the cloned repository File localPath = new File(modulesCodeDownloadPath + moduleName); localPath.delete();/* www.j av a 2s .co m*/ try { FileUtils.deleteDirectory(localPath); } catch (IOException e) { throw new ModuleDownloaderException(e); } // then clone logger.debug("Cloning from " + url + " to " + localPath); try { Git.cloneRepository().setURI(url).setDirectory(localPath).call(); } catch (InvalidRemoteException e) { throw new ModuleDownloaderException(e); } catch (TransportException e) { throw new ModuleDownloaderException(e); } catch (GitAPIException e) { throw new ModuleDownloaderException(e); } // now open the created repository FileRepositoryBuilder builder = new FileRepositoryBuilder(); Repository repository; try { repository = builder.setGitDir(localPath).readEnvironment() // scan environment GIT_* variables .findGitDir() // scan up the file system tree .build(); } catch (IOException e) { throw new ModuleDownloaderException(e); } logger.debug("Having repository: " + repository.getDirectory()); repository.close(); }
From source file:de.uzk.hki.da.cb.DeleteObjectAction.java
@Override public boolean implementation() throws FileNotFoundException, IOException, UserException { if (object.getPackages().size() == 1) { logger.info("Deleting object from database"); DELETEOBJECT = true;/*w w w. j a v a 2 s . com*/ } else if (object.getPackages().size() > 1) { object.getPackages().remove(object.getLatestPackage()); } logger.info("Deleting object from WorkArea: " + object.getPath()); FileUtils.deleteDirectory(object.getPath().toFile()); File fileInWorkArea = Path.makeFile(object.getTransientNodeRef().getWorkAreaRootPath(), "work", object.getContractor().getShort_name(), object.getLatestPackage().getContainerName()); if (fileInWorkArea.exists()) { logger.info("Delete latest package from WorkArea: " + fileInWorkArea); fileInWorkArea.delete(); } File fileInIngestArea = Path.makeFile(object.getTransientNodeRef().getIngestAreaRootPath(), object.getContractor().getShort_name(), object.getLatestPackage().getContainerName()); if (fileInIngestArea.exists()) { logger.info("Delete latest package from WorkArea: " + fileInIngestArea); fileInIngestArea.delete(); } return true; }
From source file:io.druid.storage.azure.AzureDataSegmentPuller.java
public com.metamx.common.FileUtils.FileCopyResult getSegmentFiles(final String containerName, final String blobPath, final File outDir) throws SegmentLoadingException { prepareOutDir(outDir);//from w ww . java 2 s . co m try { final ByteSource byteSource = new AzureByteSource(azureStorage, containerName, blobPath); final com.metamx.common.FileUtils.FileCopyResult result = CompressionUtils.unzip(byteSource, outDir, AzureUtils.AZURE_RETRY, true); log.info("Loaded %d bytes from [%s] to [%s]", result.size(), blobPath, outDir.getAbsolutePath()); return result; } catch (IOException e) { try { FileUtils.deleteDirectory(outDir); } catch (IOException ioe) { log.warn(ioe, "Failed to remove output directory [%s] for segment pulled from [%s]", outDir.getAbsolutePath(), blobPath); } throw new SegmentLoadingException(e, e.getMessage()); } }
From source file:com.github.joshelser.accumulo.DelimitedIngestMiniClusterTest.java
@BeforeClass public static void startMiniCluster() throws Exception { File targetDir = new File(System.getProperty("user.dir"), "target"); File macDir = new File(targetDir, DelimitedIngestMiniClusterTest.class.getSimpleName() + "_cluster"); if (macDir.exists()) { FileUtils.deleteDirectory(macDir); }//from www.ja v a 2s .com MiniAccumuloConfigImpl config = new MiniAccumuloConfigImpl(macDir, ROOT_PASSWORD); config.setNumTservers(1); config.setInstanceName(INSTANCE_NAME); config.setSiteConfig(Collections.singletonMap("fs.file.impl", RawLocalFileSystem.class.getName())); config.useMiniDFS(true); MAC = new MiniAccumuloClusterImpl(config); MAC.start(); FS = FileSystem.get(MAC.getMiniDfs().getConfiguration(0)); ARGS = new DelimitedIngestArguments(); ARGS.setUsername("root"); ARGS.setPassword(ROOT_PASSWORD); ARGS.setInstanceName(INSTANCE_NAME); ARGS.setZooKeepers(MAC.getZooKeepers()); ARGS.setConfiguration(MAC.getMiniDfs().getConfiguration(0)); }
From source file:edu.ku.brc.helpers.ZipFileHelper.java
/** * Removes any temp files that were created while unzipping. *//*w w w .j a v a2s .c om*/ public void cleanUp() { for (File dir : dirsToRemoveList) { try { if (dir.exists()) { FileUtils.deleteDirectory(dir); } } catch (IOException ex) { System.err.println(ex); } } }
From source file:com.seleniumtests.ut.driver.TestDriverExtractor.java
@BeforeMethod(groups = { "ut" }) public void deleteTmpDir() throws IOException { // clean output directory for (int i = 0; i < 5; i++) { try {// ww w. j a v a2 s .c o m FileUtils.deleteDirectory(driverPath.toFile()); break; } catch (IOException e) { WaitHelper.waitForSeconds(2); } } }
From source file:com.romanenco.gitt.git.GitHelper.java
/** * Clone remote HTTP/S repo to local file system. * //from w w w. ja v a 2 s . c o m * @param url * @param localPath * @param user * @param password * @throws GitError */ public static void clone(String url, String localPath, String user, String password, ProgressMonitor monitor) throws GitError { Log.d(TAG, "Cloning: " + url); CloneCommand clone = Git.cloneRepository(); clone.setTimeout(30); // set time out for bad servers clone.setURI(url); clone.setDirectory(new File(localPath)); if ((user != null) && (password != null)) { UsernamePasswordCredentialsProvider access = new UsernamePasswordCredentialsProvider(user, password); clone.setCredentialsProvider(access); } if (monitor != null) { clone.setProgressMonitor(monitor); } try { FileUtils.deleteDirectory(new File(localPath)); clone.call(); return; } catch (InvalidRemoteException e) { Log.e(TAG, "InvalidRemote", e); GittApp.saveErrorTrace(e); throw new NotGitRepoError(); } catch (TransportException e) { String trace = GittApp.saveErrorTrace(e); if (trace.indexOf("not authorized") != -1) { Log.e(TAG, "Auth", e); throw new AuthFailError(); } Log.e(TAG, "Transport", e); throw new ConnectionError(); } catch (GitAPIException e) { Log.e(TAG, "GitApi", e); GittApp.saveErrorTrace(e); } catch (IOException e) { Log.e(TAG, "IO", e); GittApp.saveErrorTrace(e); } catch (JGitInternalException e) { Log.e(TAG, "GitInternal", e); GittApp.saveErrorTrace(e); if (e.getCause() instanceof NotSupportedException) { throw new ConnectionError(); } else { throw new GitError(); } } throw new GitError(); }
From source file:com.linkedin.pinot.tools.admin.command.StartZookeeperCommand.java
@Override public void cleanup() { if (_tmpdir != null) { try {/*www . j a v a2s . c o m*/ FileUtils.deleteDirectory(_tmpdir); } catch (IOException e) { // Nothing to do right now. } } }