throws DBException
{
File destinationDir = downloadTo.getParentFile();
if (!destinationDir.exists())
{
throw new DBException("Specified destination directory does not exist: "
+ destinationDir.getAbsolutePath());
}
else if (!destinationDir.isDirectory())
{
throw new DBException("Specified destination 'directory' is not "
+ "actually a directory: "
+ destinationDir.getAbsolutePath());
}
else if (!destinationDir.canWrite())
{
throw new DBException("Specified destination directory is not writable: "
+ destinationDir.getAbsolutePath());
}
else if (downloadTo.exists())
{
throw new DBException("File already exists: "
+ downloadTo.getAbsolutePath());
}
try
{
logger.info("Writing: " + gridFile.getContentType()
+ ", date: " + gridFile.getUploadDate().toString()
+ ", type: " + gridFile.getContentType()
+ ", len: " + gridFile.getLength()
+ ", MD5: " + gridFile.getMD5()
+ ", Chunk size: " + gridFile.getChunkSize()
+ ", aliases: " + gridFile.getAliases()
// + ", properties: " + gridFile.toMap()
+ ", to: " + downloadTo.getAbsolutePath());
gridFile.writeTo(downloadTo);
}
catch(IOException e)
{
throw new DBException("Failed to retreive file: "
+ gridFile.getFilename()+", MD5: "+gridFile.getMD5(), e);
}
}