Class UpdateUtils


  • public class UpdateUtils
    extends java.lang.Object
    UpdateUtils provides updateFileFromUrl(String, String) to GET a file from remote URL and store it to a file. This utility will provide locks and synchronization to prevent two threads or jvms from overwriting the destination file at the same time, and will use last modification time from the source URL to skip URL acquisition based on file modification time.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  UpdateUtils.UpdateException
      An exception caused by the UpdateUtils methods.
    • Constructor Summary

      Constructors 
      Constructor Description
      UpdateUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void update​(FileUpdater updater, java.io.File destFile)
      Update a destination file with an updater implementation, while maintaining appropriate locks around the action and file
      static void updateFileFromFile​(java.io.File sourceFile, java.lang.String destinationFilePath)
      Get the source File and store it to a destination file path
      static void updateFileFromInputStream​(java.io.InputStream input, java.lang.String destinationFilePath)
      Get the source URL and store it to a destination file path
      static void updateFileFromUrl​(java.lang.String sourceUrl, java.lang.String destinationFilePath)
      Get the source URL and store it to a destination file path
      static void updateFileFromUrl​(java.lang.String sourceUrl, java.lang.String destinationFilePath, java.lang.String username, java.lang.String password)
      Get the source URL and store it to a destination file path
      static void updateFileFromUrl​(java.lang.String sourceUrl, java.lang.String destinationFilePath, java.lang.String username, java.lang.String password, URLFileUpdaterFactory factory)
      Get the source URL and store it to a destination file path
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UpdateUtils

        public UpdateUtils()
    • Method Detail

      • updateFileFromUrl

        public static void updateFileFromUrl​(java.lang.String sourceUrl,
                                             java.lang.String destinationFilePath)
                                      throws UpdateUtils.UpdateException
        Get the source URL and store it to a destination file path
        Parameters:
        sourceUrl - url
        destinationFilePath - destination
        Throws:
        UpdateUtils.UpdateException - on error
      • updateFileFromFile

        public static void updateFileFromFile​(java.io.File sourceFile,
                                              java.lang.String destinationFilePath)
                                       throws UpdateUtils.UpdateException
        Get the source File and store it to a destination file path
        Parameters:
        sourceFile - source
        destinationFilePath - destination
        Throws:
        UpdateUtils.UpdateException - on error
      • updateFileFromInputStream

        public static void updateFileFromInputStream​(java.io.InputStream input,
                                                     java.lang.String destinationFilePath)
                                              throws UpdateUtils.UpdateException
        Get the source URL and store it to a destination file path
        Parameters:
        input - input stream
        destinationFilePath - destination
        Throws:
        UpdateUtils.UpdateException - on error
      • updateFileFromUrl

        public static void updateFileFromUrl​(java.lang.String sourceUrl,
                                             java.lang.String destinationFilePath,
                                             java.lang.String username,
                                             java.lang.String password)
                                      throws UpdateUtils.UpdateException
        Get the source URL and store it to a destination file path
        Parameters:
        sourceUrl - url
        destinationFilePath - destination
        username - username
        password - password
        Throws:
        UpdateUtils.UpdateException - on error
      • updateFileFromUrl

        public static void updateFileFromUrl​(java.lang.String sourceUrl,
                                             java.lang.String destinationFilePath,
                                             java.lang.String username,
                                             java.lang.String password,
                                             URLFileUpdaterFactory factory)
                                      throws UpdateUtils.UpdateException
        Get the source URL and store it to a destination file path
        Parameters:
        sourceUrl - url
        destinationFilePath - destination
        username - username
        password - password
        factory - updater factory
        Throws:
        UpdateUtils.UpdateException - on error
      • update

        public static void update​(FileUpdater updater,
                                  java.io.File destFile)
                           throws UpdateUtils.UpdateException
        Update a destination file with an updater implementation, while maintaining appropriate locks around the action and file
        Parameters:
        updater - updater
        destFile - destination
        Throws:
        UpdateUtils.UpdateException - on error