List of usage examples for org.apache.commons.io FileUtils cleanDirectory
public static void cleanDirectory(File directory) throws IOException
From source file:org.efaps.esjp.admin.program.CSS.java
/** * Compile.//from w ww.ja va 2 s. c o m * * @param _parameter Parameter as passed by the eFaps API * @return the return * @throws EFapsException on error */ public Return compile(final Parameter _parameter) throws EFapsException { new CSSCompiler().compile(); try { FileUtils.cleanDirectory(TempFileBundle.getTempFolder()); } catch (final IOException e) { throw new EFapsException(CSS.class, "compile", e); } return new Return(); }
From source file:org.efs.openreports.actions.admin.ImageCleanupAction.java
public String execute() { File imageTempDirectory = new File(directoryProvider.getReportImageTempDirectory()); try {//from w w w.ja v a2 s . com FileUtils.cleanDirectory(imageTempDirectory); } catch (Exception e) { addActionError(e.toString()); } return SUCCESS; }
From source file:org.esigate.server.EsigateServer.java
private static File resetTempDirectory(String currentDir) throws IOException { File workDir;// w ww. j av a 2s.c o m // Currently disabled because this may be dangerous. // if (EsigateServer.workPath != null) { // workDir = new File(EsigateServer.workPath); // } else { workDir = new File(currentDir, "work"); // } if (workDir.exists()) { try { FileUtils.cleanDirectory(workDir); } catch (IllegalArgumentException e) { // Strange behavior : if this directory exists, it disappears a // few ms later, causing this exception. We can ignore since we // initially wanted to delete it. LOG.info("Info: issue while deleting work directory, it was already deleted. Not a problem."); } } return workDir; }
From source file:org.estatio.dscm.services.SyncService.java
@Programmatic public void removePlaylists(Display display, String path) { String removePath = path.concat("/displays/").concat(display.getName()).concat("/playlists/"); try {/*from w ww .j a va 2 s.c o m*/ FileUtils.cleanDirectory(new File(removePath)); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }
From source file:org.estatio.dscm.services.SyncService.java
@Programmatic public void removeDisplayAssets(Display display, String path) { String removePath = path.concat("/displays/").concat(display.getName()).concat("/assets/"); try {/*from w ww .j ava 2 s. c om*/ FileUtils.cleanDirectory(new File(removePath)); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }
From source file:org.fao.unredd.layers.folder.AbstractLayerFolder.java
@Override public void setOutput(String id, String outputName, String fieldId, String content) throws IOException { File outputFolder = new File(getOutputFolder(), id); if (outputFolder.exists()) { FileUtils.cleanDirectory(outputFolder); } else {/*w ww .ja v a2 s . c o m*/ if (!outputFolder.mkdirs()) { throw new IOException( "Cannot create the indicator output folder: " + outputFolder.getAbsolutePath()); } } BufferedOutputStream resultStream = new BufferedOutputStream( new FileOutputStream(new File(outputFolder, OUTPUT_FILE_NAME))); try { IOUtils.write(content, resultStream); } finally { resultStream.close(); } Properties metadata = getMetadataProperties(outputFolder); metadata.setProperty(METADATA_FIELD_ID_PROPERTY_NAME, fieldId); metadata.setProperty(METADATA_INDICATOR_NAME_PROPERTY_NAME, outputName); FileOutputStream metadataStream = new FileOutputStream(getMetadataFile(outputFolder)); try { metadata.store(metadataStream, ""); } finally { metadataStream.close(); } }
From source file:org.finra.dm.core.DmFileUtils.java
/** * Cleans a directory without deleting it. This method does not fail in case cleaning is unsuccessful, but simply logs the exception information as a * warning./*w ww. java2 s. com*/ * * @param directory directory to clean */ public static void cleanDirectoryIgnoreException(File directory) { try { FileUtils.cleanDirectory(directory); } catch (Exception e) { LOGGER.warn(String.format("Failed to clean \"%s\" directory.", directory), e); } }
From source file:org.finra.dm.tools.common.databridge.AbstractDataBridgeTest.java
/** * Uploads and registers a version if of the test business object data that will be used as a parent. * * @param s3KeyPrefix the destination S3 key prefix that must comply with the S3 naming conventions including the expected data version value * @param dataBridgeWebClient the databridge web client instance *///from w w w .j a va 2 s .c om protected void uploadAndRegisterTestDataParent(String s3KeyPrefix, DataBridgeWebClient dataBridgeWebClient) throws Exception { uploadTestDataFilesToS3(s3KeyPrefix, testManifestFiles, new ArrayList<String>()); UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto( TEST_PARENT_PARTITION_VALUE, TEST_SUB_PARTITION_VALUES, false); S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = getTestS3FileTransferRequestParamsDto(); s3FileTransferRequestParamsDto.setS3KeyPrefix(s3KeyPrefix + "/"); dataBridgeWebClient.registerBusinessObjectData(uploaderInputManifestDto, s3FileTransferRequestParamsDto, StorageEntity.MANAGED_STORAGE, true); // Clean up the local input directory used for the test data files upload. FileUtils.cleanDirectory(LOCAL_TEMP_PATH_INPUT.toFile()); }
From source file:org.finra.dm.tools.downloader.AbstractDownloaderTest.java
/** * Uploads and registers a version if of the test business object data with the specified data files. * * @param s3KeyPrefix the destination S3 key prefix that must comply with the S3 naming conventions including the expected data version value * @param manifestFiles the test data files to be uploaded to S3 and registered * @param directoryPaths the list of directory paths to be created in S3 relative to the S3 key prefix *//*from w ww . jav a 2s . co m*/ protected void uploadAndRegisterTestData(String s3KeyPrefix, List<ManifestFile> manifestFiles, List<String> directoryPaths) throws Exception { uploadTestDataFilesToS3(s3KeyPrefix, manifestFiles, directoryPaths); UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto(); uploaderInputManifestDto.setManifestFiles(manifestFiles); S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = getTestS3FileTransferRequestParamsDto(); s3FileTransferRequestParamsDto.setS3KeyPrefix(s3KeyPrefix + "/"); downloaderWebClient.registerBusinessObjectData(uploaderInputManifestDto, s3FileTransferRequestParamsDto, StorageEntity.MANAGED_STORAGE, false); // Clean up the local input directory used for the test data files upload. FileUtils.cleanDirectory(LOCAL_TEMP_PATH_INPUT.toFile()); }
From source file:org.finra.herd.service.helper.StoragePolicyProcessorJmsMessageListenerTest.java
/** * Sets up the test environment./*from ww w . ja va 2 s . c o m*/ */ @Before public void setup() throws Exception { // Create local temp directories. LOCAL_TEMP_DIR.toFile().mkdirs(); // Create local test files. for (String filePath : LOCAL_FILES) { createLocalFile(LOCAL_TEMP_DIR.toString(), filePath, FILE_SIZE_1_KB); } // Upload test file to S3. Since the S3 key prefix represents a directory, we add a trailing '/' character to it. s3Dao.uploadDirectory(S3FileTransferRequestParamsDto.builder().s3BucketName(S3_BUCKET_NAME) .s3KeyPrefix(S3_KEY_PREFIX + "/").localPath(LOCAL_TEMP_DIR.toString()).recursive(true).build()); // Clean up the temporary directory. FileUtils.cleanDirectory(LOCAL_TEMP_DIR.toFile()); }