Class ZipURLInstaller

  • All Implemented Interfaces:
    Installer, Loggable

    public class ZipURLInstaller
    extends LoggedObject
    implements Installer
    Installs a compressed container file from a URL to a location on your local disk.

    Though the name of this class is ZipURLInstaller, all formats supported by commons-compress are supported.
    • Constructor Detail

      • ZipURLInstaller

        public ZipURLInstaller​(URL remoteLocation)
        Parameters:
        remoteLocation - URL where the compressed container is located
      • ZipURLInstaller

        public ZipURLInstaller​(URL remoteLocation,
                               String downloadDir,
                               String extractDir)
        Parameters:
        remoteLocation - URL where the compressed container is located
        downloadDir - directory where the compressed container install will be downloaded.
        extractDir - directory where the compressed container install will be extracted.
    • Method Detail

      • setLogger

        public void setLogger​(Logger logger)
        Overriden in order to set the logger on ancillary components.
        Specified by:
        setLogger in interface Loggable
        Overrides:
        setLogger in class LoggedObject
        Parameters:
        logger - the logger to set and set in the ancillary objects
      • setDownloadDir

        public void setDownloadDir​(String downloadDir)
        Parameters:
        downloadDir - the destination directory where the compressed container install will be downloaded.
      • setExtractDir

        public void setExtractDir​(String extractDir)
        Parameters:
        extractDir - the destination directory where the compressed container install will be installed.
      • getDownloadDir

        public String getDownloadDir()
        Returns:
        The destination directory where the compressed container install will be downloaded.
      • getDownloadFile

        public String getDownloadFile()
        Returns:
        The destination file where the compressed container install will be downloaded.
      • getExtractDir

        public String getExtractDir()
        Returns:
        The destination directory where the compressed container install will be extracted.
      • getFileHandler

        public FileHandler getFileHandler()
        Returns:
        the file utility class to use for performing all file I/O.
      • setFileHandler

        public void setFileHandler​(FileHandler fileHandler)
        Parameters:
        fileHandler - the file utility class to use for performing all file I/O.
      • registerInstallation

        public void registerInstallation()
        Create timestamp file to register that the installation has been successful. This allows to prevent installing again next time. If the remote URL changes, then the container will be reinstalled.
      • isAlreadyDownloaded

        public boolean isAlreadyDownloaded()
        Returns:
        true if the container has already been downloaded, false otherwise
      • isAlreadyExtracted

        public boolean isAlreadyExtracted()
        Returns:
        true if the container has already been extracted, false otherwise
      • getHome

        public String getHome()
        Specified by:
        getHome in interface Installer
        Returns:
        the directory where the container has been installed. Note that we're returning a String instead of a File because we want to leave the possibility of using URIs for specifying the home location.
      • download

        public void download()
        Downloads the compressed file containing the container files.
      • doDownload

        protected void doDownload()
                           throws IOException
        Perform the actual HTTP download.
        Throws:
        IOException - if any I/O exception occurs (with the URL connection or file streams)
      • getSourceFileName

        protected String getSourceFileName()
        Returns:
        the name of the source compressed file (without the path)
      • setProxy

        public void setProxy​(Proxy proxy)
        Sets proxy details.
        Parameters:
        proxy - the proxy configuration to set