Program: 137790
Project: 137790
Buggy source:
/** 
 * DOC xqliu Comment method "importToStucture".
 * @param importObject
 * @param selectionFolder
 * @param type
 * @param skip
 * @param rename
 * @param importItemName
 * @return
 */
public static List<ReturnCode> importToStucture(ImportObject importObject,IFolder selectionFolder,ExpressionType type,boolean skip,boolean rename,String importItemName){
  List<ReturnCode> importEvent=new ArrayList<ReturnCode>();
  Set<String> names=PatternUtilities.getNestFolderPatternNames(new HashSet<String>(),selectionFolder);
  File importFile=importObject.getObjFile();
  String fileExtName=getFileExtName(importFile);
  if ("String_Node_Str".equalsIgnoreCase(fileExtName)) {
    try {
      CsvReader reader=new CsvReader(new FileReader(importFile),CURRENT_SEPARATOR);
      reader.setEscapeMode(CsvReader.ESCAPE_MODE_DOUBLED);
      reader.setTextQualifier(TEXT_QUAL);
      reader.setUseTextQualifier(USE_TEXT_QUAL);
      reader.readHeaders();
      while (reader.readRecord()) {
        String name=reader.get(PatternToExcelEnum.Label.getLiteral());
        if (names.contains(name)) {
          if (skip) {
            importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",name),false));
            continue;
          }
          if (rename) {
            name=name + "String_Node_Str" + new Date()+ "String_Node_Str";
          }
        }
        PatternParameters patternParameters=new ImportFactory().new PatternParameters();
        patternParameters.name=name;
        patternParameters.auther=reader.get(PatternToExcelEnum.Author.getLiteral());
        patternParameters.description=reader.get(PatternToExcelEnum.Description.getLiteral());
        patternParameters.purpose=reader.get(PatternToExcelEnum.Purpose.getLiteral());
        patternParameters.relativePath=reader.get(PatternToExcelEnum.RelativePath.getLiteral());
        for (        PatternLanguageType languagetype : PatternLanguageType.values()) {
          String cellStr=reader.get(languagetype.getExcelEnum().getLiteral());
          if (cellStr != null && !cellStr.equals("String_Node_Str")) {
            patternParameters.regex.put(languagetype.getLiteral(),cellStr);
          }
        }
        try {
          String relativePath="String_Node_Str" + createAndStorePattern(patternParameters,selectionFolder,type);
          names.add(name);
          importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",name,relativePath),true));
        }
 catch (        Exception e) {
          importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",name),false));
        }
      }
      reader.close();
    }
 catch (    Exception e) {
      log.error(e,e);
      importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false));
    }
  }
  if ("String_Node_Str".equalsIgnoreCase(fileExtName)) {
    Map<Integer,PatternLanguageType> expressionMap=new HashMap<Integer,PatternLanguageType>();
    try {
      WorkbookSettings settings=new WorkbookSettings();
      settings.setEncoding("String_Node_Str");
      Workbook rwb=Workbook.getWorkbook(importFile,settings);
      Sheet[] sheets=rwb.getSheets();
      for (      Sheet sheet : sheets) {
        Cell[] headerRow=sheet.getRow(0);
        for (        Cell cell : headerRow) {
          for (          PatternLanguageType languageType : PatternLanguageType.values()) {
            if (cell.getContents().equals(languageType.getExcelEnum().getLiteral())) {
              expressionMap.put(cell.getColumn(),languageType);
            }
          }
        }
        for (int i=1; i < sheet.getRows(); i++) {
          Cell[] row=sheet.getRow(i);
          Cell cell=row[0];
          if (CellType.LABEL.equals(cell.getType())) {
            String contents=cell.getContents();
            if (names.contains(contents)) {
              if (skip) {
                importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",contents),false));
                continue;
              }
              if (rename) {
                contents=contents + "String_Node_Str" + new Date()+ "String_Node_Str";
              }
            }
            PatternParameters patternParameters=new ImportFactory().new PatternParameters();
            patternParameters.name=contents;
            patternParameters.auther=row[6].getContents();
            patternParameters.description=row[2].getContents();
            patternParameters.purpose=row[1].getContents();
            patternParameters.status=DevelopmentStatus.DRAFT.getLiteral();
            for (            int columnIndex : expressionMap.keySet()) {
              String rowContent=row[columnIndex].getContents();
              if (!rowContent.equals("String_Node_Str")) {
                patternParameters.regex.put(expressionMap.get(columnIndex).getLiteral(),rowContent);
              }
            }
            String relativePath="String_Node_Str" + createAndStorePattern(patternParameters,selectionFolder,type);
            names.add(contents);
            importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",contents,relativePath),true));
          }
        }
      }
      rwb.close();
    }
 catch (    BiffException e) {
      log.error(e,e);
      importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false));
    }
catch (    IOException e) {
      log.error(e,e);
      importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false));
    }
catch (    TalendInternalPersistenceException e) {
      log.error(e,e);
      importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false));
    }
  }
  importObject.copyJarFiles();
  checkImportEvent(importItemName,importEvent);
  return importEvent;
}

