Class BootstrapUtilities

java.lang.Object
com.inductiveautomation.ignition.client.launch.BootstrapUtilities

public class BootstrapUtilities extends Object
Created by carl.gould on 1/29/2015.
  • Method Details

    • subdir

      public static File subdir(File parent, String child) throws Exception
      Returns a subdir and tries to create it if necessary. Throws an error if the dir can't be created
      Throws:
      Exception
    • getJarParentFolder

      public static File getJarParentFolder(File resourcesDir, LaunchManifest.Module m, LaunchManifest.Jar j) throws Exception
      Given the root of the cache/resources/ folder, returns the correct parent folder for a given jar file, right before the specific CRC subfolders.
      Throws:
      Exception
    • sanitize

      public static String sanitize(String s)
      Sanitizes a string to be compatible with filename / foldername requirements by replacing illegal chars with underscores.
    • crc

      public static long crc(File jarFile) throws IOException
      Throws:
      IOException
    • md5

      public static String md5(File file) throws IOException
      Throws:
      IOException
    • deleteDirectory

      public static void deleteDirectory(File directory) throws IOException
      Deletes a directory recursively.
      Parameters:
      directory - directory to delete
      Throws:
      IOException - in case deletion is unsuccessful
    • cleanDirectory

      public static void cleanDirectory(File directory) throws IOException
      Cleans a directory without deleting it.
      Parameters:
      directory - directory to clean
      Throws:
      IOException - in case cleaning is unsuccessful
    • forceDelete

      public static void forceDelete(File file) throws IOException
      Throws:
      IOException
    • subfile

      public static File subfile(File base, String filePath)
    • subfile

      public static File subfile(File base, String... subDirs)
    • copyFile

      public static void copyFile(File in, File out) throws IOException
      Throws:
      IOException
    • readFileAsString

      public static String readFileAsString(File file) throws IOException
      Throws:
      IOException
    • writeStringToFile

      public static void writeStringToFile(String string, File file) throws IOException
      Throws:
      IOException
    • gatewayInfo

      public static BootstrapUtilities.GatewayInfoResults gatewayInfo(GatewayAddress target) throws IOException
      Retrieves the target gateway addresses gw info from the GatewayInfoServlet. This is useful for retrieving details which are required very early in the bootstrap process or details needed at the very beginning of starting a new process or client. A Basic check is used to ensure the response is what would be expected from the GatewayInfoServlet and a small subset of values are returned which are very lenient to accommodate gateways which might not provide those details.
      Throws:
      IOException
    • launchJarCompatible

      public static BootstrapUtilities.LaunchJarResults launchJarCompatible(GatewayAddress target, File launchJar) throws IOException
      Checks if the supplied launch jar matches in length and crc32 checksum by getting the required length and checksum from the target gateway and comparing against the file. A LaunchJarResults is returned which wraps a boolean stating if its matches along with the checksum and length.
      Throws:
      IOException
    • getStringResponse

      public static String getStringResponse(URL url, int readTimeout) throws IOException
      Throws:
      IOException
    • downloadFile

      public static long downloadFile(URL url, int readTimeout, File destination) throws IOException
      Downloads the file that exists at the url and saves it to the supplied destination file. Returns the CRC32 checksum of the file. No locking of the destination file is performed.
      Throws:
      IOException
    • newConnection

      public static HttpURLConnection newConnection(URL url, int readTimeout) throws IOException
      Returns a new "GET" HttpURLConnection with the default connect timeout of 15 seconds and a read timeout based on the supplied value. Be sure to close the connection!
      Throws:
      IOException