Program: 189360
Project: 189360
Buggy source:
@Override public ExportPackage generatePackage(Submission submission){
  if (submission == null || submission.getId() == null)   throw new IllegalArgumentException("String_Node_Str");
  if (templateFile == null)   throw new IllegalStateException("String_Node_Str");
  if (manifestName == null)   throw new IllegalStateException("String_Node_Str");
  if (format == null)   throw new IllegalStateException("String_Node_Str");
  try {
    Map<String,String> parameters=new HashMap<String,String>();
    parameters=StringVariableReplacement.setParameters(submission);
    String manifestNameTemplate=manifestName;
    manifestName=StringVariableReplacement.applyParameterSubstitution(manifestName,parameters);
    String entryNameTemplate=entryName;
    String customEntryName=StringVariableReplacement.applyParameterSubstitution(entryName,parameters);
    Map<String,Object> templateBinding=new HashMap<String,Object>();
    templateBinding.put("String_Node_Str",submission);
    templateBinding.put("String_Node_Str",personRepo);
    templateBinding.put("String_Node_Str",subRepo);
    templateBinding.put("String_Node_Str",settingRepo);
    templateBinding.put("String_Node_Str",proquestRepo);
    templateBinding.put("String_Node_Str",packageType);
    templateBinding.put("String_Node_Str",manifestName);
    templateBinding.put("String_Node_Str",entryName);
    templateBinding.put("String_Node_Str",format);
    templateBinding.put("String_Node_Str",mimeType);
    templateBinding.put("String_Node_Str",attachmentTypes);
    if (templateArguments != null)     templateBinding.putAll(templateArguments);
    Template template=TemplateLoader.load(templateFile);
    String manifest=template.render(templateBinding);
    File pkg=null;
    if (packageType.equals("String_Node_Str")) {
      pkg=File.createTempFile("String_Node_Str","String_Node_Str");
      FileOutputStream fos=new FileOutputStream(pkg);
      ZipOutputStream zos=new ZipOutputStream(fos);
      File manifestFile=new File(manifestName);
      FileUtils.writeStringToFile(manifestFile,manifest);
      ZipEntry ze=new ZipEntry(manifestName);
      zos.putNextEntry(ze);
      FileInputStream in=new FileInputStream(manifestFile);
      byte[] buf=new byte[1024];
      int len;
      while ((len=in.read(buf)) > 0) {
        zos.write(buf,0,len);
      }
      in.close();
      zos.closeEntry();
      manifestFile.delete();
      if (attachmentTypes.size() > 0) {
        for (        Attachment attachment : submission.getAttachments()) {
          if (!attachmentTypes.contains(attachment.getType()))           continue;
          String shortFileName=attachment.getName().replaceAll("String_Node_Str" + FilenameUtils.getExtension(attachment.getName()),"String_Node_Str");
          String fileName=attachment.getName();
          if (attachmentAttributes.get(attachment.getType().name()).get("String_Node_Str") != null) {
            fileName=attachmentAttributes.get(attachment.getType().name()).get("String_Node_Str") + "String_Node_Str" + FilenameUtils.getExtension(attachment.getName());
            fileName=fileName.replace("String_Node_Str",shortFileName);
            fileName=StringVariableReplacement.applyParameterSubstitution(fileName,parameters);
          }
          File exportFile=null;
          Boolean hasDir=false;
          if (attachmentAttributes.get(attachment.getType().name()).get("String_Node_Str") != null) {
            String dirName=(String)attachmentAttributes.get(attachment.getType().name()).get("String_Node_Str");
            dirName=dirName.replace("String_Node_Str",shortFileName);
            dirName=StringVariableReplacement.applyParameterSubstitution(dirName,parameters);
            exportFile=new File(dirName,fileName);
            fileName=dirName + fileName;
            hasDir=true;
          }
 else {
            exportFile=new File(fileName);
          }
          FileUtils.copyFile(attachment.getFile(),exportFile);
          ze=new ZipEntry(fileName);
          zos.putNextEntry(ze);
          in=new FileInputStream(exportFile);
          while ((len=in.read(buf)) > 0) {
            zos.write(buf,0,len);
          }
          in.close();
          zos.closeEntry();
          if (hasDir) {
            FileUtils.deleteDirectory(exportFile.getParentFile());
          }
 else {
            exportFile.delete();
          }
        }
        zos.close();
        fos.close();
      }
    }
 else {
      if (attachmentTypes.size() > 0) {
        pkg=File.createTempFile("String_Node_Str","String_Node_Str");
        pkg.delete();
        pkg.mkdir();
        File manifestFile=new File(pkg.getPath(),manifestName);
        FileUtils.writeStringToFile(manifestFile,manifest);
        for (        Attachment attachment : submission.getAttachments()) {
          if (!attachmentTypes.contains(attachment.getType()))           continue;
          String shortFileName=attachment.getName().replaceAll("String_Node_Str" + FilenameUtils.getExtension(attachment.getName()),"String_Node_Str");
          String fileName=attachment.getName();
          if (attachmentAttributes.get(attachment.getType().name()).get("String_Node_Str") != null) {
            fileName=attachmentAttributes.get(attachment.getType().name()).get("String_Node_Str") + "String_Node_Str" + FilenameUtils.getExtension(attachment.getName());
            fileName=fileName.replace("String_Node_Str",shortFileName);
            fileName=StringVariableReplacement.applyParameterSubstitution(fileName,parameters);
          }
          String pkgPath=pkg.getPath();
          if (attachmentAttributes.get(attachment.getType().name()).get("String_Node_Str") != null) {
            String dirName=(String)attachmentAttributes.get(attachment.getType().name()).get("String_Node_Str");
            dirName=dirName.replace("String_Node_Str",shortFileName);
            dirName=StringVariableReplacement.applyParameterSubstitution(dirName,parameters);
            pkgPath=pkgPath + File.separator + dirName;
          }
          File exportFile=new File(pkgPath,fileName);
          FileUtils.copyFile(attachment.getFile(),exportFile);
        }
      }
 else {
        String extension=FilenameUtils.getExtension(manifestName);
        if (extension.length() > 0)         extension="String_Node_Str" + extension;
        pkg=File.createTempFile("String_Node_Str",extension);
        FileUtils.writeStringToFile(pkg,manifest);
      }
    }
    this.setManifestName(manifestNameTemplate);
    this.setEntryName(entryNameTemplate);
    return new TemplatePackage(submission,mimeType,format,pkg,customEntryName);
  }
 catch (  IOException ioe) {
    throw new RuntimeException("String_Node_Str",ioe);
  }
}

