Program: 125743
Project: 125743
Buggy source:
/** 
 * DOC YeXiaowei Comment method "isValid".
 * @param node
 * @param itemName
 * @param selectionInClipboard
 * @return null means valid, other means some error exist
 */
private String validJobName(RepositoryNode node,String itemName,ERepositoryObjectType type,TreeSelection selectionInClipboard){
  if (!isValid(node,itemName)) {
    return Messages.getString("String_Node_Str");
  }
  IRepositoryService service=(IRepositoryService)GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
  IProxyRepositoryFactory repositoryFactory=service.getProxyRepositoryFactory();
  if (itemName.length() == 0) {
    return Messages.getString("String_Node_Str");
  }
 else   if (!Pattern.matches(RepositoryConstants.getPattern(type),itemName)) {
    return Messages.getString("String_Node_Str");
  }
 else   if (itemName.equalsIgnoreCase(ProjectManager.getInstance().getCurrentProject().getLabel())) {
    return Messages.getString("String_Node_Str");
  }
 else {
    ERepositoryObjectType repositoryType=node.getObjectType();
    if (repositoryType != null) {
      if (repositoryType == ERepositoryObjectType.PROCESS || repositoryType == ERepositoryObjectType.PROCESS_STORM || repositoryType == ERepositoryObjectType.PROCESS_MR) {
        try {
          List<IRepositoryViewObject> listExistingObjects=repositoryFactory.getAll(ERepositoryObjectType.PROCESS,true,false);
          if (PluginChecker.isStormPluginLoader()) {
            listExistingObjects.addAll(repositoryFactory.getAll(ERepositoryObjectType.PROCESS_STORM,true,false));
          }
          if (PluginChecker.isMapReducePluginLoader()) {
            listExistingObjects.addAll(repositoryFactory.getAll(ERepositoryObjectType.PROCESS_MR,true,false));
          }
          Property property=((RepositoryNode)selectionInClipboard.toArray()[0]).getObject().getProperty();
          if (property != null && (!repositoryFactory.isNameAvailable(property.getItem(),itemName,listExistingObjects) || itemName.equals(property.getLabel()))) {
            return Messages.getString("String_Node_Str");
          }
        }
 catch (        PersistenceException e1) {
          return Messages.getString("String_Node_Str");
        }
      }
 else {
        boolean isTestContainer=false;
        List<IRepositoryViewObject> testObjectList=new ArrayList<IRepositoryViewObject>();
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
          ITestContainerProviderService testContainerService=(ITestContainerProviderService)GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
          if (testContainerService != null) {
            isTestContainer=testContainerService.isTestContainerType(repositoryType);
            if (isTestContainer) {
              testObjectList=testContainerService.listExistingTestCases();
            }
          }
        }
        if (isTestContainer && !testObjectList.isEmpty()) {
          try {
            if (!repositoryFactory.isNameAvailable(node.getObject().getProperty().getItem(),itemName,testObjectList)) {
              return Messages.getString("String_Node_Str");
            }
          }
 catch (          PersistenceException e) {
            return Messages.getString("String_Node_Str");
          }
        }
 else {
          try {
            Item testNewItem=createNewItem();
            if (testNewItem != null) {
              if (!repositoryFactory.isNameAvailable(testNewItem,itemName)) {
                return Messages.getString("String_Node_Str");
              }
            }
          }
 catch (          PersistenceException e) {
            return Messages.getString("String_Node_Str");
          }
        }
      }
    }
    if (isKeyword(itemName)) {
      return Messages.getString("String_Node_Str");
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * DOC YeXiaowei Comment method "isValid".
 * @param node
 * @param itemName
 * @param selectionInClipboard
 * @return null means valid, other means some error exist
 */
private String validJobName(RepositoryNode node,String itemName,ERepositoryObjectType type,TreeSelection selectionInClipboard){
  if (!isValid(node,itemName)) {
    return Messages.getString("String_Node_Str");
  }
  IRepositoryService service=(IRepositoryService)GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
  IProxyRepositoryFactory repositoryFactory=service.getProxyRepositoryFactory();
  if (itemName.length() == 0) {
    return Messages.getString("String_Node_Str");
  }
 else   if (!Pattern.matches(RepositoryConstants.getPattern(type),itemName)) {
    return Messages.getString("String_Node_Str");
  }
 else   if (itemName.equalsIgnoreCase(ProjectManager.getInstance().getCurrentProject().getLabel())) {
    return Messages.getString("String_Node_Str");
  }
 else {
    ERepositoryObjectType repositoryType=node.getObjectType();
    if (repositoryType != null) {
      if (repositoryType == ERepositoryObjectType.PROCESS || repositoryType == ERepositoryObjectType.PROCESS_STORM || repositoryType == ERepositoryObjectType.PROCESS_MR) {
        try {
          List<IRepositoryViewObject> listExistingObjects=repositoryFactory.getAll(ERepositoryObjectType.PROCESS,true,false);
          if (PluginChecker.isStormPluginLoader()) {
            listExistingObjects.addAll(repositoryFactory.getAll(ERepositoryObjectType.PROCESS_STORM,true,false));
          }
          if (PluginChecker.isMapReducePluginLoader()) {
            listExistingObjects.addAll(repositoryFactory.getAll(ERepositoryObjectType.PROCESS_MR,true,false));
          }
          Property property=((RepositoryNode)selectionInClipboard.toArray()[0]).getObject().getProperty();
          if (property != null && (!repositoryFactory.isNameAvailable(property.getItem(),itemName,listExistingObjects) || itemName.equals(property.getLabel()))) {
            return Messages.getString("String_Node_Str");
          }
        }
 catch (        PersistenceException e1) {
          return Messages.getString("String_Node_Str");
        }
      }
 else {
        boolean isTestContainer=false;
        List<IRepositoryViewObject> testObjectList=new ArrayList<IRepositoryViewObject>();
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
          ITestContainerProviderService testContainerService=(ITestContainerProviderService)GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
          if (testContainerService != null) {
            isTestContainer=testContainerService.isTestContainerType(repositoryType);
            if (isTestContainer) {
              testObjectList=testContainerService.listExistingTestCases(null);
            }
          }
        }
        if (isTestContainer && !testObjectList.isEmpty()) {
          try {
            if (!repositoryFactory.isNameAvailable(node.getObject().getProperty().getItem(),itemName,testObjectList)) {
              return Messages.getString("String_Node_Str");
            }
          }
 catch (          PersistenceException e) {
            return Messages.getString("String_Node_Str");
          }
        }
 else {
          try {
            Item testNewItem=createNewItem();
            if (testNewItem != null) {
              if (!repositoryFactory.isNameAvailable(testNewItem,itemName)) {
                return Messages.getString("String_Node_Str");
              }
            }
          }
 catch (          PersistenceException e) {
            return Messages.getString("String_Node_Str");
          }
        }
      }
    }
    if (isKeyword(itemName)) {
      return Messages.getString("String_Node_Str");
    }
  }
  return null;
}