/** * Cleans the WAR file of all files relating to the currently installed version of the the AMP. * * @param warFileLocatio the war file location * @param moduleId the module id * @param preview indicates whether this is a preview installation */ private void cleanWAR(String warFileLocation, String moduleId, boolean preview) { InstalledFiles installedFiles = new InstalledFiles(warFileLocation, moduleId); installedFiles.load(); for (String add : installedFiles.getAdds()) { // Remove file removeFile(warFileLocation, add, preview); } for (String mkdir : installedFiles.getMkdirs()) { // Remove folder removeFile(warFileLocation, mkdir, preview); } for (Map.Entry<String, String> update : installedFiles.getUpdates().entrySet()) { if (preview == false) { // Recover updated file and delete backups File modified = new File(warFileLocation + update.getKey(), DETECTOR_AMP_AND_WAR); File backup = new File(warFileLocation + update.getValue(), DETECTOR_AMP_AND_WAR); modified.copyFrom(backup); backup.delete(); } outputMessage( "Recovering file '" + update.getKey() + "' from backup '" + update.getValue() + "'", true); } // Now remove the installed files list String installedFilesPathInWar = installedFiles.getFilePathInWar(); removeFile(warFileLocation, installedFilesPathInWar, preview); // Remove the module properties String modulePropertiesFileLocationInWar = ModuleDetailsHelper.getModulePropertiesFilePathInWar(moduleId); removeFile(warFileLocation, modulePropertiesFileLocationInWar, preview); }