Program: 138166
Project: 138166
Buggy source:
/** 
 * DOC bZhou Comment method "createDQStructure".
 */
public void createDQStructure(){
  RepositoryNodeBuilder instance=RepositoryNodeBuilder.getInstance();
  Plugin plugin=CorePlugin.getDefault();
  try {
    IProject project=ResourceManager.getRootProject();
    if (!project.exists()) {
      project=createNewProject(ResourceManager.getRootProjectName());
    }
    if (!project.getFolder(EResourceConstant.DB_CONNECTIONS.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.METADATA,Path.EMPTY,EResourceConstant.DB_CONNECTIONS.getName());
    }
    if (!project.getFolder(EResourceConstant.MDM_CONNECTIONS.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.METADATA,Path.EMPTY,EResourceConstant.MDM_CONNECTIONS.getName());
    }
    if (!project.getFolder(EResourceConstant.FILEDELIMITED.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.METADATA,Path.EMPTY,EResourceConstant.FILEDELIMITED.getName());
    }
    if (!project.getFolder(EResourceConstant.ANALYSIS.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_DATA_PROFILING,Path.EMPTY,EResourceConstant.ANALYSIS.getName());
    }
    if (!ReponsitoryContextBridge.isDefautProject()) {
      if (!project.getFolder(EResourceConstant.REPORTS.getPath()).exists()) {
        Folder reportFoler=ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_DATA_PROFILING,Path.EMPTY,EResourceConstant.REPORTS.getName());
      }
    }
    if (!project.getFolder(EResourceConstant.PATTERNS.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES,Path.EMPTY,EResourceConstant.PATTERNS.getName());
    }
    if (!project.getFolder(EResourceConstant.RULES.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES,Path.EMPTY,EResourceConstant.RULES.getName());
    }
    Folder rulesSQLFoler=null;
    if (!project.getFolder(EResourceConstant.RULES_SQL.getPath()).exists()) {
      rulesSQLFoler=ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_RULES,Path.EMPTY,EResourceConstant.RULES_SQL.getName());
    }
 else {
      rulesSQLFoler=instance.getObjectFolder(EResourceConstant.RULES_SQL);
    }
    rulesSQLFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_RULES_SQL.getFolder());
    Folder rulesParserFoler=null;
    if (!project.getFolder(EResourceConstant.RULES_PARSER.getPath()).exists()) {
      if (!ReponsitoryContextBridge.isDefautProject()) {
        rulesParserFoler=ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_RULES,Path.EMPTY,EResourceConstant.RULES_PARSER.getName());
      }
    }
 else {
      rulesParserFoler=instance.getObjectFolder(EResourceConstant.RULES_PARSER);
    }
    rulesParserFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_RULES_PARSER.getFolder());
    if (!project.getFolder(EResourceConstant.EXCHANGE.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES,Path.EMPTY,EResourceConstant.EXCHANGE.getName());
    }
    if (!project.getFolder(EResourceConstant.INDICATORS.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES,Path.EMPTY,EResourceConstant.INDICATORS.getName());
    }
    Folder systemIndicatorFoler=null;
    if (!project.getFolder(EResourceConstant.SYSTEM_INDICATORS.getPath()).exists()) {
      systemIndicatorFoler=ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_INDICATOR_ELEMENT,Path.EMPTY,EResourceConstant.SYSTEM_INDICATORS.getName());
    }
 else {
      systemIndicatorFoler=instance.getObjectFolder(EResourceConstant.SYSTEM_INDICATORS);
    }
    systemIndicatorFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_SYSTEM_INDICATORS.getFolder());
    if (!project.getFolder(EResourceConstant.USER_DEFINED_INDICATORS.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_INDICATOR_ELEMENT,Path.EMPTY,EResourceConstant.USER_DEFINED_INDICATORS.getName());
    }
    if (!project.getFolder(EResourceConstant.USER_DEFINED_INDICATORS_LIB.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS,Path.EMPTY,EResourceConstant.USER_DEFINED_INDICATORS_LIB.getName());
    }
    if (!project.getFolder(EResourceConstant.JRXML_TEMPLATE.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES,Path.EMPTY,EResourceConstant.JRXML_TEMPLATE.getName());
    }
    Folder patternRegexFoler=null;
    if (!project.getFolder(EResourceConstant.PATTERN_REGEX.getPath()).exists()) {
      patternRegexFoler=ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_PATTERN_ELEMENT,Path.EMPTY,EResourceConstant.PATTERN_REGEX.getName());
    }
 else {
      patternRegexFoler=instance.getObjectFolder(EResourceConstant.PATTERN_REGEX);
    }
    patternRegexFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_PATTERN_REGEX.getFolder());
    Folder patternSQLFoler=null;
    if (!project.getFolder(EResourceConstant.PATTERN_SQL.getPath()).exists()) {
      patternSQLFoler=ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_PATTERN_ELEMENT,Path.EMPTY,EResourceConstant.PATTERN_SQL.getName());
    }
 else {
      patternSQLFoler=instance.getObjectFolder(EResourceConstant.PATTERN_SQL);
    }
    patternSQLFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_PATTERN_SQL.getFolder());
    Folder sourceFileFoler=null;
    if (!project.getFolder(EResourceConstant.SOURCE_FILES.getPath()).exists()) {
      sourceFileFoler=ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES,Path.EMPTY,EResourceConstant.SOURCE_FILES.getName());
    }
 else {
      sourceFileFoler=instance.getObjectFolder(EResourceConstant.SOURCE_FILES);
    }
    sourceFileFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT.getFolder());
    if (systemIndicatorFoler != null && patternRegexFoler != null && patternSQLFoler != null && sourceFileFoler != null && rulesSQLFoler != null && rulesParserFoler != null) {
      copyFilesToFolder(plugin,SYSTEM_INDICATOR_PATH,true,systemIndicatorFoler,null,ERepositoryObjectType.TDQ_SYSTEM_INDICATORS);
      copyFilesToFolder(plugin,PATTERN_PATH,true,patternRegexFoler,null,ERepositoryObjectType.TDQ_PATTERN_REGEX);
      copyFilesToFolder(plugin,SQL_LIKE_PATH,true,patternSQLFoler,null,ERepositoryObjectType.TDQ_PATTERN_SQL);
      copyFilesToFolder(plugin,DEMO_PATH,true,sourceFileFoler,null,ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
      copyFilesToFolder(plugin,RULES_PATH,true,rulesSQLFoler,null,ERepositoryObjectType.TDQ_RULES_SQL);
      copyFilesToFolder(plugin,RULES_PARSER,true,rulesParserFoler,null,ERepositoryObjectType.TDQ_RULES_PARSER);
    }
    WorkspaceVersionHelper.storeVersion();
    ResourceService.refreshStructure();
  }
 catch (  Exception ex) {
    ExceptionHandler.process(ex);
    ProxyRepositoryManager.getInstance().save();
  }
}

