Program: 139444
Project: 139444
Buggy source:
/** 
 * DOC xqliu Comment method "importIndicatorToStucture".
 * @param importFile
 * @param selectionFolder
 * @param skip
 * @param rename
 * @return
 */
public static List<ReturnCode> importIndicatorToStucture(File importFile,IFolder selectionFolder,boolean skip,boolean rename){
  List<ReturnCode> information=new ArrayList<ReturnCode>();
  Set<String> names=UDIHelper.getAllIndicatorNames(selectionFolder);
  String fileExtName=getFileExtName(importFile);
  if ("String_Node_Str".equalsIgnoreCase(fileExtName)) {
    if (!verifyImportFile(importFile)) {
      information.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false));
    }
 else {
      String name="String_Node_Str";
      try {
        CsvReader reader=new CsvReader(new FileReader(importFile),CURRENT_SEPARATOR);
        reader.setEscapeMode(ESCAPE_MODE_BACKSLASH);
        reader.setTextQualifier(TEXT_QUAL);
        reader.setUseTextQualifier(USE_TEXT_QUAL);
        reader.readHeaders();
        if (checkFileHeader(reader.getHeaders())) {
          java.text.SimpleDateFormat simpleDateFormat=new java.text.SimpleDateFormat("String_Node_Str");
          while (reader.readRecord()) {
            name=reader.get(PatternToExcelEnum.Label.getLiteral());
            if (names.contains(name)) {
              if (skip) {
                information.add(new ReturnCode("String_Node_Str" + name + "String_Node_Str",false));
                continue;
              }
              if (rename) {
                name=name + "String_Node_Str" + simpleDateFormat.format(new Date())+ Math.random()+ "String_Node_Str";
              }
            }
            UDIParameters udiParameters=new ImportFactory().new UDIParameters();
            udiParameters.name=name;
            udiParameters.auther=reader.get(PatternToExcelEnum.Author.getLiteral());
            udiParameters.description=reader.get(PatternToExcelEnum.Description.getLiteral());
            udiParameters.purpose=reader.get(PatternToExcelEnum.Purpose.getLiteral());
            udiParameters.relativePath=reader.get(PatternToExcelEnum.RelativePath.getLiteral());
            udiParameters.category=reader.get(PatternToExcelEnum.Category.getLiteral());
            for (            PatternLanguageType languagetype : PatternLanguageType.values()) {
              String cellStr=reader.get(languagetype.getExcelEnum().getLiteral());
              if (cellStr != null && !cellStr.equals("String_Node_Str")) {
                udiParameters.regex.put(languagetype.getLiteral(),cellStr);
              }
            }
            createAndStoreUDI(udiParameters,selectionFolder);
            names.add(name);
            information.add(new ReturnCode("String_Node_Str" + name + "String_Node_Str",true));
          }
          reader.close();
        }
 else {
          information.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false));
        }
      }
 catch (      Exception e) {
        log.error(e,e);
        information.add(new ReturnCode("String_Node_Str" + name + "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) {
                continue;
              }
              if (rename) {
                contents=contents + "String_Node_Str" + new Date()+ "String_Node_Str";
              }
            }
            UDIParameters udiParameters=new ImportFactory().new UDIParameters();
            udiParameters.name=contents;
            udiParameters.auther=row[6].getContents();
            udiParameters.description=row[2].getContents();
            udiParameters.purpose=row[1].getContents();
            udiParameters.status=DevelopmentStatus.DRAFT.getLiteral();
            udiParameters.category=row[16].getContents();
            for (            int columnIndex : expressionMap.keySet()) {
              String rowContent=row[columnIndex].getContents();
              if (!rowContent.equals("String_Node_Str")) {
                udiParameters.regex.put(expressionMap.get(columnIndex).getLiteral(),rowContent);
              }
            }
            createAndStoreUDI(udiParameters,selectionFolder);
            names.add(contents);
          }
        }
      }
      rwb.close();
    }
 catch (    BiffException e) {
      log.error(e,e);
    }
catch (    IOException e) {
      log.error(e,e);
    }
  }
  return information;
}

