Program: 136546
Project: 136546
Buggy source:
/** 
 * DOC xqliu Comment method "importIndicatorToStucture".
 * @param importObject
 * @param selectionFolder
 * @param skip
 * @param rename
 * @param importItemName
 * @return
 */
public static List<ReturnCode> importIndicatorToStucture(ImportObject importObject,IFolder selectionFolder,boolean skip,boolean rename,String importItemName){
  List<ReturnCode> information=new ArrayList<ReturnCode>();
  Set<String> names=UDIHelper.getAllIndicatorNames(selectionFolder);
  File importFile=importObject.getObjFile();
  String fileExtName=getFileExtName(importFile);
  if (FileUtils.isCSV(fileExtName)) {
    String name=PluginConstant.EMPTY_STRING;
    try {
      CSVReader reader=FileUtils.createCSVReader(importFile,FileUtils.TEXT_QUAL,FileUtils.TEXT_QUAL);
      reader.setSkipEmptyRecords(true);
      reader.readHeaders();
      java.text.SimpleDateFormat simpleDateFormat=new java.text.SimpleDateFormat("String_Node_Str");
      while (reader.readNext()) {
        name=reader.get(PatternToExcelEnum.Label.getLiteral());
        if (names.contains(name)) {
          if (skip) {
            information.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",name),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());
        udiParameters.javaClassName=reader.get(PatternToExcelEnum.JavaClassName.getLiteral());
        udiParameters.javaJarPath=reader.get(PatternToExcelEnum.JavaJarPath.getLiteral());
        String[] headers=reader.getHeaders();
        String[] columnsValue=reader.getValues();
        HashMap<String,String> record=new HashMap<String,String>();
        for (int i=0; i < headers.length; i++) {
          if (columnsValue[i] != null && columnsValue[i].length() > 0) {
            record.put(headers[i],columnsValue[i]);
          }
        }
        for (        PatternLanguageType languagetype : PatternLanguageType.values()) {
          String cellStr=record.get(languagetype.getExcelEnum().getLiteral());
          if (cellStr != null && !cellStr.equals("String_Node_Str")) {
            udiParameters.regex.put(languagetype.getLiteral(),trimQuote(cellStr));
          }
        }
        udiParameters.setParaMap(buildIndDefPara(record));
        TypedReturnCode<Object> create=createAndStoreUDI(udiParameters,selectionFolder);
        if (create.isOk()) {
          names.add(name);
          information.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",((TDQItem)create.getObject()).getProperty().getDisplayName(),selectionFolder.getProjectRelativePath().toString()),true));
        }
 else {
          throw new TalendInternalPersistenceException(create.getMessage());
        }
      }
      reader.close();
    }
 catch (    Exception e) {
      log.error(e,e);
      information.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",name),false));
    }
  }
  if (FactoriesUtil.DEFINITION.equalsIgnoreCase(fileExtName)) {
    String propFilePath=importFile.getPath().replaceFirst(PluginConstant.DOT_STRING + fileExtName,PluginConstant.DOT_STRING + FactoriesUtil.PROPERTIES_EXTENSION);
    File propFile=new File(propFilePath);
    if (!propFile.exists()) {
      return information;
    }
    String name=importFile.getName();
    try {
      if (names.contains(name)) {
        if (skip) {
          information.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",name),false));
          return information;
        }
        if (rename) {
          name=name + "String_Node_Str" + new Date()+ Math.random()+ "String_Node_Str";
        }
      }
      IFile elementFile=selectionFolder.getFile(name);
      if (!elementFile.exists()) {
        elementFile.create(new FileInputStream(importFile),false,null);
        ModelElement modelElement=ModelElementFileFactory.getModelElement(elementFile);
        if (modelElement != null) {
          ElementWriterFactory.getInstance().createIndicatorDefinitionWriter().create(modelElement,selectionFolder);
          DefinitionHandler.getInstance().reloadIndicatorsDefinitions();
          names.add(name);
          information.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",name),true));
        }
      }
    }
 catch (    Exception e) {
      log.error(e);
      information.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",name),false));
    }
  }
  importObject.copyJarFiles();
  checkImportEvent(importItemName,information);
  return information;
}

Fixed version (ground truth):
/** 
 * DOC xqliu Comment method "importIndicatorToStucture".
 * @param importObject
 * @param selectionFolder
 * @param skip
 * @param rename
 * @param importItemName
 * @return
 */
public static List<ReturnCode> importIndicatorToStucture(ImportObject importObject,IFolder selectionFolder,boolean skip,boolean rename,String importItemName){
  List<ReturnCode> information=new ArrayList<ReturnCode>();
  Set<String> names=UDIHelper.getAllIndicatorNames(selectionFolder);
  File importFile=importObject.getObjFile();
  String fileExtName=getFileExtName(importFile);
  if (FileUtils.isCSV(fileExtName)) {
    String name=PluginConstant.EMPTY_STRING;
    try {
      CSVReader reader=FileUtils.createCSVReader(importFile,FileUtils.TEXT_QUAL,FileUtils.TEXT_QUAL);
      reader.setSkipEmptyRecords(true);
      reader.readHeaders();
      java.text.SimpleDateFormat simpleDateFormat=new java.text.SimpleDateFormat("String_Node_Str");
      while (reader.readNext()) {
        name=reader.get(PatternToExcelEnum.Label.getLiteral());
        if (names.contains(name)) {
          if (skip) {
            information.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",name),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());
        udiParameters.javaClassName=reader.get(PatternToExcelEnum.JavaClassName.getLiteral());
        udiParameters.javaJarPath=reader.get(PatternToExcelEnum.JavaJarPath.getLiteral());
        String[] headers=reader.getHeaders();
        String[] columnsValue=reader.getValues();
        HashMap<String,String> record=new HashMap<String,String>();
        for (int i=0; i < headers.length; i++) {
          if (i >= columnsValue.length) {
            record.put(headers[i],"String_Node_Str");
          }
 else {
            if (columnsValue[i] != null && columnsValue[i].length() > 0) {
              record.put(headers[i],columnsValue[i]);
            }
          }
        }
        for (        PatternLanguageType languagetype : PatternLanguageType.values()) {
          String cellStr=record.get(languagetype.getExcelEnum().getLiteral());
          if (cellStr != null && !cellStr.equals("String_Node_Str")) {
            udiParameters.regex.put(languagetype.getLiteral(),trimQuote(cellStr));
          }
        }
        udiParameters.setParaMap(buildIndDefPara(record));
        TypedReturnCode<Object> create=createAndStoreUDI(udiParameters,selectionFolder);
        if (create.isOk()) {
          names.add(name);
          information.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",((TDQItem)create.getObject()).getProperty().getDisplayName(),selectionFolder.getProjectRelativePath().toString()),true));
        }
 else {
          throw new TalendInternalPersistenceException(create.getMessage());
        }
      }
      reader.close();
    }
 catch (    Exception e) {
      log.error(e,e);
      information.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",name),false));
    }
  }
  if (FactoriesUtil.DEFINITION.equalsIgnoreCase(fileExtName)) {
    String propFilePath=importFile.getPath().replaceFirst(PluginConstant.DOT_STRING + fileExtName,PluginConstant.DOT_STRING + FactoriesUtil.PROPERTIES_EXTENSION);
    File propFile=new File(propFilePath);
    if (!propFile.exists()) {
      return information;
    }
    String name=importFile.getName();
    try {
      if (names.contains(name)) {
        if (skip) {
          information.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",name),false));
          return information;
        }
        if (rename) {
          name=name + "String_Node_Str" + new Date()+ Math.random()+ "String_Node_Str";
        }
      }
      IFile elementFile=selectionFolder.getFile(name);
      if (!elementFile.exists()) {
        elementFile.create(new FileInputStream(importFile),false,null);
        ModelElement modelElement=ModelElementFileFactory.getModelElement(elementFile);
        if (modelElement != null) {
          ElementWriterFactory.getInstance().createIndicatorDefinitionWriter().create(modelElement,selectionFolder);
          DefinitionHandler.getInstance().reloadIndicatorsDefinitions();
          names.add(name);
          information.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",name),true));
        }
      }
    }
 catch (    Exception e) {
      log.error(e);
      information.add(new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str",name),false));
    }
  }
  importObject.copyJarFiles();
  checkImportEvent(importItemName,information);
  return information;
}