Fixed version (ground truth):
@Override public ExportPackage generatePackage(Submission submission){
  if (submission == null || submission.getId() == null)   throw new IllegalArgumentException("String_Node_Str");
  if (templateFile == null)   throw new IllegalStateException("String_Node_Str");
  if (manifestName == null)   throw new IllegalStateException("String_Node_Str");
  if (format == null)   throw new IllegalStateException("String_Node_Str");
  try {
    Map<String,String> parameters=new HashMap<String,String>();
    parameters=StringVariableReplacement.setParameters(submission);
    String manifestNameTemplate=manifestName;
    manifestName=StringVariableReplacement.applyParameterSubstitution(manifestName,parameters);
    String entryNameTemplate=entryName;
    String customEntryName=StringVariableReplacement.applyParameterSubstitution(entryName,parameters);
    Map<String,Object> templateBinding=new HashMap<String,Object>();
    templateBinding.put("String_Node_Str",submission);
    templateBinding.put("String_Node_Str",personRepo);
    templateBinding.put("String_Node_Str",subRepo);
    templateBinding.put("String_Node_Str",settingRepo);
    templateBinding.put("String_Node_Str",proquestRepo);
    templateBinding.put("String_Node_Str",packageType);
    templateBinding.put("String_Node_Str",manifestName);
    templateBinding.put("String_Node_Str",entryName);
    templateBinding.put("String_Node_Str",format);
    templateBinding.put("String_Node_Str",mimeType);
    templateBinding.put("String_Node_Str",attachmentTypes);
    if (templateArguments != null)     templateBinding.putAll(templateArguments);
    Template template=TemplateLoader.load(templateFile);
    String manifest=template.render(templateBinding);
    File pkg=null;
    if (packageType.equals("String_Node_Str")) {
      pkg=File.createTempFile("String_Node_Str","String_Node_Str");
      FileOutputStream fos=new FileOutputStream(pkg);
      ZipOutputStream zos=new ZipOutputStream(fos);
      File manifestFile=File.createTempFile(manifestName,null);
      FileUtils.writeStringToFile(manifestFile,manifest);
      ZipEntry ze=new ZipEntry(manifestName);
      zos.putNextEntry(ze);
      FileInputStream in=new FileInputStream(manifestFile);
      byte[] buf=new byte[1024];
      int len;
      while ((len=in.read(buf)) > 0) {
        zos.write(buf,0,len);
      }
      in.close();
      zos.closeEntry();
      manifestFile.delete();
      if (attachmentTypes.size() > 0) {
        for (        Attachment attachment : submission.getAttachments()) {
          if (!attachmentTypes.contains(attachment.getType()))           continue;
          String shortFileName=attachment.getName().replaceAll("String_Node_Str" + FilenameUtils.getExtension(attachment.getName()),"String_Node_Str");
          String fileName=attachment.getName();
          if (attachmentAttributes.get(attachment.getType().name()).get("String_Node_Str") != null) {
            fileName=attachmentAttributes.get(attachment.getType().name()).get("String_Node_Str") + "String_Node_Str" + FilenameUtils.getExtension(attachment.getName());
            fileName=fileName.replace("String_Node_Str",shortFileName);
            fileName=StringVariableReplacement.applyParameterSubstitution(fileName,parameters);
          }
          File exportFile=null;
          Boolean hasDir=false;
          String dirName=null;
          if (attachmentAttributes.get(attachment.getType().name()).get("String_Node_Str") != null) {
            dirName=(String)attachmentAttributes.get(attachment.getType().name()).get("String_Node_Str");
            dirName=dirName.replace("String_Node_Str",shortFileName);
            dirName=StringVariableReplacement.applyParameterSubstitution(dirName,parameters);
            fileName=dirName + fileName;
            hasDir=true;
          }
          exportFile=File.createTempFile(fileName,null);
          FileUtils.copyFile(attachment.getFile(),exportFile);
          ze=new ZipEntry(fileName);
          zos.putNextEntry(ze);
          in=new FileInputStream(exportFile);
          while ((len=in.read(buf)) > 0) {
            zos.write(buf,0,len);
          }
          in.close();
          zos.closeEntry();
          if (hasDir && dirName != null) {
            FileUtils.deleteDirectory(new File(dirName));
          }
 else {
            exportFile.delete();
          }
        }
        zos.close();
        fos.close();
      }
    }
 else {
      if (attachmentTypes.size() > 0) {
        pkg=File.createTempFile("String_Node_Str","String_Node_Str");
        pkg.delete();
        pkg.mkdir();
        File manifestFile=new File(pkg.getPath(),manifestName);
        FileUtils.writeStringToFile(manifestFile,manifest);
        for (        Attachment attachment : submission.getAttachments()) {
          if (!attachmentTypes.contains(attachment.getType()))           continue;
          String shortFileName=attachment.getName().replaceAll("String_Node_Str" + FilenameUtils.getExtension(attachment.getName()),"String_Node_Str");
          String fileName=attachment.getName();
          if (attachmentAttributes.get(attachment.getType().name()).get("String_Node_Str") != null) {
            fileName=attachmentAttributes.get(attachment.getType().name()).get("String_Node_Str") + "String_Node_Str" + FilenameUtils.getExtension(attachment.getName());
            fileName=fileName.replace("String_Node_Str",shortFileName);
            fileName=StringVariableReplacement.applyParameterSubstitution(fileName,parameters);
          }
          String pkgPath=pkg.getPath();
          if (attachmentAttributes.get(attachment.getType().name()).get("String_Node_Str") != null) {
            String dirName=(String)attachmentAttributes.get(attachment.getType().name()).get("String_Node_Str");
            dirName=dirName.replace("String_Node_Str",shortFileName);
            dirName=StringVariableReplacement.applyParameterSubstitution(dirName,parameters);
            pkgPath=pkgPath + File.separator + dirName;
          }
          File exportFile=new File(pkgPath,fileName);
          FileUtils.copyFile(attachment.getFile(),exportFile);
        }
      }
 else {
        String extension=FilenameUtils.getExtension(manifestName);
        if (extension.length() > 0)         extension="String_Node_Str" + extension;
        pkg=File.createTempFile("String_Node_Str",extension);
        FileUtils.writeStringToFile(pkg,manifest);
      }
    }
    this.setManifestName(manifestNameTemplate);
    this.setEntryName(entryNameTemplate);
    return new TemplatePackage(submission,mimeType,format,pkg,customEntryName);
  }
 catch (  IOException ioe) {
    throw new RuntimeException("String_Node_Str",ioe);
  }
}