use of org.apache.commons.io.FileUtils in project gocd by gocd.
the class AgentBootstrapper method cleanupTempFiles.
private void cleanupTempFiles() {
FileUtils.deleteQuietly(new File(FileUtil.TMP_PARENT_DIR));
// launchers extracted from old versions
FileUtils.deleteQuietly(new File("exploded_agent_launcher_dependencies"));
FileUtils.listFiles(new File("."), AGENT_LAUNCHER_TMP_FILE_FILTER, FalseFileFilter.INSTANCE).forEach(FileUtils::deleteQuietly);
FileUtils.deleteQuietly(new File(new SystemEnvironment().getConfigDir(), "trust.jks"));
}
use of org.apache.commons.io.FileUtils in project cas by apereo.
the class SamlSPUtilsTests method shutdown.
@AfterAll
public static void shutdown() {
val file = new File(FileUtils.getTempDirectoryPath(), "idp-metadata-test");
val cols = FileUtils.listFiles(file, new String[] { "crt", "key", "xml" }, false);
cols.forEach(FileUtils::deleteQuietly);
}
use of org.apache.commons.io.FileUtils in project jmeter by apache.
the class Save method backupAndSave.
/**
* Backup existing file according to jmeter/user.properties settings
* and save
* @param e {@link ActionEvent}
* @param subTree HashTree Test plan to save
* @param fullSave Partial or full save
* @param newFile File to save
* @throws IllegalUserActionException
*/
void backupAndSave(ActionEvent e, HashTree subTree, boolean fullSave, String newFile) throws IllegalUserActionException {
//
List<File> expiredBackupFiles = EMPTY_FILE_LIST;
if (GuiPackage.getInstance().isDirty()) {
File fileToBackup = new File(newFile);
log.debug("Test plan has changed, make backup of {}", fileToBackup);
try {
expiredBackupFiles = createBackupFile(fileToBackup);
} catch (Exception ex) {
// $NON-NLS-1$
log.error("Failed to create a backup for {}", fileToBackup, ex);
}
}
try {
convertSubTree(subTree);
} catch (Exception err) {
if (log.isWarnEnabled()) {
log.warn("Error converting subtree. {}", err.toString());
}
}
try (FileOutputStream ostream = new FileOutputStream(newFile)) {
SaveService.saveTree(subTree, ostream);
if (fullSave) {
// Only update the stored copy of the tree for a full save
FileServer.getFileServer().setScriptName(new File(newFile).getName());
// refetch, because convertSubTree affects it
subTree = GuiPackage.getInstance().getTreeModel().getTestPlan();
ActionRouter.getInstance().doActionNow(new ActionEvent(subTree, e.getID(), ActionNames.SUB_TREE_SAVED));
}
// delete expired backups : here everything went right so we can
// proceed to deletion
expiredBackupFiles.forEach(FileUtils::deleteQuietly);
} catch (RuntimeException ex) {
throw ex;
} catch (Exception ex) {
log.error("Error saving tree.", ex);
throw new IllegalUserActionException("Couldn't save test plan to file: " + newFile, ex);
}
}
Aggregations