Fixed version (ground truth):
/** 
 * DOC xqliu Comment method "importIndicatorToStucture".
 * @param importFile
 * @param selectionFolder
 * @param skip
 * @param rename
 * @return
 */
public static List<ReturnCode> importIndicatorToStucture(File importFile,IFolder selectionFolder,boolean skip,boolean rename){
  List<ReturnCode> information=new ArrayList<ReturnCode>();
  Set<String> names=UDIHelper.getAllIndicatorNames(selectionFolder);
  String fileExtName=getFileExtName(importFile);
  if ("String_Node_Str".equalsIgnoreCase(fileExtName)) {
    ReturnCode rc=verifyImportFile(importFile);
    if (!rc.isOk()) {
      information.add(rc);
    }
 else {
      String name="String_Node_Str";
      try {
        CsvReader reader=new CsvReader(new FileReader(importFile),CURRENT_SEPARATOR);
        reader.setEscapeMode(ESCAPE_MODE_BACKSLASH);
        reader.setTextQualifier(TEXT_QUAL);
        reader.setUseTextQualifier(USE_TEXT_QUAL);
        reader.readHeaders();
        java.text.SimpleDateFormat simpleDateFormat=new java.text.SimpleDateFormat("String_Node_Str");
        while (reader.readRecord()) {
          name=reader.get(PatternToExcelEnum.Label.getLiteral());
          if (names.contains(name)) {
            if (skip) {
              information.add(new ReturnCode("String_Node_Str" + name + "String_Node_Str",false));
              continue;
            }
            if (rename) {
              name=name + "String_Node_Str" + simpleDateFormat.format(new Date())+ Math.random()+ "String_Node_Str";
            }
          }
          UDIParameters udiParameters=new ImportFactory().new UDIParameters();
          udiParameters.name=name;
          udiParameters.auther=reader.get(PatternToExcelEnum.Author.getLiteral());
          udiParameters.description=reader.get(PatternToExcelEnum.Description.getLiteral());
          udiParameters.purpose=reader.get(PatternToExcelEnum.Purpose.getLiteral());
          udiParameters.relativePath=reader.get(PatternToExcelEnum.RelativePath.getLiteral());
          udiParameters.category=reader.get(PatternToExcelEnum.Category.getLiteral());
          for (          PatternLanguageType languagetype : PatternLanguageType.values()) {
            String cellStr=reader.get(languagetype.getExcelEnum().getLiteral());
            if (cellStr != null && !cellStr.equals("String_Node_Str")) {
              udiParameters.regex.put(languagetype.getLiteral(),cellStr);
            }
          }
          createAndStoreUDI(udiParameters,selectionFolder);
          names.add(name);
          information.add(new ReturnCode("String_Node_Str" + name + "String_Node_Str",true));
        }
        reader.close();
      }
 catch (      Exception e) {
        log.error(e,e);
        information.add(new ReturnCode("String_Node_Str" + name + "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) {
                continue;
              }
              if (rename) {
                contents=contents + "String_Node_Str" + new Date()+ "String_Node_Str";
              }
            }
            UDIParameters udiParameters=new ImportFactory().new UDIParameters();
            udiParameters.name=contents;
            udiParameters.auther=row[6].getContents();
            udiParameters.description=row[2].getContents();
            udiParameters.purpose=row[1].getContents();
            udiParameters.status=DevelopmentStatus.DRAFT.getLiteral();
            udiParameters.category=row[16].getContents();
            for (            int columnIndex : expressionMap.keySet()) {
              String rowContent=row[columnIndex].getContents();
              if (!rowContent.equals("String_Node_Str")) {
                udiParameters.regex.put(expressionMap.get(columnIndex).getLiteral(),rowContent);
              }
            }
            createAndStoreUDI(udiParameters,selectionFolder);
            names.add(contents);
          }
        }
      }
      rwb.close();
    }
 catch (    BiffException e) {
      log.error(e,e);
    }
catch (    IOException e) {
      log.error(e,e);
    }
  }
  return information;
}