modification to give randomness to output files

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngineSmartExecutor@160370 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Gianpaolo Coro 2017-12-12 18:20:29 +00:00
parent 967fc2038d
commit 056f0183d9
2 changed files with 22 additions and 2 deletions

View File

@ -2841,6 +2841,26 @@ public class FileUtils {
}
}
public static void moveFileToDirectory(File srcFile, File destDir, File dstFile, boolean createDestDir) throws IOException {
if (srcFile == null) {
throw new NullPointerException("Source must not be null");
}
if (destDir == null) {
throw new NullPointerException("Destination directory must not be null");
}
if (!destDir.exists() && createDestDir) {
destDir.mkdirs();
}
if (!destDir.exists()) {
throw new FileNotFoundException("Destination directory '" + destDir +
"' does not exist [createDestDir=" + createDestDir +"]");
}
if (!destDir.isDirectory()) {
throw new IOException("Destination '" + destDir + "' is not a directory");
}
moveFile(srcFile, new File(destDir, dstFile.getName()));
}
/**
* Moves a file to a directory.
*

View File

@ -236,10 +236,10 @@ public abstract class GenericRScript extends StandardLocalInfraAlgorithm {
}
if (rowFile.exists()) {
String preparedFile = new File(config.getConfigPath(), rowFile.getName()).getAbsolutePath();
String preparedFile = new File(config.getConfigPath(), UUID.randomUUID()+rowFile.getName()).getAbsolutePath();
LOGGER.debug("Copying " + rowFile.getAbsolutePath() + " to " + preparedFile);
try{
org.gcube.dataanalysis.executor.rscripts.generic.FileUtils.moveFileToDirectory(rowFile, new File(config.getConfigPath()), false);
org.gcube.dataanalysis.executor.rscripts.generic.FileUtils.moveFileToDirectory(rowFile, new File(config.getConfigPath()),new File(preparedFile), false);
files.add(preparedFile);
}catch(Exception e){
LOGGER.error("error in moving file "+rowFile.getAbsolutePath()+" to "+preparedFile,e);