* to the output task.
*/
private void download() {
IntervalDownloaderConfiguration configuration;
TimestampTracker timestampTracker;
ChangesetFileNameFormatter fileNameFormatter;
Date currentTime;
Date maximumTime;
URL baseUrl;
int maxDownloadCount;
int downloadCount;
ArrayList<File> tmpFileList;
ArrayList<RunnableChangeSource> tasks;
ArrayList<TaskRunner> taskRunners;
boolean tasksSuccessful;
// Instantiate utility objects.
configuration = new IntervalDownloaderConfiguration(new File(workingDirectory, CONFIG_FILE));
timestampTracker = new TimestampTracker(
new File(workingDirectory, TSTAMP_FILE),
new File(workingDirectory, TSTAMP_NEW_FILE)
);
fileNameFormatter = new ChangesetFileNameFormatter(
configuration.getChangeFileBeginFormat(),
configuration.getChangeFileEndFormat()
);
// Create the base url.
try {
baseUrl = new URL(configuration.getBaseUrl());
} catch (MalformedURLException e) {
throw new OsmosisRuntimeException(
"Unable to convert URL string (" + configuration.getBaseUrl() + ") into a URL.", e);
}
tmpFileList = new ArrayList<File>();
// Load the current time from the timestamp tracking file.
currentTime = timestampTracker.getTime();
// Load the latest timestamp from the server.
maximumTime = getServerTimestamp(baseUrl);
// Process until all files have been retrieved from the server.
maxDownloadCount = configuration.getMaxDownloadCount();
downloadCount = 0;
while ((maxDownloadCount == 0 || downloadCount < maxDownloadCount) && currentTime.before(maximumTime)) {
Date nextTime;
String downloadFileName;
// Calculate the end of the next time interval.
nextTime = new Date(currentTime.getTime() + configuration.getIntervalLength());
// Generate the filename to be retrieved from the server.
downloadFileName = fileNameFormatter.generateFileName(currentTime, nextTime);
// Download the changeset from the server.
tmpFileList.add(downloadChangesetFile(downloadFileName, baseUrl));
// Move the current time to the next interval.