List of usage examples for org.apache.commons.io FileUtils cleanDirectory
public static void cleanDirectory(File directory) throws IOException
From source file:org.duracloud.syncui.service.SyncConfigurationManagerImpl.java
@Override public void purgeWorkDirectory() { try {// w w w. ja v a 2s. c o m FileUtils.cleanDirectory(SyncUIConfig.getWorkDir()); } catch (IOException e) { log.error("Unable to clean work directory due to: " + e.getMessage()); } }
From source file:org.easycloud.las.core.util.Files.java
/** * Remove all subdirectories for a given directory * * @param rootDir the directory where we start */// w ww . ja v a 2 s . co m public static void deleteSubdirectories(String rootDir) { try { File in = new File(rootDir); FileUtils.cleanDirectory(in); } catch (Exception e) { if (LOGGER.isErrorEnabled()) { LOGGER.error(e.getMessage(), e); } throw new FileOperationsException(e); } }
From source file:org.ebayopensource.turmeric.eclipse.buildsystem.utils.ActionUtil.java
/** * Clean project.// ww w .j a va 2 s .c o m * * @param project the project * @param monitor the monitor * @return the i status * @throws CoreException the core exception */ public static IStatus cleanProject(IProject project, IProgressMonitor monitor) throws CoreException { try { final Collection<IFolder> resources = new HashSet<IFolder>(); resources.add(project.getFolder(SOAProjectConstants.FOLDER_GEN_META_SRC)); resources.add(project.getFolder(SOAProjectConstants.FOLDER_GEN_TEST)); IFolder genClient = project.getFolder(SOAProjectConstants.FOLDER_GEN_SRC_CLIENT); IFolder genService = project.getFolder(SOAProjectConstants.FOLDER_GEN_SRC_SERVICE); if (genClient.isAccessible() == false && genService.isAccessible() == false) { resources.add(project.getFolder(SOAProjectConstants.FOLDER_GEN_SRC)); } resources.add(genClient); resources.add(genService); resources.add(project.getFolder(SOAProjectConstants.FOLDER_GEN_WEB_CONTENT)); logger.info("Start to clean project " + project.getName() + "..."); for (final IResource resource : resources) { if (resource.isAccessible()) { try { logger.info("Cleaning directory " + resource.getLocation() + "..."); FileUtils.cleanDirectory(resource.getLocation().toFile()); ProgressUtil.progressOneStep(monitor); } catch (Exception e) { logger.error(e); throw new SOAActionExecutionFailedException(e); } } } logger.info("Clean project " + project.getName() + " finished."); project.refreshLocal(IResource.DEPTH_INFINITE, monitor); project.build(IncrementalProjectBuilder.CLEAN_BUILD, monitor); ProgressUtil.progressOneStep(monitor); } finally { monitor.done(); WorkspaceUtil.refresh(monitor, project); } return Status.OK_STATUS; }
From source file:org.ebayopensource.turmeric.eclipse.buildsystem.utils.BuilderUtil.java
/** * Cleans the bin/META-INF folder and do a refresh. * * @param project the project//from www . j av a 2 s. c o m * @param monitor the monitor * @throws IOException Signals that an I/O exception has occurred. * @throws CoreException the core exception */ public static void cleanBinMetaInfDir(final IProject project, IProgressMonitor monitor) throws IOException, CoreException { final IFolder metaFolder = project.getFolder(SOAProjectConstants.FOLDER_OUTPUT_DIR + WorkspaceUtil.PATH_SEPERATOR + SOAProjectConstants.FOLDER_META_INF); metaFolder.getParent().refreshLocal(IResource.DEPTH_ONE, monitor); if (metaFolder.isAccessible()) { SOALogger.getLogger() .warning(StringUtil.formatString(SOAMessages.CLEAN_FOLDER, metaFolder.getLocation())); FileUtils.cleanDirectory(metaFolder.getLocation().toFile()); } }
From source file:org.ebayopensource.turmeric.eclipse.test.utils.WsdlUtilTest.java
/** * @throws java.lang.Exception//from w ww .j ava 2 s . c o m */ @Override @After public void tearDownAfterClass() throws Exception { // clean the output folder FileUtils.cleanDirectory(outputFile); }
From source file:org.ebayopensource.turmeric.frameworkjars.ui.CopyLibraryDialog.java
@Override protected void okPressed() { if (metadata == null) return;//from ww w . j a v a 2 s. c om final String destination = this.destinationText.getText(); final IRunnableWithProgress runnable = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Copying jars for library ->" + metadata + "...", IProgressMonitor.UNKNOWN); try { monitor.internalWorked(20); IMavenEclipseApi api = MavenApiPlugin.getDefault().getMavenEclipseApi(); File destDir = new File(destination); if (destDir.exists() == false) destDir.mkdir(); else { try { FileUtils.cleanDirectory(destDir); } catch (IOException e) { e.printStackTrace(); } } monitor.internalWorked(20); try { for (Artifact artifact : api.resolveArtifactAsClasspath(metadata)) { File artifactFile = artifact.getFile(); if (artifactFile.getName().endsWith(".pom")) { System.out.println("bad"); } monitor.setTaskName("Copying from " + artifactFile + " to " + destDir); FileUtils.copyFileToDirectory(artifact.getFile(), destDir); monitor.internalWorked(20); } } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { throw new InvocationTargetException(e); } finally { monitor.done(); } } }; final IProgressService service = PlatformUI.getWorkbench().getProgressService(); try { service.run(false, false, runnable); } catch (Exception e) { ErrorDialog.openError(getShell(), "Error Occurred", "error occurred while copying library->" + metadata, new Status(IStatus.ERROR, "org.ebayopensource.turmeric", e.getLocalizedMessage(), e)); e.printStackTrace(); } super.okPressed(); }
From source file:org.ebayopensource.turmeric.tools.library.builders.CodeGenTypeLibraryGenerator.java
private static void clean(TypeLibraryCodeGenContext codeGenCtx) throws Exception { String genSrcPath = codeGenCtx.getGenJavaSrcDestFolder(); String genMetaSrcPath = codeGenCtx.getGenMetaSrcDestFolder(); try {/* ww w . j a va 2 s .c o m*/ FileUtils.cleanDirectory(new File(genSrcPath)); FileUtils.cleanDirectory(new File(genMetaSrcPath)); } catch (Exception e) { getLogger().log(Level.INFO, "Error while cleaning the directory"); } createBaseFolders(codeGenCtx); }
From source file:org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest.java
@After public void cleanUp() { if (new File(artifactDirectory).exists()) { try {/*from w w w . j a va 2 s.com*/ FileUtils.cleanDirectory(new File(artifactDirectory)); } catch (final IOException | IllegalArgumentException e) { LOG.warn("Cannot cleanup file-directory", e); } } }
From source file:org.eclipse.smila.processing.bpel.ODEWorkflowProcessor.java
/** * copy pipelines files from configuration directory to workspace directory for deployment. * //from w w w . ja va 2 s . c om * @param pipelineConfigDirName * name of configuration directory containing BPEL and associated files. * @param pipelineDeployDir * target workspace directory to deploy from * @throws IOException * error during copying */ private void copyPipelineDirectory(final String pipelineConfigDirName, final File pipelineDeployDir) throws IOException { _log.info("Pipeline deploy directory is " + pipelineDeployDir.getAbsolutePath()); FileUtils.cleanDirectory(pipelineDeployDir); final File configDir = ConfigUtils.getConfigFolder(ConfigurationConstants.BUNDLE_NAME, pipelineConfigDirName); FileUtils.copyDirectory(configDir, pipelineDeployDir, new NotFileFilter(new WildcardFileFilter(".*"))); _log.info("Pipeline configuration directory has been copied to workspace successfully."); }
From source file:org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager.java
/** * Delete the supplementary files of a given trace. * * @param trace/*from w ww .j ava 2 s . c om*/ * The trace for which the supplementary files are to be deleted * @since 2.2 */ public static void deleteSupplementaryFiles(ITmfTrace trace) { try { FileUtils.cleanDirectory(new File(TmfTraceManager.getSupplementaryFileDir(trace))); } catch (IOException e) { Activator.logError("Error deleting supplementary files for trace " + trace.getName(), e); //$NON-NLS-1$ } refreshSupplementaryFiles(trace); }