/* * [ReplicatorCommon.java] * * Summary: ReplicatorCommon, code used by both send and receive. * * Copyright: (c) 2006-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 7.2 2006-02-11 add RETIREMENT property to delay deleting old zips. * 7.3 2006-03-05 reformat with IntelliJ and add Javadoc * 7.4 2007-05-30 * 7.5 2007-07-16 IntelliJ inspector. * 7.6 2007-07-19 refactor to use use enums, for:each, pass IntelliJ Inspector. * 7.7 2007-07-20 compress manifests * 7.8 2007-07-23 debugging logs, extra validations. * 7.9 2007-07-23 new way to do zip retires to avoid out-of-order bug. * 8.0 2007-07-28 fix log so works on virgin machines. * 8.1 2007-07-29 Remove Windows centric code. * 8.2 2007-07-30 properties file specified on the command line. * sender and receiver to make it work properly on Ubuntu. More * efficient unpacking of zips, bypassing work it has done * previously. * 8.3 2007-08-04 Use new version of FileTransfer with * timeouts, more efficient CPU use, etc. * 8.4 2007-08-18 merged clump, move fileLength to FD for verify. * 8.5 2007-09-02 better stats, can hit verify during download, more spacious layout. * 8.6 2007-09-13 reduced frequency of zip repacking * 8.7 2007-09-18 Fix zip order when deletions * 8.8 2007-09-20 flip to JDK 1.6 * 8.9 2007-09-22 now handles files that change length without changing date. * 9.0 2007-09-23 retirement time now specified in minutes rather than hours. * 9.1 2007-10-28 fix bug to ensure gui state persisted. * 9.2 2007-12-24 display range of times for retired. * 9.3 2008-01-07 emaciate and delete files in the same replicatorSender run. * 9.4 2008-01-28 calculate percentage of deadwood more conservatively * 9.5 2008-02-08 better error message if can't create dirs, tool tip help. * 9.6 2008-02-22 display computed lag and retirement timestamps * 9.7 2008-03-20 only unpack new files, not the entire zip. * 9.8 2008-03-28 fine tune generated JNLP * 9.9 2008-04-09 compact zips under tighter rules immediately after LAG days. * 10.0 2008-08-10 extend timeouts to be more patient with network congestion. * 10.1 2009-01-23 fix harmless bug in saving the internal state * 10.2 2009-04-03 tidy up code to check presence of necessary files to make it more WORA. * 10.3 2009-05-03 localise log output file with Localise and PrintWriterPortable * 10.4 2009-08-08 add RECOVER, HIGHEST_ACCEPTABLE_EXIT_CODE, MAX_UPLOAD_TRIES config parms. * 10.5 2011-04-22 fully automate StartOver.bat, so no additional copies are needed. * 10.6 2011-07-30 add support for Java 1.7 * 10.7 2011-08-05 add packing statistics * 10.8 2011-09-08 sort packing statistics, avoiding voids. * 10.9 2011-09-14 base stats on clumping, and stats on newest repackaged. * 11.0 2011-12-22 update the JNLP * 11.1 2012-03-15 serialise arrays instead of ArrayLists. Correct docs on how LAG works. * 11.2 2012-05-12 more consistent use of empty timestamp markers. Should make more compact uploads. * 11.3 2012-05-13 further more consistent use of empty markers. * 11.4 2014-04-06 bypass Oracle dropping support for JNLP properties. * 11.5 2014-08-19 modify SortedArrayList to account for JDK 1.8.0_20s fobbing Collections.sort on ArrayList.sort. * 11.6 2015-03-10 sign the jar. */ package com.mindprod.replicatorcommon; import java.awt.Toolkit; import static java.lang.System.*; /** * ReplicatorCommon, code used by both send and receive. * * @author Roedy Green, Canadian Mind Products * @version 11.6 2015-03-10 sign the jar. * @since 2006 */ public final class ReplicatorCommon { /** * when version released. Broadcast to related replicator packages. Leave public! */ @SuppressWarnings( { "UnusedDeclaration" } ) public static final String RELEASE_DATE = "2015-03-10"; /** * embedded version string. Broadcast to related replicator packages. Leave public! */ @SuppressWarnings( { "UnusedDeclaration" } ) public static final String VERSION_STRING = "11.6"; private static final int FIRST_COPYRIGHT_YEAR = 2006; /** * undisplayed copyright notice */ @SuppressWarnings( { "UnusedDeclaration" } ) private static final String EMBEDDED_COPYRIGHT = "Copyright: (c) 2006-2017 Roedy Green, Canadian Mind Products, http://mindprod.com"; /** * name of this application. */ @SuppressWarnings( { "UnusedDeclaration" } ) private static final String TITLE_STRING = "The Replicator Common library"; /** * Fatal error in send side, used in replicatorcommon. * * @param errorMessage what went wrong */ public static void fatal( String errorMessage ) { err.println( "F A T A L E R R O R" ); errorMessage += "\nReboot and try again later." + "\nIf problem persists, run startover.bat." + "\nIf problem still persists, ask for help from roedyg@mindprod.com."; Toolkit.getDefaultToolkit().beep(); err.println( errorMessage ); // Avoid dragging in all of Swing into JET executable just for this. // JOptionPane.showMessageDialog( null, // errorMessage, // "Fatal Error", // JOptionPane.ERROR_MESSAGE ); System.exit( 1 ); } /** * test harness, dummy * * @param args not used */ @SuppressWarnings( { "EmptyMethod" } ) public static void main( String[] args ) { } }