Class AbstractUpdateServiceImpl

java.lang.Object
org.tentackle.update.AbstractUpdateServiceImpl
All Implemented Interfaces:
Remote, UpdateService

public abstract class AbstractUpdateServiceImpl extends Object implements UpdateService
Server side update service implementation.
  • Constructor Details

    • AbstractUpdateServiceImpl

      public AbstractUpdateServiceImpl(String updateURL)
      Creates an update service object.
      Parameters:
      updateURL - the http url where to download the updates from
  • Method Details

    • getArtifactName

      public abstract String getArtifactName()
      Gets the artifact name excluding the version.

      Example:

      admin-jlink-client
      Returns:
      the artifact name
    • getVersion

      public abstract String getVersion()
      Gets the server version.
      Returns:
      the version
    • getUpdateURL

      public String getUpdateURL()
      Gets the update base URL.
      Returns:
      the url (with trailing slash!)
    • setUpdateURL

      public void setUpdateURL(String updateURL)
      Sets the update base URL.
      Parameters:
      updateURL - the url
    • getUpdateInfo

      public UpdateInfo getUpdateInfo(ClientInfo clientInfo)
      Description copied from interface: UpdateService
      Gets the info, how to download and install the update.
      Specified by:
      getUpdateInfo in interface UpdateService
      Parameters:
      clientInfo - the client application info
      Returns:
      the update info
    • createUpdateInfo

      protected UpdateInfo createUpdateInfo(String version, URL zipURL, String checksumHash, long size, String updateExecutor)
      Creates the update info to be returned to the client.
      Parameters:
      version - the new application version
      zipURL - the URL to download the zip file
      checksumHash - the checksum hash
      size - the download size
      updateExecutor - the filename to execute to perform the update
      Returns:
      the update info
    • createUpdateExecutor

      protected String createUpdateExecutor(ClientInfo clientInfo)
      Creates the name of the update executor.
      Parameters:
      clientInfo - the client info
      Returns:
      the executor name
    • createZipURL

      protected URL createZipURL(ClientInfo clientInfo)
      Creates the URL for the ZIP file.
      Parameters:
      clientInfo - the client info
      Returns:
      the URL
    • createChecksumURL

      protected URL createChecksumURL(ClientInfo clientInfo)
      Creates the URL for the checksum hash file.
      Parameters:
      clientInfo - the client info
      Returns:
      the URL
    • createBaseUrlName

      protected String createBaseUrlName(ClientInfo clientInfo)
      Creates the base URL name without extension.
      Parameters:
      clientInfo - the client info
      Returns:
      the URL string
    • determineChecksumHash

      protected String determineChecksumHash(URL checksumURL) throws IOException
      Determines the checksum hash.
      Parameters:
      checksumURL - the URL of the checksum hash file
      Returns:
      the hash value
      Throws:
      IOException - if failed
    • determineDownloadSize

      protected long determineDownloadSize(URL zipURL) throws IOException
      Determines the download size of the ZIP file.

      Only a determinate size is cached. An unknown size is not, because it would otherwise be answered for this artifact until the server is restarted, even though the very next request might get a proper content-length.

      Parameters:
      zipURL - the download URL
      Returns:
      the size in bytes, -1 if no content-length in header response
      Throws:
      IOException - if failed or the artifact is not available
    • isSuccessful

      protected boolean isSuccessful(int statusCode)
      Returns whether an HTTP status code denotes success.
      Parameters:
      statusCode - the status code
      Returns:
      true if 2xx