Program: 172089
Project: 172089
Buggy source:
/** 
 * Installs a given AMP file into a given WAR file.
 * @param ampFileLocation   the location of the AMP file to be installed
 * @param warFileLocation   the location of the WAR file into which the AMP file is to be installed.
 * @param preview           indicates whether this should be a preview install.  This means that the process of installation will be followed and reported, but the WAR file will not be modified.
 * @param forceInstall      indicates whether the installed files will be replaces reguarless of the currently installed version of the AMP.  Generally used during development of the AMP.
 * @param backupWAR         indicates whether we should backup the war we are modifying or not
 */
public void installModule(String ampFileLocation,String warFileLocation,boolean preview,boolean forceInstall,boolean backupWAR){
  try {
    outputMessage("String_Node_Str" + ampFileLocation + "String_Node_Str"+ warFileLocation+ "String_Node_Str");
    java.io.File theWar=new File(warFileLocation,DETECTOR_AMP_AND_WAR);
    if (preview == false) {
      File moduleDir=new File(warFileLocation + WarHelper.MODULE_NAMESPACE_DIR,DETECTOR_AMP_AND_WAR);
      if (moduleDir.exists() == false) {
        moduleDir.mkdir();
      }
      File backUpDir=new File(warFileLocation + BACKUP_DIR,DETECTOR_AMP_AND_WAR);
      if (backUpDir.exists() == false) {
        backUpDir.mkdir();
      }
      if (backupWAR == true) {
        java.io.File warFile=new java.io.File(warFileLocation);
        if (warFile.exists() == false) {
          throw new ModuleManagementToolException("String_Node_Str" + warFileLocation + "String_Node_Str");
        }
        String backupLocation=warFileLocation + "String_Node_Str" + System.currentTimeMillis()+ "String_Node_Str";
        java.io.File backup=new java.io.File(backupLocation);
        copyFile(warFile,backup);
        outputMessage("String_Node_Str" + backupLocation + "String_Node_Str");
      }
    }
    String propertiesLocation=ampFileLocation + "String_Node_Str";
    ModuleDetails installingModuleDetails=ModuleDetailsHelper.createModuleDetailsFromPropertyLocation(propertiesLocation);
    if (installingModuleDetails == null) {
      throw new ModuleManagementToolException("String_Node_Str" + ampFileLocation + "String_Node_Str");
    }
    String installingId=installingModuleDetails.getId();
    VersionNumber installingVersion=installingModuleDetails.getVersion();
    warHelper.checkCompatibleVersion(theWar,installingModuleDetails);
    warHelper.checkCompatibleEdition(theWar,installingModuleDetails);
    warHelper.checkModuleDependencies(theWar,installingModuleDetails);
    ModuleDetails installedModuleDetails=warHelper.getModuleDetailsOrAlias(theWar,installingModuleDetails);
    if (installedModuleDetails != null) {
      String installedId=installedModuleDetails.getId();
      VersionNumber installedVersion=installedModuleDetails.getVersion();
      int compareValue=installedVersion.compareTo(installingVersion);
      if (compareValue > 0) {
        outputMessage("String_Node_Str" + "String_Node_Str",false);
        return;
      }
      if (forceInstall == true) {
        outputMessage("String_Node_Str",false);
      }
      if (compareValue == 0) {
        outputMessage("String_Node_Str",false);
      }
      if (forceInstall == true || compareValue <= 0) {
        outputMessage("String_Node_Str" + installedVersion + "String_Node_Str"+ installedId+ "String_Node_Str",false);
        uninstallModule(installedId,warFileLocation,preview,true);
      }
    }
    Properties fileMappingProperties=null;
    Properties customFileMappingProperties=getCustomFileMappings(ampFileLocation);
    if (customFileMappingProperties == null) {
      fileMappingProperties=defaultFileMappingProperties;
    }
 else {
      fileMappingProperties=new Properties();
      String inheritDefaultStr=customFileMappingProperties.getProperty(PROP_INHERIT_DEFAULT,"String_Node_Str");
      if (inheritDefaultStr.equalsIgnoreCase("String_Node_Str")) {
        fileMappingProperties.putAll(defaultFileMappingProperties);
      }
      fileMappingProperties.putAll(customFileMappingProperties);
      fileMappingProperties.remove(PROP_INHERIT_DEFAULT);
    }
    outputMessage("String_Node_Str" + installingVersion + "String_Node_Str"+ installingId+ "String_Node_Str");
    InstalledFiles installedFiles=new InstalledFiles(warFileLocation,installingId);
    for (    Map.Entry<Object,Object> entry : fileMappingProperties.entrySet()) {
      String mappingSource=(String)entry.getKey();
      if (mappingSource.length() == 0 || !mappingSource.startsWith("String_Node_Str")) {
        throw new AlfrescoRuntimeException("String_Node_Str" + mappingSource);
      }
      String mappingTarget=(String)entry.getValue();
      if (mappingTarget.length() == 0 || !mappingTarget.startsWith("String_Node_Str")) {
        throw new AlfrescoRuntimeException("String_Node_Str" + mappingTarget + "String_Node_Str");
      }
      copyToWar(ampFileLocation,warFileLocation,mappingSource,mappingTarget,installedFiles,preview);
      if (preview == false) {
        File source=new File(ampFileLocation + "String_Node_Str" + mappingSource,DETECTOR_AMP_AND_WAR);
        if (source != null && source.list() != null) {
          File destination=new File(warFileLocation + "String_Node_Str" + mappingTarget,DETECTOR_AMP_AND_WAR);
          if (destination == null) {
            throw new ModuleManagementToolException("String_Node_Str" + mappingTarget + "String_Node_Str");
          }
          destination.copyAllFrom(source);
        }
      }
    }
    if (preview == false) {
      installedFiles.save();
      installingModuleDetails.setInstallState(ModuleInstallState.INSTALLED);
      installingModuleDetails.setInstallDate(new Date());
      ModuleDetailsHelper.saveModuleDetails(warFileLocation,installingModuleDetails);
      File.update();
      java.io.File warFile=new java.io.File(warFileLocation);
      if (warFile.exists()) {
        warFile.setLastModified(System.currentTimeMillis());
      }
    }
  }
 catch (  ZipWarningException ignore) {
  }
catch (  ZipControllerException exception) {
    throw new ModuleManagementToolException("String_Node_Str",exception);
  }
catch (  IOException exception) {
    throw new ModuleManagementToolException("String_Node_Str",exception);
  }
}

