Class AbstractFetcher

    • Field Detail

      • log

        protected static final org.apache.commons.logging.Log log
      • allowUseExisting

        protected boolean allowUseExisting
        Whether we are allowed to use an existing file rather than downloading again, in the case where we can't connect to the remote host to check the size of the file. Setting force=true overrides this. Default is FALSE.
      • force

        protected boolean force
        Whether download is required even if the sizes match.
      • localBasePath

        protected String localBasePath
      • remoteBaseDir

        protected String remoteBaseDir
    • Constructor Detail

      • AbstractFetcher

        public AbstractFetcher()
    • Method Detail

      • getLocalBasePath

        public String getLocalBasePath()
        Returns:
        Returns the localBasePath.
      • isForce

        public boolean isForce()
        Returns:
        the force
      • setForce

        public void setForce​(boolean force)
        Set to true if downloads should proceed even if the file already exists.
        Specified by:
        setForce in interface Fetcher
        Parameters:
        force - new force
      • setAllowUseExisting

        public void setAllowUseExisting​(boolean allowUseExisting)
        Parameters:
        allowUseExisting - the allowUseExisting to set
      • fetchedFile

        protected LocalFile fetchedFile​(String seekFilePath,
                                        String outputFilePath)
        Parameters:
        seekFilePath - Absolute path to the file for download
        outputFilePath - Absolute path to the download location.
        Returns:
        local file
      • formLocalFilePath

        protected abstract String formLocalFilePath​(String identifier,
                                                    File newDir)
      • formRemoteFilePath

        protected abstract String formRemoteFilePath​(String identifier)
      • getExistingFile

        protected Collection<LocalFile> getExistingFile​(File existingFile,
                                                        String seekFile)
        Wrap the existing file in the required Collection<LocalFile>
        Parameters:
        existingFile - existing file
        seekFile - seek file
        Returns:
        collection of local files
      • initConfig

        protected abstract void initConfig()
      • mkdir

        protected File mkdir()
                      throws IOException
        Like mkdir(accession) but for cases where there is no accession.
        Returns:
        file
        Throws:
        IOException - when there are IO problems.
      • mkdir

        protected File mkdir​(String accession)
                      throws IOException
        Create a directory according to the current accession number and set path information, including any non-existing parent directories. If the path cannot be used, we use a temporary directory.
        Parameters:
        accession - accession
        Returns:
        new directory
        Throws:
        IOException - if there is a problem while manipulating the file
      • waitForDownload

        protected boolean waitForDownload​(FutureTask<Boolean> future)
        Parameters:
        future - future task
        Returns:
        true if it finished normally, false if it was cancelled.
      • waitForDownload

        protected boolean waitForDownload​(FutureTask<Boolean> future,
                                          long expectedSize,
                                          File outputFile)
        Parameters:
        future - future task
        expectedSize - expected size
        outputFile - output file
        Returns:
        true if it finished normally, false if it was cancelled.