Class AbstractFetcher
- java.lang.Object
-
- ubic.gemma.core.loader.util.fetcher.AbstractFetcher
-
- All Implemented Interfaces:
Fetcher
- Direct Known Subclasses:
FtpFetcher,HttpFetcher
public abstract class AbstractFetcher extends Object implements Fetcher
- Author:
- pavlidis
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanallowUseExistingWhether 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.protected booleanforceWhether download is required even if the sizes match.protected static intINFO_UPDATE_INTERVALprotected StringlocalBasePathprotected static org.apache.commons.logging.Loglogprotected StringremoteBaseDir
-
Constructor Summary
Constructors Constructor Description AbstractFetcher()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected LocalFilefetchedFile(String seekFile)protected LocalFilefetchedFile(String seekFilePath, String outputFilePath)protected abstract StringformLocalFilePath(String identifier, File newDir)protected abstract StringformRemoteFilePath(String identifier)protected Collection<LocalFile>getExistingFile(File existingFile, String seekFile)Wrap the existing file in the required Collection<LocalFile>StringgetLocalBasePath()protected abstract voidinitConfig()booleanisForce()protected Filemkdir()Like mkdir(accession) but for cases where there is no accession.protected Filemkdir(String accession)Create a directory according to the current accession number and set path information, including any non-existing parent directories.voidsetAllowUseExisting(boolean allowUseExisting)voidsetForce(boolean force)Set to true if downloads should proceed even if the file already exists.protected booleanwaitForDownload(FutureTask<Boolean> future)protected booleanwaitForDownload(FutureTask<Boolean> future, long expectedSize, File outputFile)
-
-
-
Field Detail
-
INFO_UPDATE_INTERVAL
protected static final int INFO_UPDATE_INTERVAL
- See Also:
- Constant Field Values
-
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
-
-
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.
-
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 downloadoutputFilePath- Absolute path to the download location.- Returns:
- local file
-
getExistingFile
protected Collection<LocalFile> getExistingFile(File existingFile, String seekFile)
Wrap the existing file in the required Collection<LocalFile>- Parameters:
existingFile- existing fileseekFile- 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 taskexpectedSize- expected sizeoutputFile- output file- Returns:
- true if it finished normally, false if it was cancelled.
-
-