@Override public void download(RemoteFile remoteFile, File localFile) throws StorageException { connect(); File repoFile = getRemoteFile(remoteFile); if (!repoFile.exists()) { throw new StorageFileNotFoundException("No such file in local repository: " + repoFile); } try { File tempLocalFile = createTempFile("local-tm-download"); tempLocalFile.deleteOnExit(); FileUtils.copyFile(repoFile, tempLocalFile); localFile.delete(); FileUtils.moveFile(tempLocalFile, localFile); tempLocalFile.delete(); } catch (IOException ex) { throw new StorageException("Unable to copy file " + repoFile + " from local repository to " + localFile, ex); } }
throw new StorageFileNotFoundException("File " + remoteFile.getName() + " does not exist and is not in any transaction");