Class BootstrapUtilities
java.lang.Object
com.inductiveautomation.ignition.client.launch.BootstrapUtilities
Created by carl.gould on 1/29/2015.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Stores a subset of information for a gateway which will be launched after a restart or retarget.static final class
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
cleanDirectory
(File directory) Cleans a directory without deleting it.static void
static long
static void
deleteDirectory
(File directory) Deletes a directory recursively.static long
downloadFile
(URL url, int readTimeout, File destination) Downloads the file that exists at the url and saves it to the supplied destination file.static void
forceDelete
(File file) gatewayInfo
(GatewayAddress target) Retrieves the target gateway addresses gw info from the GatewayInfoServlet.static File
getJarParentFolder
(File resourcesDir, LaunchManifest.Module m, LaunchManifest.Jar j) Given the root of the cache/resources/ folder, returns the correct parent folder for a given jar file, right before the specific CRC subfolders.static String
getStringResponse
(URL url, int readTimeout) launchJarCompatible
(GatewayAddress target, File launchJar) 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.static String
static HttpURLConnection
newConnection
(URL url, int readTimeout) Returns a new "GET" HttpURLConnection with the default connect timeout of 15 seconds and a read timeout based on the supplied value.static String
readFileAsString
(File file) static String
Sanitizes a string to be compatible with filename / foldername requirements by replacing illegal chars with underscores.static File
Returns a subdir and tries to create it if necessary.static File
static File
static void
writeStringToFile
(String string, File file)
-
Method Details
-
subdir
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
Sanitizes a string to be compatible with filename / foldername requirements by replacing illegal chars with underscores. -
crc
- Throws:
IOException
-
md5
- Throws:
IOException
-
deleteDirectory
Deletes a directory recursively.- Parameters:
directory
- directory to delete- Throws:
IOException
- in case deletion is unsuccessful
-
cleanDirectory
Cleans a directory without deleting it.- Parameters:
directory
- directory to clean- Throws:
IOException
- in case cleaning is unsuccessful
-
forceDelete
- Throws:
IOException
-
subfile
-
subfile
-
copyFile
- Throws:
IOException
-
readFileAsString
- Throws:
IOException
-
writeStringToFile
- 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
- Throws:
IOException
-
downloadFile
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
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
-