Fixed version (ground truth):
/** 
 * DOC xqliu Comment method "importToStucture".
 * @param importObject
 * @param selectionFolder
 * @param type
 * @param skip
 * @param rename
 * @param importItemName
 * @return
 */
public static List<ReturnCode> importToStucture(ImportObject importObject,IFolder selectionFolder,ExpressionType type,boolean skip,boolean rename,String importItemName){
  List<ReturnCode> importEvent=new ArrayList<ReturnCode>();
  Set<String> names=PatternUtilities.getNestFolderPatternNames(new HashSet<String>(),ResourceManager.getPatternFolder());
  File importFile=importObject.getObjFile();
  String fileExtName=getFileExtName(importFile);
  if ("String_Node_Str".equalsIgnoreCase(fileExtName)) {
    try {
      CsvReader reader=new CsvReader(new FileReader(importFile),CURRENT_SEPARATOR);
      reader.setEscapeMode(CsvReader.ESCAPE_MODE_DOUBLED);
      reader.setTextQualifier(TEXT_QUAL);
      reader.setUseTextQualifier(USE_TEXT_QUAL);
      reader.readHeaders();
      while (reader.readRecord()) {
        String name=reader.get(PatternToExcelEnum.Label.getLiteral());
        if (names.contains(name)) {
          if (skip) {
            importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",name),false));
            continue;
          }
          if (rename) {
            name=name + "String_Node_Str" + new Date()+ "String_Node_Str";
          }
        }
        PatternParameters patternParameters=new ImportFactory().new PatternParameters();
        patternParameters.name=name;
        patternParameters.auther=reader.get(PatternToExcelEnum.Author.getLiteral());
        patternParameters.description=reader.get(PatternToExcelEnum.Description.getLiteral());
        patternParameters.purpose=reader.get(PatternToExcelEnum.Purpose.getLiteral());
        patternParameters.relativePath=reader.get(PatternToExcelEnum.RelativePath.getLiteral());
        for (        PatternLanguageType languagetype : PatternLanguageType.values()) {
          String cellStr=reader.get(languagetype.getExcelEnum().getLiteral());
          if (cellStr != null && !cellStr.equals("String_Node_Str")) {
            patternParameters.regex.put(languagetype.getLiteral(),cellStr);
          }
        }
        try {
          String relativePath="String_Node_Str" + createAndStorePattern(patternParameters,selectionFolder,type);
          names.add(name);
          importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",name,relativePath),true));
        }
 catch (        Exception e) {
          importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",name),false));
        }
      }
      reader.close();
    }
 catch (    Exception e) {
      log.error(e,e);
      importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false));
    }
  }
  if ("String_Node_Str".equalsIgnoreCase(fileExtName)) {
    Map<Integer,PatternLanguageType> expressionMap=new HashMap<Integer,PatternLanguageType>();
    try {
      WorkbookSettings settings=new WorkbookSettings();
      settings.setEncoding("String_Node_Str");
      Workbook rwb=Workbook.getWorkbook(importFile,settings);
      Sheet[] sheets=rwb.getSheets();
      for (      Sheet sheet : sheets) {
        Cell[] headerRow=sheet.getRow(0);
        for (        Cell cell : headerRow) {
          for (          PatternLanguageType languageType : PatternLanguageType.values()) {
            if (cell.getContents().equals(languageType.getExcelEnum().getLiteral())) {
              expressionMap.put(cell.getColumn(),languageType);
            }
          }
        }
        for (int i=1; i < sheet.getRows(); i++) {
          Cell[] row=sheet.getRow(i);
          Cell cell=row[0];
          if (CellType.LABEL.equals(cell.getType())) {
            String contents=cell.getContents();
            if (names.contains(contents)) {
              if (skip) {
                importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",contents),false));
                continue;
              }
              if (rename) {
                contents=contents + "String_Node_Str" + new Date()+ "String_Node_Str";
              }
            }
            PatternParameters patternParameters=new ImportFactory().new PatternParameters();
            patternParameters.name=contents;
            patternParameters.auther=row[6].getContents();
            patternParameters.description=row[2].getContents();
            patternParameters.purpose=row[1].getContents();
            patternParameters.status=DevelopmentStatus.DRAFT.getLiteral();
            for (            int columnIndex : expressionMap.keySet()) {
              String rowContent=row[columnIndex].getContents();
              if (!rowContent.equals("String_Node_Str")) {
                patternParameters.regex.put(expressionMap.get(columnIndex).getLiteral(),rowContent);
              }
            }
            String relativePath="String_Node_Str" + createAndStorePattern(patternParameters,selectionFolder,type);
            names.add(contents);
            importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",contents,relativePath),true));
          }
        }
      }
      rwb.close();
    }
 catch (    BiffException e) {
      log.error(e,e);
      importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false));
    }
catch (    IOException e) {
      log.error(e,e);
      importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false));
    }
catch (    TalendInternalPersistenceException e) {
      log.error(e,e);
      importEvent.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false));
    }
  }
  importObject.copyJarFiles();
  checkImportEvent(importItemName,importEvent);
  return importEvent;
}