diff --git a/src/distMaker/DistMakerEngine.java b/src/distMaker/DistMakerEngine.java index d13875b..00b0c4b 100644 --- a/src/distMaker/DistMakerEngine.java +++ b/src/distMaker/DistMakerEngine.java @@ -33,9 +33,6 @@ import glum.util.ThreadUtil; public class DistMakerEngine { - // Constants - private final String NonDistmakerAppMsg = "This application does not appear to be a properly configured DistMaker application.\n\n" + "Please check installation configuration."; - // State vars private URL updateSiteUrl; private AppRelease currRelease; @@ -75,7 +72,7 @@ public class DistMakerEngine if (DistUtils.isDevelopersEnvironment() == true) displayNotice("Updates are not possible in a developer environment."); else - displayNotice(NonDistmakerAppMsg); + displayNotice(ErrorMsg.NonDistmakerApp); return; } appName = currRelease.getName(); @@ -187,7 +184,7 @@ public class DistMakerEngine { // Alert the user to the incongruence if this is not a developer's build if (DistUtils.isDevelopersEnvironment() == false) - displayNotice(NonDistmakerAppMsg); + displayNotice(ErrorMsg.NonDistmakerApp); return; } @@ -228,7 +225,7 @@ public class DistMakerEngine if (appName == null || verName == null) { - displayNotice(NonDistmakerAppMsg); + displayNotice(ErrorMsg.NonDistmakerApp); System.err.println("Failed to properly parse DistMaker config file: " + cfgFile); return; } @@ -757,13 +754,13 @@ public class DistMakerEngine if (jreList == null) { aTask.infoAppendln("The update site has not had any JREs deployed."); - aTask.infoAppendln("Please contact the update site adminstartor."); + aTask.infoAppendln(ErrorMsg.ContactSiteAdmin); return null; } if (jreList.size() == 0) { aTask.infoAppendln("No JRE releases found!"); - aTask.infoAppendln("Please contact the update site adminstartor."); + aTask.infoAppendln(ErrorMsg.ContactSiteAdmin); return null; } @@ -784,7 +781,7 @@ public class DistMakerEngine aTask.infoAppendln("There are no compatible JREs found on the deploy site. Available JREs: " + jreList.size()); for (JreRelease aJreRelease : jreList) aTask.infoAppendln("\t" + aJreRelease.getFileName() + " ---> (JRE: " + aJreRelease.getVersion().getLabel() + ")"); - aTask.infoAppendln("\nPlease contact the update site adminstartor."); + aTask.infoAppendln("\n" + ErrorMsg.ContactSiteAdmin); return null; } JreVersion pickJreVer = pickJre.getVersion(); @@ -838,7 +835,7 @@ public class DistMakerEngine // Unpack the JRE to the working unpack folder. Ensure that the unpacked JRE results in 1 top level folder. tmpTask = new PartialTask(aTask, aTask.getProgress(), (tmpFileLen * 0.25) / (releaseSizeFull + 0.00)); - MiscUtils.unTar(tmpTask, dstFile, unpackPath); + MiscUtils.unPack(tmpTask, dstFile, unpackPath); File[] fileArr = unpackPath.listFiles(); if (fileArr.length != 1 && fileArr[0].isDirectory() == false) throw new Exception("Expected only one (top level) folder to be unpacked. Items extracted: " + fileArr.length + " Path: " + unpackPath); @@ -1123,19 +1120,15 @@ public class DistMakerEngine } // Setup the runnable that will clean up our delta folder - Runnable cleanDeltaRunnable = new Runnable() + Runnable cleanDeltaRunnable = () -> { - @Override - public void run() - { - // Remove the delta folder (if it exists) - File deltaPath = new File(DistUtils.getAppPath().getParentFile(), "delta"); - if (deltaPath.isDirectory() == false) - return; + // Remove the delta folder (if it exists) + File deltaPath = new File(DistUtils.getAppPath().getParentFile(), "delta"); + if (deltaPath.isDirectory() == false) + return; - if (IoUtil.deleteDirectory(deltaPath) == false) - System.err.println("Failed to remove delta path. Cleanup after update was not fully completed."); - } + if (IoUtil.deleteDirectory(deltaPath) == false) + System.err.println("Failed to remove delta path. Cleanup after update was not fully completed."); }; // Show the message panel and execute cleanDeltaRunnable diff --git a/src/distMaker/ErrorMsg.java b/src/distMaker/ErrorMsg.java new file mode 100644 index 0000000..dbb15ce --- /dev/null +++ b/src/distMaker/ErrorMsg.java @@ -0,0 +1,13 @@ +package distMaker; + +/** + * Collection of error messages used within the DistMaker library. + * + * @author lopeznr1 + */ +public class ErrorMsg +{ + // Constants + public static final String ContactSiteAdmin = "Please contact the update site administrator."; + public static final String NonDistmakerApp = "This application does not appear to be a properly configured DistMaker application.\n\n" + "Please check installation configuration."; +} diff --git a/src/distMaker/MiscUtils.java b/src/distMaker/MiscUtils.java index 153c559..ddbf069 100644 --- a/src/distMaker/MiscUtils.java +++ b/src/distMaker/MiscUtils.java @@ -1,8 +1,5 @@ package distMaker; -import glum.task.Task; -import glum.util.ThreadUtil; - import java.io.*; import java.nio.file.Files; import java.nio.file.Path; @@ -10,16 +7,19 @@ import java.nio.file.attribute.PosixFilePermission; import java.nio.file.attribute.PosixFilePermissions; import java.util.*; import java.util.zip.GZIPInputStream; +import java.util.zip.ZipInputStream; -import org.apache.commons.compress.archivers.ArchiveException; -import org.apache.commons.compress.archivers.ArchiveStreamFactory; +import org.apache.commons.compress.archivers.*; import org.apache.commons.compress.archivers.tar.TarArchiveEntry; -import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; +import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; import org.apache.commons.compress.utils.IOUtils; import com.google.common.base.Strings; import com.google.common.io.CountingInputStream; +import glum.task.Task; +import glum.util.ThreadUtil; + /** * Collection of generic utility methods that should be migrated to another library / class. */ @@ -119,7 +119,7 @@ public class MiscUtils } /** - * Untar an input file into an output file. + * Unpacks an input file into an output file. *
* Source based off of:
* http://stackoverflow.com/questions/315618/how-do-i-extract-a-tar-file-in-java/7556307#7556307
@@ -128,7 +128,7 @@ public class MiscUtils
* extension.
*
* @param inputFile
- * the input .tar file
+ * the input .tar.gz or zip file
* @param aDestPath
* The destination folder where the content will be dumped.
* @throws IOException
@@ -136,7 +136,7 @@ public class MiscUtils
* @return The {@link List} of {@link File}s with the untared content.
* @throws ArchiveException
*/
- public static List