Search in sources :

Example 1 with FileDownloader

use of org.monarchinitiative.loinc2hpo.io.FileDownloader in project loinc2hpo by monarch-initiative.

the class DownloadCommand method downloadHpOntologyIfNeeded.

private void downloadHpOntologyIfNeeded() {
    File f = new File(String.format("%s%shp.obo", downloadDirectory, File.separator));
    if (f.exists()) {
        logger.trace(String.format("Cowardly refusing to download hp.obo since we found it at %s", f.getAbsolutePath()));
        return;
    }
    FileDownloader downloader = new FileDownloader();
    try {
        URL url = new URL(HP_OBO);
        logger.debug("Created url from " + HP_OBO + ": " + url.toString());
        downloader.copyURLToFile(url, new File(f.getAbsolutePath()));
    } catch (MalformedURLException e) {
        logger.error("Malformed URL for hp.obo");
        logger.error(e, e);
    } catch (FileDownloadException e) {
        logger.error("Error downloading hp.obo");
        logger.error(e, e);
    }
    logger.trace(String.format("Successfully downloaded hp.obo file at %s", f.getAbsolutePath()));
}
Also used : MalformedURLException(java.net.MalformedURLException) FileDownloader(org.monarchinitiative.loinc2hpo.io.FileDownloader) File(java.io.File) URL(java.net.URL) FileDownloadException(org.monarchinitiative.loinc2hpo.exception.FileDownloadException)

Aggregations

File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 FileDownloadException (org.monarchinitiative.loinc2hpo.exception.FileDownloadException)1 FileDownloader (org.monarchinitiative.loinc2hpo.io.FileDownloader)1