Fixed version (ground truth):
/** 
 * Installs a given AMP file into a given WAR file.
 * @param ampFileLocation   the location of the AMP file to be installed
 * @param warFileLocation   the location of the WAR file into which the AMP file is to be installed.
 * @param preview           indicates whether this should be a preview install.  This means that the process of installation will be followed and reported, but the WAR file will not be modified.
 * @param forceInstall      indicates whether the installed files will be replaces reguarless of the currently installed version of the AMP.  Generally used during development of the AMP.
 * @param backupWAR         indicates whether we should backup the war we are modifying or not
 */
public void installModule(String ampFileLocation,String warFileLocation,boolean preview,boolean forceInstall,boolean backupWAR){
  try {
    outputMessage("String_Node_Str" + ampFileLocation + "String_Node_Str"+ warFileLocation+ "String_Node_Str");
    java.io.File theWar=new File(warFileLocation,DETECTOR_AMP_AND_WAR);
    if (!theWar.exists()) {
      throw new ModuleManagementToolException("String_Node_Str" + warFileLocation + "String_Node_Str");
    }
    if (preview == false) {
      File moduleDir=new File(warFileLocation + WarHelper.MODULE_NAMESPACE_DIR,DETECTOR_AMP_AND_WAR);
      if (moduleDir.exists() == false) {
        moduleDir.mkdir();
      }
      File backUpDir=new File(warFileLocation + BACKUP_DIR,DETECTOR_AMP_AND_WAR);
      if (backUpDir.exists() == false) {
        backUpDir.mkdir();
      }
      if (backupWAR == true) {
        java.io.File warFile=new java.io.File(warFileLocation);
        String backupLocation=warFileLocation + "String_Node_Str" + System.currentTimeMillis()+ "String_Node_Str";
        java.io.File backup=new java.io.File(backupLocation);
        copyFile(warFile,backup);
        outputMessage("String_Node_Str" + backupLocation + "String_Node_Str");
      }
    }
    String propertiesLocation=ampFileLocation + "String_Node_Str";
    ModuleDetails installingModuleDetails=ModuleDetailsHelper.createModuleDetailsFromPropertyLocation(propertiesLocation);
    if (installingModuleDetails == null) {
      throw new ModuleManagementToolException("String_Node_Str" + ampFileLocation + "String_Node_Str");
    }
    String installingId=installingModuleDetails.getId();
    VersionNumber installingVersion=installingModuleDetails.getVersion();
    warHelper.checkCompatibleVersion(theWar,installingModuleDetails);
    warHelper.checkCompatibleEdition(theWar,installingModuleDetails);
    warHelper.checkModuleDependencies(theWar,installingModuleDetails);
    ModuleDetails installedModuleDetails=warHelper.getModuleDetailsOrAlias(theWar,installingModuleDetails);
    if (installedModuleDetails != null) {
      String installedId=installedModuleDetails.getId();
      VersionNumber installedVersion=installedModuleDetails.getVersion();
      int compareValue=installedVersion.compareTo(installingVersion);
      if (compareValue > 0) {
        outputMessage("String_Node_Str" + "String_Node_Str",false);
        return;
      }
      if (forceInstall == true) {
        outputMessage("String_Node_Str",false);
      }
      if (compareValue == 0) {
        outputMessage("String_Node_Str",false);
      }
      if (forceInstall == true || compareValue <= 0) {
        outputMessage("String_Node_Str" + installedVersion + "String_Node_Str"+ installedId+ "String_Node_Str",false);
        uninstallModule(installedId,warFileLocation,preview,true);
      }
    }
    Properties fileMappingProperties=null;
    Properties customFileMappingProperties=getCustomFileMappings(ampFileLocation);
    if (customFileMappingProperties == null) {
      fileMappingProperties=defaultFileMappingProperties;
    }
 else {
      fileMappingProperties=new Properties();
      String inheritDefaultStr=customFileMappingProperties.getProperty(PROP_INHERIT_DEFAULT,"String_Node_Str");
      if (inheritDefaultStr.equalsIgnoreCase("String_Node_Str")) {
        fileMappingProperties.putAll(defaultFileMappingProperties);
      }
      fileMappingProperties.putAll(customFileMappingProperties);
      fileMappingProperties.remove(PROP_INHERIT_DEFAULT);
    }
    outputMessage("String_Node_Str" + installingVersion + "String_Node_Str"+ installingId+ "String_Node_Str");
    InstalledFiles installedFiles=new InstalledFiles(warFileLocation,installingId);
    for (    Map.Entry<Object,Object> entry : fileMappingProperties.entrySet()) {
      String mappingSource=(String)entry.getKey();
      if (mappingSource.length() == 0 || !mappingSource.startsWith("String_Node_Str")) {
        throw new AlfrescoRuntimeException("String_Node_Str" + mappingSource);
      }
      String mappingTarget=(String)entry.getValue();
      if (mappingTarget.length() == 0 || !mappingTarget.startsWith("String_Node_Str")) {
        throw new AlfrescoRuntimeException("String_Node_Str" + mappingTarget + "String_Node_Str");
      }
      copyToWar(ampFileLocation,warFileLocation,mappingSource,mappingTarget,installedFiles,preview);
      if (preview == false) {
        File source=new File(ampFileLocation + "String_Node_Str" + mappingSource,DETECTOR_AMP_AND_WAR);
        if (source != null && source.list() != null) {
          File destination=new File(warFileLocation + "String_Node_Str" + mappingTarget,DETECTOR_AMP_AND_WAR);
          if (destination == null) {
            throw new ModuleManagementToolException("String_Node_Str" + mappingTarget + "String_Node_Str");
          }
          destination.copyAllFrom(source);
        }
      }
    }
    if (preview == false) {
      installedFiles.save();
      installingModuleDetails.setInstallState(ModuleInstallState.INSTALLED);
      installingModuleDetails.setInstallDate(new Date());
      ModuleDetailsHelper.saveModuleDetails(warFileLocation,installingModuleDetails);
      File.update();
      java.io.File warFile=new java.io.File(warFileLocation);
      if (warFile.exists()) {
        warFile.setLastModified(System.currentTimeMillis());
      }
    }
  }
 catch (  ZipWarningException ignore) {
  }
catch (  ZipControllerException exception) {
    throw new ModuleManagementToolException("String_Node_Str",exception);
  }
catch (  IOException exception) {
    throw new ModuleManagementToolException("String_Node_Str",exception);
  }
}