Skip to content
Snippets Groups Projects
Commit 57519116 authored by cramakri's avatar cramakri
Browse files

LMS-1887 Provide more accurate information to the user during download.

SVN: 18878
parent e378b3fe
No related branches found
No related tags found
No related merge requests found
...@@ -62,20 +62,32 @@ class CommandGet extends AbstractDssCommand<CommandGet.CommandGetArguments> ...@@ -62,20 +62,32 @@ class CommandGet extends AbstractDssCommand<CommandGet.CommandGetArguments>
private static class DownloaderListener implements private static class DownloaderListener implements
FileInfoDssDownloader.FileInfoDssDownloaderListener FileInfoDssDownloader.FileInfoDssDownloaderListener
{ {
private final File targetDir;
DownloaderListener(File targetDir)
{
this.targetDir = targetDir;
}
public void willDownload(FileInfoDssDTO fileInfo) public void willDownload(FileInfoDssDTO fileInfo)
{ {
System.out.println("downloading " + fileInfo.getPathInListing()); System.out.println("downloading " + getPathForFileInfo(fileInfo));
} }
public void willCreateDirectory(FileInfoDssDTO fileInfo) public void willCreateDirectory(FileInfoDssDTO fileInfo)
{ {
System.out.println("mkdir " + fileInfo.getPathInListing()); System.out.println("mkdir " + getPathForFileInfo(fileInfo));
} }
public void didFinish() public void didFinish()
{ {
System.out.println("Finished."); System.out.println("Finished.");
} }
private String getPathForFileInfo(FileInfoDssDTO fileInfo)
{
return targetDir.getPath() + "/" + fileInfo.getPathInListing();
}
} }
private static class CommandGetExecutor extends AbstractDataSetExecutor<CommandGetArguments> private static class CommandGetExecutor extends AbstractDataSetExecutor<CommandGetArguments>
...@@ -120,7 +132,7 @@ class CommandGet extends AbstractDssCommand<CommandGet.CommandGetArguments> ...@@ -120,7 +132,7 @@ class CommandGet extends AbstractDssCommand<CommandGet.CommandGetArguments>
FileInfoDssDownloader downloader = FileInfoDssDownloader downloader =
new FileInfoDssDownloader(dataSet, fileInfos, outputDir, new FileInfoDssDownloader(dataSet, fileInfos, outputDir,
new DownloaderListener()); new DownloaderListener(outputDir));
downloader.downloadFiles(); downloader.downloadFiles();
} }
......
...@@ -50,20 +50,32 @@ class ReplicaDownloader ...@@ -50,20 +50,32 @@ class ReplicaDownloader
private static class DownloaderListener implements private static class DownloaderListener implements
FileInfoDssDownloader.FileInfoDssDownloaderListener FileInfoDssDownloader.FileInfoDssDownloaderListener
{ {
private final File targetDir;
DownloaderListener(File targetDir)
{
this.targetDir = targetDir;
}
public void willDownload(FileInfoDssDTO fileInfo) public void willDownload(FileInfoDssDTO fileInfo)
{ {
System.out.println("downloading " + fileInfo.getPathInListing()); System.out.println("downloading " + getPathForFileInfo(fileInfo));
} }
public void willCreateDirectory(FileInfoDssDTO fileInfo) public void willCreateDirectory(FileInfoDssDTO fileInfo)
{ {
System.out.println("mkdir " + fileInfo.getPathInListing()); System.out.println("mkdir " + getPathForFileInfo(fileInfo));
} }
public void didFinish() public void didFinish()
{ {
System.out.println("Finished."); System.out.println("Finished.");
} }
private String getPathForFileInfo(FileInfoDssDTO fileInfo)
{
return targetDir.getPath() + "/" + fileInfo.getPathInListing();
}
} }
protected void download() protected void download()
...@@ -108,9 +120,10 @@ class ReplicaDownloader ...@@ -108,9 +120,10 @@ class ReplicaDownloader
IDataSetDss dataSetDss = component.getDataSet(dataSet.getCode()); IDataSetDss dataSetDss = component.getDataSet(dataSet.getCode());
FileInfoDssDTO[] fileInfos = dataSetDss.listFiles("/original/", true); FileInfoDssDTO[] fileInfos = dataSetDss.listFiles("/original/", true);
File targetDir = new File(outputDir, subfolderName);
FileInfoDssDownloader downloader = FileInfoDssDownloader downloader =
new FileInfoDssDownloader(dataSetDss, fileInfos, new FileInfoDssDownloader(dataSetDss, fileInfos, targetDir, new DownloaderListener(
new File(outputDir, subfolderName), new DownloaderListener()); targetDir));
downloader.downloadFiles(); downloader.downloadFiles();
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment