Program: 129206
Project: 129206
Buggy source:
private boolean deleteElements(IProxyRepositoryFactory factory,DeleteActionCache deleteActionCache,final RepositoryNode currentJobNode,Boolean confirm) throws PersistenceException, BusinessException {
  boolean needReturn=false;
  final IRepositoryViewObject objToDelete=currentJobNode.getObject();
  final List<ContextReferenceBean> checkContext=checkContextFromProcess(factory,deleteActionCache,currentJobNode);
  if (checkContext.size() > 0) {
    Display.getDefault().syncExec(new Runnable(){
      public void run(){
        ContextReferenceDialog dialog=new ContextReferenceDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),objToDelete,checkContext);
        dialog.open();
      }
    }
);
    return true;
  }
  Item item=objToDelete.getProperty().getItem();
  AbstractResourceChangesService resChangeService=TDQServiceRegister.getInstance().getResourceChangeService(AbstractResourceChangesService.class);
  if (resChangeService != null && item instanceof ConnectionItem && item.getState().isDeleted()) {
    if (!resChangeService.handleResourceChange(((ConnectionItem)item).getConnection())) {
      return true;
    }
  }
  ERepositoryObjectType nodeType=(ERepositoryObjectType)currentJobNode.getProperties(EProperties.CONTENT_TYPE);
  if (nodeType != null && nodeType.isSubItem()) {
    Display.getDefault().syncExec(new Runnable(){
      public void run(){
        final DeleteTableAction deleteTableAction=new DeleteTableAction();
        deleteTableAction.setWorkbenchPart(getWorkbenchPart());
        deleteTableAction.run();
      }
    }
);
    needReturn=true;
  }
 else {
    if (factory.getStatus(objToDelete) == ERepositoryStatus.DELETED) {
      if (confirm == null) {
        Display.getDefault().syncExec(new Runnable(){
          public void run(){
            String title=Messages.getString("String_Node_Str");
            String message=currentJobNode.getProperties(EProperties.LABEL) + "String_Node_Str" + Messages.getString("String_Node_Str")+ "String_Node_Str"+ Messages.getString("String_Node_Str");
            confirmFromDialog=MessageDialog.openQuestion(new Shell(),title,message);
          }
        }
);
        confirm=confirmFromDialog;
      }
      if (confirm) {
        deleteActionCache.closeOpenedEditor(objToDelete);
        if (currentJobNode.getType() == ENodeType.SIMPLE_FOLDER) {
          boolean success=true;
          for (          IRepositoryNode curNode : currentJobNode.getChildren()) {
            try {
              deleteElements(factory,deleteActionCache,(RepositoryNode)curNode,confirm);
            }
 catch (            Exception e) {
              ExceptionHandler.process(e);
              success=false;
            }
          }
          if (success) {
            if (currentJobNode.getObject() != null && currentJobNode.getObject().getProperty() != null && currentJobNode.getObject().getProperty().getItem() != null) {
              Item fitem=currentJobNode.getObject().getProperty().getItem();
              if ((fitem instanceof FolderItem) && (((FolderItem)fitem).getType().getValue() == FolderType.FOLDER)) {
                factory.deleteFolder(currentJobNode.getContentType(),RepositoryNodeUtilities.getFolderPath(currentJobNode.getObject().getProperty().getItem()));
              }
 else {
                factory.deleteFolder(currentJobNode.getContentType(),RepositoryNodeUtilities.getPath(currentJobNode));
              }
            }
 else {
              factory.deleteFolder(currentJobNode.getContentType(),RepositoryNodeUtilities.getPath(currentJobNode));
            }
          }
        }
 else {
          if (resChangeService != null && (item instanceof TDQItem || item instanceof ConnectionItem)) {
            resChangeService.removeAllDependecies(item);
          }
          if (item instanceof ConnectionItem && GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
            ITDQRepositoryService tdqRepService=(ITDQRepositoryService)GlobalServiceRegister.getDefault().getService(ITDQRepositoryService.class);
            tdqRepService.removeAliasInSQLExplorer(currentJobNode);
          }
          factory.deleteObjectPhysical(objToDelete);
          ExpressionPersistance.getInstance().jobDeleted(objToDelete.getLabel());
        }
      }
    }
 else {
      factory.deleteObjectLogical(objToDelete);
    }
  }
  return needReturn;
}

