Class BootstrapUtilities
- java.lang.Object
-
- com.inductiveautomation.ignition.client.launch.BootstrapUtilities
-
public class BootstrapUtilities extends java.lang.ObjectCreated by carl.gould on 1/29/2015.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBootstrapUtilities.LaunchJarResults
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcleanDirectory(java.io.File directory)Cleans a directory without deleting it.static voidcopyFile(java.io.File in, java.io.File out)static longcrc(java.io.File jarFile)static voiddeleteDirectory(java.io.File directory)Deletes a directory recursively.static longdownloadFile(java.net.URL url, int readTimeout, java.io.File destination)Downloads the file that exists at the url and saves it to the supplied destination file.static voidforceDelete(java.io.File file)static java.io.FilegetJarParentFolder(java.io.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 java.lang.StringgetStringResponse(java.net.URL url, int readTimeout)static BootstrapUtilities.LaunchJarResultslaunchJarCompatible(GatewayAddress target, java.io.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 java.lang.Stringmd5(java.io.File file)static java.net.HttpURLConnectionnewConnection(java.net.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 java.lang.StringreadFileAsString(java.io.File file)static java.lang.Stringsanitize(java.lang.String s)Sanitizes a string to be compatible with filename / foldername requirements by replacing illegal chars with underscores.static java.io.Filesubdir(java.io.File parent, java.lang.String child)Returns a subdir and tries to create it if necessary.static java.io.Filesubfile(java.io.File base, java.lang.String filePath)static java.io.Filesubfile(java.io.File base, java.lang.String... subDirs)static voidwriteStringToFile(java.lang.String string, java.io.File file)
-
-
-
Method Detail
-
subdir
public static java.io.File subdir(java.io.File parent, java.lang.String child) throws java.lang.ExceptionReturns a subdir and tries to create it if necessary. Throws an error if the dir can't be created- Throws:
java.lang.Exception
-
getJarParentFolder
public static java.io.File getJarParentFolder(java.io.File resourcesDir, LaunchManifest.Module m, LaunchManifest.Jar j) throws java.lang.ExceptionGiven the root of the cache/resources/ folder, returns the correct parent folder for a given jar file, right before the specific CRC subfolders.- Throws:
java.lang.Exception
-
sanitize
public static java.lang.String sanitize(java.lang.String s)
Sanitizes a string to be compatible with filename / foldername requirements by replacing illegal chars with underscores.
-
crc
public static long crc(java.io.File jarFile) throws java.io.IOException- Throws:
java.io.IOException
-
md5
public static java.lang.String md5(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
deleteDirectory
public static void deleteDirectory(java.io.File directory) throws java.io.IOExceptionDeletes a directory recursively.- Parameters:
directory- directory to delete- Throws:
java.io.IOException- in case deletion is unsuccessful
-
cleanDirectory
public static void cleanDirectory(java.io.File directory) throws java.io.IOExceptionCleans a directory without deleting it.- Parameters:
directory- directory to clean- Throws:
java.io.IOException- in case cleaning is unsuccessful
-
forceDelete
public static void forceDelete(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
subfile
public static java.io.File subfile(java.io.File base, java.lang.String filePath)
-
subfile
public static java.io.File subfile(java.io.File base, java.lang.String... subDirs)
-
copyFile
public static void copyFile(java.io.File in, java.io.File out) throws java.io.IOException- Throws:
java.io.IOException
-
readFileAsString
public static java.lang.String readFileAsString(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
writeStringToFile
public static void writeStringToFile(java.lang.String string, java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
launchJarCompatible
public static BootstrapUtilities.LaunchJarResults launchJarCompatible(GatewayAddress target, java.io.File launchJar) throws java.io.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:
java.io.IOException
-
getStringResponse
public static java.lang.String getStringResponse(java.net.URL url, int readTimeout) throws java.io.IOException- Throws:
java.io.IOException
-
downloadFile
public static long downloadFile(java.net.URL url, int readTimeout, java.io.File destination) throws java.io.IOExceptionDownloads 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:
java.io.IOException
-
newConnection
public static java.net.HttpURLConnection newConnection(java.net.URL url, int readTimeout) throws java.io.IOExceptionReturns 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:
java.io.IOException
-
-