Fixed version (ground truth):
/** 
 * DOC bZhou Comment method "createDQStructure".
 */
public void createDQStructure(){
  RepositoryNodeBuilder instance=RepositoryNodeBuilder.getInstance();
  Plugin plugin=CorePlugin.getDefault();
  try {
    IProject project=ResourceManager.getRootProject();
    if (!project.exists()) {
      project=createNewProject(ResourceManager.getRootProjectName());
    }
    if (!project.getFolder(EResourceConstant.DB_CONNECTIONS.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.METADATA,Path.EMPTY,EResourceConstant.DB_CONNECTIONS.getName());
    }
    if (!project.getFolder(EResourceConstant.MDM_CONNECTIONS.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.METADATA,Path.EMPTY,EResourceConstant.MDM_CONNECTIONS.getName());
    }
    if (!project.getFolder(EResourceConstant.FILEDELIMITED.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.METADATA,Path.EMPTY,EResourceConstant.FILEDELIMITED.getName());
    }
    if (!project.getFolder(EResourceConstant.ANALYSIS.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_DATA_PROFILING,Path.EMPTY,EResourceConstant.ANALYSIS.getName());
    }
    if (!ReponsitoryContextBridge.isDefautProject()) {
      if (!project.getFolder(EResourceConstant.REPORTS.getPath()).exists()) {
        Folder reportFoler=ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_DATA_PROFILING,Path.EMPTY,EResourceConstant.REPORTS.getName());
      }
    }
    if (!project.getFolder(EResourceConstant.PATTERNS.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES,Path.EMPTY,EResourceConstant.PATTERNS.getName());
    }
    if (!project.getFolder(EResourceConstant.RULES.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES,Path.EMPTY,EResourceConstant.RULES.getName());
    }
    Folder rulesSQLFoler=null;
    if (!project.getFolder(EResourceConstant.RULES_SQL.getPath()).exists()) {
      rulesSQLFoler=ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_RULES,Path.EMPTY,EResourceConstant.RULES_SQL.getName());
    }
 else {
      rulesSQLFoler=instance.getObjectFolder(EResourceConstant.RULES_SQL);
    }
    rulesSQLFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_RULES_SQL.getFolder());
    Folder rulesParserFoler=null;
    if (!project.getFolder(EResourceConstant.RULES_PARSER.getPath()).exists()) {
      if (!ReponsitoryContextBridge.isDefautProject()) {
        rulesParserFoler=ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_RULES,Path.EMPTY,EResourceConstant.RULES_PARSER.getName());
      }
    }
 else {
      rulesParserFoler=instance.getObjectFolder(EResourceConstant.RULES_PARSER);
    }
    if (rulesParserFoler != null) {
      rulesParserFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_RULES_PARSER.getFolder());
    }
    if (!project.getFolder(EResourceConstant.EXCHANGE.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES,Path.EMPTY,EResourceConstant.EXCHANGE.getName());
    }
    if (!project.getFolder(EResourceConstant.INDICATORS.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES,Path.EMPTY,EResourceConstant.INDICATORS.getName());
    }
    Folder systemIndicatorFoler=null;
    if (!project.getFolder(EResourceConstant.SYSTEM_INDICATORS.getPath()).exists()) {
      systemIndicatorFoler=ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_INDICATOR_ELEMENT,Path.EMPTY,EResourceConstant.SYSTEM_INDICATORS.getName());
    }
 else {
      systemIndicatorFoler=instance.getObjectFolder(EResourceConstant.SYSTEM_INDICATORS);
    }
    systemIndicatorFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_SYSTEM_INDICATORS.getFolder());
    if (!project.getFolder(EResourceConstant.USER_DEFINED_INDICATORS.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_INDICATOR_ELEMENT,Path.EMPTY,EResourceConstant.USER_DEFINED_INDICATORS.getName());
    }
    if (!project.getFolder(EResourceConstant.USER_DEFINED_INDICATORS_LIB.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS,Path.EMPTY,EResourceConstant.USER_DEFINED_INDICATORS_LIB.getName());
    }
    if (!project.getFolder(EResourceConstant.JRXML_TEMPLATE.getPath()).exists()) {
      ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES,Path.EMPTY,EResourceConstant.JRXML_TEMPLATE.getName());
    }
    Folder patternRegexFoler=null;
    if (!project.getFolder(EResourceConstant.PATTERN_REGEX.getPath()).exists()) {
      patternRegexFoler=ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_PATTERN_ELEMENT,Path.EMPTY,EResourceConstant.PATTERN_REGEX.getName());
    }
 else {
      patternRegexFoler=instance.getObjectFolder(EResourceConstant.PATTERN_REGEX);
    }
    patternRegexFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_PATTERN_REGEX.getFolder());
    Folder patternSQLFoler=null;
    if (!project.getFolder(EResourceConstant.PATTERN_SQL.getPath()).exists()) {
      patternSQLFoler=ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_PATTERN_ELEMENT,Path.EMPTY,EResourceConstant.PATTERN_SQL.getName());
    }
 else {
      patternSQLFoler=instance.getObjectFolder(EResourceConstant.PATTERN_SQL);
    }
    patternSQLFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_PATTERN_SQL.getFolder());
    Folder sourceFileFoler=null;
    if (!project.getFolder(EResourceConstant.SOURCE_FILES.getPath()).exists()) {
      sourceFileFoler=ProxyRepositoryFactory.getInstance().createFolder(ERepositoryObjectType.TDQ_LIBRARIES,Path.EMPTY,EResourceConstant.SOURCE_FILES.getName());
    }
 else {
      sourceFileFoler=instance.getObjectFolder(EResourceConstant.SOURCE_FILES);
    }
    sourceFileFoler.getProperty().getItem().getState().setPath(ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT.getFolder());
    if (systemIndicatorFoler != null && patternRegexFoler != null && patternSQLFoler != null && sourceFileFoler != null && rulesSQLFoler != null) {
      copyFilesToFolder(plugin,SYSTEM_INDICATOR_PATH,true,systemIndicatorFoler,null,ERepositoryObjectType.TDQ_SYSTEM_INDICATORS);
      copyFilesToFolder(plugin,PATTERN_PATH,true,patternRegexFoler,null,ERepositoryObjectType.TDQ_PATTERN_REGEX);
      copyFilesToFolder(plugin,SQL_LIKE_PATH,true,patternSQLFoler,null,ERepositoryObjectType.TDQ_PATTERN_SQL);
      copyFilesToFolder(plugin,DEMO_PATH,true,sourceFileFoler,null,ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
      copyFilesToFolder(plugin,RULES_PATH,true,rulesSQLFoler,null,ERepositoryObjectType.TDQ_RULES_SQL);
    }
    if (rulesParserFoler != null) {
      copyFilesToFolder(plugin,RULES_PARSER,true,rulesParserFoler,null,ERepositoryObjectType.TDQ_RULES_PARSER);
    }
    WorkspaceVersionHelper.storeVersion();
    ResourceService.refreshStructure();
  }
 catch (  Exception ex) {
    ExceptionHandler.process(ex);
    ProxyRepositoryManager.getInstance().save();
  }
}