Fixed version (ground truth):
private boolean deleteElements(IProxyRepositoryFactory factory,DeleteActionCache deleteActionCache,final RepositoryNode currentJobNode,Boolean confirm) throws PersistenceException, BusinessException {
  boolean needReturn=false;
  final IRepositoryViewObject objToDelete=currentJobNode.getObject();
  final List<ContextReferenceBean> checkContext=checkContextFromProcess(factory,deleteActionCache,currentJobNode);
  if (checkContext.size() > 0) {
    Display.getDefault().syncExec(new Runnable(){
      public void run(){
        ContextReferenceDialog dialog=new ContextReferenceDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),objToDelete,checkContext);
        dialog.open();
      }
    }
);
    return true;
  }
  Item item=null;
  if (objToDelete != null && objToDelete.getProperty() != null) {
    item=objToDelete.getProperty().getItem();
  }
  AbstractResourceChangesService resChangeService=TDQServiceRegister.getInstance().getResourceChangeService(AbstractResourceChangesService.class);
  if (resChangeService != null && item != null && item instanceof ConnectionItem && item.getState().isDeleted()) {
    if (!resChangeService.handleResourceChange(((ConnectionItem)item).getConnection())) {
      return true;
    }
  }
  ERepositoryObjectType nodeType=(ERepositoryObjectType)currentJobNode.getProperties(EProperties.CONTENT_TYPE);
  if (nodeType != null && nodeType.isSubItem()) {
    Display.getDefault().syncExec(new Runnable(){
      public void run(){
        final DeleteTableAction deleteTableAction=new DeleteTableAction();
        deleteTableAction.setWorkbenchPart(getWorkbenchPart());
        deleteTableAction.run();
      }
    }
);
    needReturn=true;
  }
 else {
    if (factory.getStatus(objToDelete) == ERepositoryStatus.DELETED) {
      if (confirm == null) {
        Display.getDefault().syncExec(new Runnable(){
          public void run(){
            String title=Messages.getString("String_Node_Str");
            String message=currentJobNode.getProperties(EProperties.LABEL) + "String_Node_Str" + Messages.getString("String_Node_Str")+ "String_Node_Str"+ Messages.getString("String_Node_Str");
            confirmFromDialog=MessageDialog.openQuestion(new Shell(),title,message);
          }
        }
);
        confirm=confirmFromDialog;
      }
      if (confirm) {
        deleteActionCache.closeOpenedEditor(objToDelete);
        if (currentJobNode.getType() == ENodeType.SIMPLE_FOLDER) {
          boolean success=true;
          for (          IRepositoryNode curNode : currentJobNode.getChildren()) {
            try {
              deleteElements(factory,deleteActionCache,(RepositoryNode)curNode,confirm);
            }
 catch (            Exception e) {
              ExceptionHandler.process(e);
              success=false;
            }
          }
          if (success) {
            if (currentJobNode.getObject() != null && currentJobNode.getObject().getProperty() != null && currentJobNode.getObject().getProperty().getItem() != null) {
              Item fitem=currentJobNode.getObject().getProperty().getItem();
              if ((fitem instanceof FolderItem) && (((FolderItem)fitem).getType().getValue() == FolderType.FOLDER)) {
                factory.deleteFolder(currentJobNode.getContentType(),RepositoryNodeUtilities.getFolderPath(currentJobNode.getObject().getProperty().getItem()));
              }
 else {
                factory.deleteFolder(currentJobNode.getContentType(),RepositoryNodeUtilities.getPath(currentJobNode));
              }
            }
 else {
              factory.deleteFolder(currentJobNode.getContentType(),RepositoryNodeUtilities.getPath(currentJobNode));
            }
          }
        }
 else {
          if (resChangeService != null && (item instanceof TDQItem || item instanceof ConnectionItem)) {
            resChangeService.removeAllDependecies(item);
          }
          if (item instanceof ConnectionItem && GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
            ITDQRepositoryService tdqRepService=(ITDQRepositoryService)GlobalServiceRegister.getDefault().getService(ITDQRepositoryService.class);
            tdqRepService.removeAliasInSQLExplorer(currentJobNode);
          }
          factory.deleteObjectPhysical(objToDelete);
          ExpressionPersistance.getInstance().jobDeleted(objToDelete.getLabel());
        }
      }
    }
 else {
      factory.deleteObjectLogical(objToDelete);
    }
  }
  return needReturn;
}