// ************************* // *** constructor // *********************** public PreProcess() { // get current working directory File workingDirectory = new File(System.getProperty("user.dir")); // create File objects for source / destination directories File sourcePathFile = new File(workingDirectory, sourcePathName); File outputPathFile = new File(workingDirectory, outputPathName); // get File object for tracking directory File trackingFolderSourcePathFile = new File(workingDirectory, PHP_TRACKING_DIRECTORY_PATH); File trackingFolderDestinationPathFile = new File(workingDirectory, outputPathName + "/" + PHP_TRACKING_DIRECTORY_NAME); System.out.println("in constructor"); trace("PreProcess", "-----------------------------------step (0)", 0); trace("PreProcess", "(0) delete contents of output directory", 0); // (0) delete contents of output directory deleteAllFiles(outputPathFile); trace("PreProcess", "-----------------------------------step (1)", 0); trace( "PreProcess", "(1) copy all contents (including subdirectoies) from src to output directory", 0); // (1) copy all contents (including subdirectoies) from src to output directory copyDirectoryContents(sourcePathFile, outputPathFile); trace("PreProcess", "-----------------------------------step (2)", 0); trace("PreProcess", "(2) get list of '.html' files in this folder", 0); // (2) get list of ".html" files in this folder String[] htmlFileList = findFilesWithSuffix(outputPathFile, SUFFIX_HTML); for (int i = 0; i < htmlFileList.length; i++) { trace("PreProcess", "htmlFileList = " + htmlFileList[i], 0); } trace("PreProcess", "-----------------------------------step (3)", 0); trace("PreProcess", "(3) rename all these files as '.php'", 0); // (3) rename all these files as ".php" renameHTMLtoPHP(outputPathFile, htmlFileList); trace("PreProcess", "-----------------------------------step (4)", 0); trace("PreProcess", "(4) get list of '.php' files in this folder", 0); // (4) get list of ".php" files in this folder String[] phpFileList = findFilesWithSuffix(outputPathFile, SUFFIX_PHP); for (int i = 0; i < phpFileList.length; i++) { trace("PreProcess", "phpFileList = " + phpFileList[i], 0); } trace("PreProcess", "-----------------------------------step (5)", 0); trace("PreProcess", "(5) add PHP INCLUDE line in ALL PHP files in directory", 0); // (5) add PHP INCLUDE line in ALL PHP files in directory addTrackingCode(outputPathFile, phpFileList); trace("PreProcess", "-----------------------------------step (6)", 0); trace( "PreProcess", "(6) replace any references to the old '.html' files to the renamed '.php' files", 0); // (6) replace any references to the old ".html" files to the renamed ".php" files replaceHTMLReferences(outputPathFile, phpFileList, htmlFileList); trace("PreProcess", "-----------------------------------step (7)", 0); trace("PreProcess", "(7) copy user tracking files into output directory", 0); // (7) copy the user tracking files (and their directory) into the output folder copyDirectory(trackingFolderSourcePathFile, trackingFolderDestinationPathFile); trace("PreProcess", "----------------------------------------------------------", 0); trace("PreProcess", "-------------------- end of application ------------------", 0); trace("PreProcess", "----------------------------------------------------------", 0); } // constructor