use of ubic.gemma.core.loader.expression.geo.util.GeoUtil in project Gemma by PavlidisLab.
the class RawDataFetcher method fetch.
/**
* @param identifier The url for the supplementary file.
* @return local files
*/
@Override
public Collection<LocalFile> fetch(String identifier) {
try {
if (this.ftpClient == null || !this.ftpClient.isConnected())
this.ftpClient = (new GeoUtil()).connect(FTP.BINARY_FILE_TYPE);
assert this.ftpClient != null;
File newDir = this.mkdir(identifier);
newDir = new File(newDir, "rawDataFiles");
if (!newDir.canRead() && !newDir.mkdir())
throw new IOException("Could not create the raw data subdirectory");
final String outputFileName = this.formLocalFilePath(identifier, newDir);
final String seekFile = this.formRemoteFilePath(identifier);
try {
NetUtils.checkForFile(this.ftpClient, seekFile);
} catch (FileNotFoundException e) {
// that's okay, just return.
AbstractFetcher.log.info("There is apparently no raw data archive for " + identifier + "(sought: " + seekFile + ")");
EntityUtils.deleteFile(newDir);
// important to do this!
this.ftpClient.disconnect();
return null;
}
if (this.ftpClient == null || !this.ftpClient.isConnected()) {
throw new IOException("Lost FTP connection");
}
long expectedSize = this.getExpectedSize(seekFile);
FutureTask<Boolean> future = this.defineTask(outputFileName, seekFile);
Collection<LocalFile> result = this.doTask(future, expectedSize, seekFile, outputFileName);
if (result == null || result.isEmpty()) {
throw new IOException("Files were not obtained, or download was cancelled.");
}
return result;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations