Program: 126838
Project: 126838
Buggy source:
/** 
 * DOC qwei Comment method "deleteFolder".
 * @param deleteActionCache
 */
private void deleteFolder(final RepositoryNode node,final IProxyRepositoryFactory factory,final DeleteActionCache deleteActionCache){
  if (node.getObject().isDeleted()) {
    try {
      deleteElements(factory,deleteActionCache,node);
    }
 catch (    Exception e) {
      ExceptionHandler.process(e);
    }
    return;
  }
  IPath path=RepositoryNodeUtilities.getPath(node);
  ERepositoryObjectType objectType=(ERepositoryObjectType)node.getProperties(EProperties.CONTENT_TYPE);
  List<IRepositoryNode> repositoryList=node.getChildren();
  boolean success=true;
  Exception bex=null;
  for (  IRepositoryNode repositoryNode : repositoryList) {
    try {
      deleteRepositoryNode(repositoryNode,factory);
    }
 catch (    Exception e) {
      bex=e;
      ExceptionHandler.process(e);
      success=false;
    }
  }
  if (bex != null) {
    final Shell shell=getShell();
    MessageDialog.openWarning(shell,Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
  }
  if (!success) {
    return;
  }
  FolderItem folderItem=factory.getFolderItem(ProjectManager.getInstance().getCurrentProject(),objectType,path);
  folderItem.getState().setDeleted(true);
  String fullPath="String_Node_Str";
  FolderItem curItem=folderItem;
  while (curItem.getParent() instanceof FolderItem && ((Item)curItem.getParent()).getParent() instanceof FolderItem && ((FolderItem)((Item)curItem.getParent()).getParent()).getType().getValue() == FolderType.FOLDER) {
    FolderItem parentFolder=(FolderItem)curItem.getParent();
    if ("String_Node_Str".equals(fullPath)) {
      fullPath=parentFolder.getProperty().getLabel() + fullPath;
    }
 else {
      fullPath=parentFolder.getProperty().getLabel() + "String_Node_Str" + fullPath;
    }
    curItem=parentFolder;
  }
  if (!objectType.getKey().toString().startsWith("String_Node_Str") && objectType != ERepositoryObjectType.SQLPATTERNS && objectType != ERepositoryObjectType.ROUTINES && objectType != ERepositoryObjectType.JOB_SCRIPT && curItem.getParent() instanceof FolderItem && ((Item)curItem.getParent()).getParent() instanceof FolderItem && !objectType.isDQItemType()) {
    FolderItem parentFolder=(FolderItem)curItem.getParent();
    if ("String_Node_Str".equals(fullPath)) {
      fullPath=parentFolder.getProperty().getLabel() + fullPath;
    }
 else {
      fullPath=parentFolder.getProperty().getLabel() + "String_Node_Str" + fullPath;
    }
    curItem=parentFolder;
  }
  if (objectType.getKey().toString().startsWith("String_Node_Str")) {
    while (((FolderItem)curItem.getParent()).getType().getValue() != FolderType.SYSTEM_FOLDER) {
      if ("String_Node_Str".equals(fullPath)) {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + fullPath;
      }
 else {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + "String_Node_Str" + fullPath;
      }
      curItem=(FolderItem)curItem.getParent();
    }
  }
  if (objectType == ERepositoryObjectType.ROUTINES) {
    while (((FolderItem)curItem.getParent()).getType().getValue() != FolderType.SYSTEM_FOLDER) {
      if ("String_Node_Str".equals(fullPath)) {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + fullPath;
      }
 else {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + "String_Node_Str" + fullPath;
      }
      curItem=(FolderItem)curItem.getParent();
    }
  }
  if (objectType == ERepositoryObjectType.JOB_SCRIPT) {
    while (((FolderItem)curItem.getParent()).getType().getValue() != FolderType.SYSTEM_FOLDER) {
      if ("String_Node_Str".equals(fullPath)) {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + fullPath;
      }
 else {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + "String_Node_Str" + fullPath;
      }
      curItem=(FolderItem)curItem.getParent();
    }
  }
  if (objectType == ERepositoryObjectType.SQLPATTERNS) {
    while (((FolderItem)curItem.getParent()).getType().getValue() != FolderType.SYSTEM_FOLDER) {
      if ("String_Node_Str".equals(fullPath)) {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + fullPath;
      }
 else {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + "String_Node_Str" + fullPath;
      }
      curItem=(FolderItem)curItem.getParent();
    }
    while (!((FolderItem)curItem.getParent()).getProperty().getLabel().equals("String_Node_Str")) {
      fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + "String_Node_Str" + fullPath;
      curItem=(FolderItem)curItem.getParent();
    }
  }
  if (objectType.isDQItemType()) {
    while (((FolderItem)curItem.getParent()).getType().getValue() != FolderType.SYSTEM_FOLDER) {
      if ("String_Node_Str".equals(fullPath)) {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + fullPath;
      }
 else {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + "String_Node_Str" + fullPath;
      }
      curItem=(FolderItem)curItem.getParent();
    }
  }
  folderItem.getState().setPath(fullPath);
  this.setChildFolderPath(folderItem);
}

Fixed version (ground truth):
/** 
 * DOC qwei Comment method "deleteFolder".
 * @param deleteActionCache
 */
private void deleteFolder(final RepositoryNode node,final IProxyRepositoryFactory factory,final DeleteActionCache deleteActionCache){
  if (node.getObject().isDeleted()) {
    try {
      deleteElements(factory,deleteActionCache,node);
    }
 catch (    Exception e) {
      ExceptionHandler.process(e);
    }
    return;
  }
  IPath path=RepositoryNodeUtilities.getPath(node);
  ERepositoryObjectType objectType=(ERepositoryObjectType)node.getProperties(EProperties.CONTENT_TYPE);
  List<IRepositoryNode> repositoryList=node.getChildren();
  boolean success=true;
  Exception bex=null;
  for (  IRepositoryNode repositoryNode : repositoryList) {
    try {
      boolean ret=deleteRepositoryNode(repositoryNode,factory);
      if (!ret) {
        return;
      }
    }
 catch (    Exception e) {
      bex=e;
      ExceptionHandler.process(e);
      success=false;
    }
  }
  if (bex != null) {
    final Shell shell=getShell();
    MessageDialog.openWarning(shell,Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
  }
  if (!success) {
    return;
  }
  FolderItem folderItem=factory.getFolderItem(ProjectManager.getInstance().getCurrentProject(),objectType,path);
  folderItem.getState().setDeleted(true);
  String fullPath="String_Node_Str";
  FolderItem curItem=folderItem;
  while (curItem.getParent() instanceof FolderItem && ((Item)curItem.getParent()).getParent() instanceof FolderItem && ((FolderItem)((Item)curItem.getParent()).getParent()).getType().getValue() == FolderType.FOLDER) {
    FolderItem parentFolder=(FolderItem)curItem.getParent();
    if ("String_Node_Str".equals(fullPath)) {
      fullPath=parentFolder.getProperty().getLabel() + fullPath;
    }
 else {
      fullPath=parentFolder.getProperty().getLabel() + "String_Node_Str" + fullPath;
    }
    curItem=parentFolder;
  }
  if (!objectType.getKey().toString().startsWith("String_Node_Str") && objectType != ERepositoryObjectType.SQLPATTERNS && objectType != ERepositoryObjectType.ROUTINES && objectType != ERepositoryObjectType.JOB_SCRIPT && curItem.getParent() instanceof FolderItem && ((Item)curItem.getParent()).getParent() instanceof FolderItem && !objectType.isDQItemType()) {
    FolderItem parentFolder=(FolderItem)curItem.getParent();
    if ("String_Node_Str".equals(fullPath)) {
      fullPath=parentFolder.getProperty().getLabel() + fullPath;
    }
 else {
      fullPath=parentFolder.getProperty().getLabel() + "String_Node_Str" + fullPath;
    }
    curItem=parentFolder;
  }
  if (objectType.getKey().toString().startsWith("String_Node_Str")) {
    while (((FolderItem)curItem.getParent()).getType().getValue() != FolderType.SYSTEM_FOLDER) {
      if ("String_Node_Str".equals(fullPath)) {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + fullPath;
      }
 else {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + "String_Node_Str" + fullPath;
      }
      curItem=(FolderItem)curItem.getParent();
    }
  }
  if (objectType == ERepositoryObjectType.ROUTINES) {
    while (((FolderItem)curItem.getParent()).getType().getValue() != FolderType.SYSTEM_FOLDER) {
      if ("String_Node_Str".equals(fullPath)) {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + fullPath;
      }
 else {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + "String_Node_Str" + fullPath;
      }
      curItem=(FolderItem)curItem.getParent();
    }
  }
  if (objectType == ERepositoryObjectType.JOB_SCRIPT) {
    while (((FolderItem)curItem.getParent()).getType().getValue() != FolderType.SYSTEM_FOLDER) {
      if ("String_Node_Str".equals(fullPath)) {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + fullPath;
      }
 else {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + "String_Node_Str" + fullPath;
      }
      curItem=(FolderItem)curItem.getParent();
    }
  }
  if (objectType == ERepositoryObjectType.SQLPATTERNS) {
    while (((FolderItem)curItem.getParent()).getType().getValue() != FolderType.SYSTEM_FOLDER) {
      if ("String_Node_Str".equals(fullPath)) {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + fullPath;
      }
 else {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + "String_Node_Str" + fullPath;
      }
      curItem=(FolderItem)curItem.getParent();
    }
    while (!((FolderItem)curItem.getParent()).getProperty().getLabel().equals("String_Node_Str")) {
      fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + "String_Node_Str" + fullPath;
      curItem=(FolderItem)curItem.getParent();
    }
  }
  if (objectType.isDQItemType()) {
    while (((FolderItem)curItem.getParent()).getType().getValue() != FolderType.SYSTEM_FOLDER) {
      if ("String_Node_Str".equals(fullPath)) {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + fullPath;
      }
 else {
        fullPath=((FolderItem)curItem.getParent()).getProperty().getLabel() + "String_Node_Str" + fullPath;
      }
      curItem=(FolderItem)curItem.getParent();
    }
  }
  folderItem.getState().setPath(fullPath);
  this.setChildFolderPath(folderItem);
}