Program: 128013
Project: 128013
Buggy source:
private void createOperation(final String newJobName,final RepositoryNode target,CopyObjectAction copyObjectAction,final TreeSelection selectionInClipboard){
  Object currentSource=selectionInClipboard.toArray()[0];
  try {
    final IPath path=RepositoryNodeUtilities.getPath(target);
    if (((RepositoryNode)currentSource).getType().equals(ENodeType.REPOSITORY_ELEMENT)) {
      Item originalItem=((RepositoryNode)currentSource).getObject().getProperty().getItem();
      List<IRepositoryViewObject> allVersion=factory.getAllVersion(originalItem.getProperty().getId());
      for (      IRepositoryViewObject obj : allVersion) {
        if (obj.getVersion().equals(originalItem.getProperty().getVersion())) {
          originalItem=obj.getProperty().getItem();
          break;
        }
      }
      if (allVersion.size() == 1) {
        duplicateSingleVersionItem(originalItem,path,newJobName);
      }
 else       if (allVersion.size() > 1) {
        final PastSelectorDialog dialog=new PastSelectorDialog(Display.getCurrent().getActiveShell(),allVersion,sourceNode);
        final Item item=originalItem;
        if (dialog.open() == Window.OK) {
          final IWorkspaceRunnable op=new IWorkspaceRunnable(){
            @Override public void run(            IProgressMonitor monitor) throws CoreException {
              Set<IRepositoryViewObject> selectedVersionItems=dialog.getSelectedVersionItems();
              String id=null;
              boolean isfirst=true;
              boolean needSys=true;
              try {
                for (                IRepositoryViewObject object : selectedVersionItems) {
                  Item selectedItem=object.getProperty().getItem();
                  Item copy;
                  copy=factory.copy(selectedItem,path,newJobName);
                  if (isfirst) {
                    id=copy.getProperty().getId();
                    isfirst=false;
                  }
                  copy.getProperty().setId(id);
                  if (needSys && item instanceof RoutineItem) {
                    String lastestVersion=getLastestVersion(selectedVersionItems);
                    if (lastestVersion.equals(copy.getProperty().getVersion())) {
                      synDuplicatedRoutine((RoutineItem)copy);
                      needSys=false;
                    }
                  }
                  if (copy instanceof ProcessItem) {
                    RelationshipItemBuilder.getInstance().addOrUpdateItem(copy);
                  }
                  if (copy instanceof ConnectionItem) {
                    Connection connection=((ConnectionItem)copy).getConnection();
                    if (connection != null) {
                      connection.getSupplierDependency().clear();
                      connection.setLabel(newJobName);
                      connection.setName(newJobName);
                    }
                  }
                  factory.save(copy);
                  notifySQLExplorer(copy);
                }
              }
 catch (              PersistenceException e) {
                throw new CoreException(new Status(IStatus.ERROR,"String_Node_Str","String_Node_Str",e));
              }
catch (              BusinessException e) {
                throw new CoreException(new Status(IStatus.ERROR,"String_Node_Str","String_Node_Str",e));
              }
            }
          }
;
          IRunnableWithProgress iRunnableWithProgress=new IRunnableWithProgress(){
            @Override public void run(            IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
              IWorkspace workspace=ResourcesPlugin.getWorkspace();
              try {
                ISchedulingRule schedulingRule=workspace.getRoot();
                workspace.run(op,schedulingRule,IWorkspace.AVOID_UPDATE,monitor);
              }
 catch (              CoreException e) {
                throw new InvocationTargetException(e);
              }
            }
          }
;
          try {
            new ProgressMonitorDialog(null).run(false,false,iRunnableWithProgress);
          }
 catch (          InvocationTargetException e) {
            ExceptionHandler.process(e);
          }
catch (          InterruptedException e) {
          }
        }
      }
    }
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
}

Fixed version (ground truth):
private void createOperation(final String newJobName,final RepositoryNode target,CopyObjectAction copyObjectAction,final TreeSelection selectionInClipboard){
  Object currentSource=selectionInClipboard.toArray()[0];
  try {
    final IPath path=RepositoryNodeUtilities.getPath(target);
    if (((RepositoryNode)currentSource).getType().equals(ENodeType.REPOSITORY_ELEMENT)) {
      Item originalItem=((RepositoryNode)currentSource).getObject().getProperty().getItem();
      List<IRepositoryViewObject> allVersion=factory.getAllVersion(originalItem.getProperty().getId());
      for (      IRepositoryViewObject obj : allVersion) {
        if (obj.getVersion().equals(originalItem.getProperty().getVersion())) {
          originalItem=obj.getProperty().getItem();
          break;
        }
      }
      if (allVersion.size() == 1) {
        duplicateSingleVersionItem(originalItem,path,newJobName);
      }
 else       if (allVersion.size() > 1) {
        final PastSelectorDialog dialog=new PastSelectorDialog(Display.getCurrent().getActiveShell(),allVersion,sourceNode);
        final Item item=originalItem;
        if (dialog.open() == Window.OK) {
          final IWorkspaceRunnable op=new IWorkspaceRunnable(){
            @Override public void run(            IProgressMonitor monitor) throws CoreException {
              Set<IRepositoryViewObject> selectedVersionItems=dialog.getSelectedVersionItems();
              String id=null;
              boolean isfirst=true;
              boolean needSys=true;
              try {
                for (                IRepositoryViewObject object : selectedVersionItems) {
                  Item selectedItem=object.getProperty().getItem();
                  Item copy;
                  copy=factory.copy(selectedItem,path,newJobName);
                  if (isfirst) {
                    id=copy.getProperty().getId();
                    isfirst=false;
                  }
                  copy.getProperty().setId(id);
                  if (needSys && item instanceof RoutineItem) {
                    String lastestVersion=getLastestVersion(selectedVersionItems);
                    if (lastestVersion.equals(copy.getProperty().getVersion())) {
                      synDuplicatedRoutine((RoutineItem)copy,selectedItem.getProperty().getLabel());
                      needSys=false;
                    }
                  }
                  if (copy instanceof ProcessItem) {
                    RelationshipItemBuilder.getInstance().addOrUpdateItem(copy);
                  }
                  if (copy instanceof ConnectionItem) {
                    Connection connection=((ConnectionItem)copy).getConnection();
                    if (connection != null) {
                      connection.getSupplierDependency().clear();
                      connection.setLabel(newJobName);
                      connection.setName(newJobName);
                    }
                  }
                  factory.save(copy);
                  notifySQLExplorer(copy);
                }
              }
 catch (              PersistenceException e) {
                throw new CoreException(new Status(IStatus.ERROR,"String_Node_Str","String_Node_Str",e));
              }
catch (              BusinessException e) {
                throw new CoreException(new Status(IStatus.ERROR,"String_Node_Str","String_Node_Str",e));
              }
            }
          }
;
          IRunnableWithProgress iRunnableWithProgress=new IRunnableWithProgress(){
            @Override public void run(            IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
              IWorkspace workspace=ResourcesPlugin.getWorkspace();
              try {
                ISchedulingRule schedulingRule=workspace.getRoot();
                workspace.run(op,schedulingRule,IWorkspace.AVOID_UPDATE,monitor);
              }
 catch (              CoreException e) {
                throw new InvocationTargetException(e);
              }
            }
          }
;
          try {
            new ProgressMonitorDialog(null).run(false,false,iRunnableWithProgress);
          }
 catch (          InvocationTargetException e) {
            ExceptionHandler.process(e);
          }
catch (          InterruptedException e) {
          }
        }
      }
    }
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
}