Program: 119635
Project: 119635
Buggy source:
private Map<File,IPath> exportItems2(Collection<Item> items,File destinationDirectory,boolean projectFolderStructure,IProgressMonitor progressMonitor) throws Exception {
  Map<File,IPath> toExport=new HashMap<File,IPath>();
  progressMonitor.beginTask("String_Node_Str",items.size() + 1);
  TimeMeasure.display=CommonsPlugin.isDebugMode();
  TimeMeasure.displaySteps=CommonsPlugin.isDebugMode();
  TimeMeasure.measureActive=CommonsPlugin.isDebugMode();
  TimeMeasure.begin("String_Node_Str");
  try {
    Map<Item,Project> itemProjectMap=new HashMap<Item,Project>();
    Collection<Item> allItems=new ArrayList<Item>(items);
    items.clear();
    if (allItems.isEmpty()) {
      IPath proRelativePath=getProjectPath().append(FileConstants.LOCAL_PROJECT_FILENAME);
      IPath proSourcePath=workspacePath.append(proRelativePath);
      IPath proTargetPath=new Path(destinationDirectory.getAbsolutePath()).append(proRelativePath);
      FilesUtils.copyFile(new File(proSourcePath.toPortableString()),new File(proTargetPath.toPortableString()));
      toExport.put(proTargetPath.toFile(),proRelativePath);
      return toExport;
    }
    allItems=sortItemsByProject(allItems,itemProjectMap);
    ITransformService tdmService=null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITransformService.class)) {
      tdmService=(ITransformService)GlobalServiceRegister.getDefault().getService(ITransformService.class);
    }
    itemProjectMap.clear();
    Set<String> jarNameList=new HashSet<String>();
    Iterator<Item> iterator=allItems.iterator();
    Set<String> projectHasTdm=new HashSet<String>();
    while (iterator.hasNext()) {
      Item item=iterator.next();
      project=pManager.getProject(item);
      String label=item.getProperty().getLabel();
      IPath proRelativePath=getProjectPath().append(FileConstants.LOCAL_PROJECT_FILENAME);
      IPath proSourcePath=workspacePath.append(proRelativePath);
      IPath proTargetPath=new Path(destinationDirectory.getAbsolutePath()).append(proRelativePath);
      FilesUtils.copyFile(new File(proSourcePath.toPortableString()),new File(proTargetPath.toPortableString()));
      toExport.put(proTargetPath.toFile(),proRelativePath);
      String technicalLabel=project.getTechnicalLabel();
      if (tdmService != null && !projectHasTdm.contains(technicalLabel) && tdmService.isTransformItem(item)) {
        projectHasTdm.add(technicalLabel);
        IPath tdmPropsPath=getProjectPath().append(FileConstants.TDM_PROPS_PATH);
        IPath propsSourcePath=workspacePath.append(tdmPropsPath);
        IPath propsTargetPath=new Path(destinationDirectory.getAbsolutePath()).append(tdmPropsPath);
        FilesUtils.copyFile(new File(propsSourcePath.toPortableString()),new File(propsTargetPath.toPortableString()));
        toExport.put(propsTargetPath.toFile(),tdmPropsPath);
      }
      if (item.getProperty() instanceof FakePropertyImpl) {
        FakePropertyImpl fakeProperty=(FakePropertyImpl)item.getProperty();
        IPath itemResPath=fakeProperty.getItemPath().makeRelative();
        IPath itemSourcePath=workspacePath.append(itemResPath);
        IPath itemTargetPath=new Path(destinationDirectory.getAbsolutePath()).append(itemResPath);
        FilesUtils.copyFile(new File(itemSourcePath.toPortableString()),new File(itemTargetPath.toPortableString()));
        toExport.put(itemTargetPath.toFile(),itemResPath);
        continue;
      }
      XmiResourceManager localRepositoryManager=ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager();
      IPath propertyPath=null;
      for (      Resource curResource : localRepositoryManager.getAffectedResources(item.getProperty())) {
        URI uri=curResource.getURI();
        IPath relativeItemPath=URIHelper.convert(uri).makeRelative();
        IPath sourcePath=workspacePath.append(relativeItemPath);
        IPath targetPath=new Path(destinationDirectory.getAbsolutePath()).append(relativeItemPath);
        FilesUtils.copyFile(new File(sourcePath.toPortableString()),new File(targetPath.toPortableString()));
        toExport.put(targetPath.toFile(),relativeItemPath);
        if (uri.lastSegment() != null && uri.lastSegment().endsWith(FileConstants.PROPERTIES_FILE_SUFFIX)) {
          propertyPath=targetPath;
        }
      }
      if (propertyPath == null) {
        return toExport;
      }
      if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.JAVA)) {
        if (item instanceof RoutineItem) {
          List list=((RoutineItem)item).getImports();
          for (int i=0; i < list.size(); i++) {
            String jarName=((IMPORTTypeImpl)list.get(i)).getMODULE();
            jarNameList.add(jarName.toString());
          }
        }
      }
      boolean needChangeItem=false;
      needChangeItem=needChangeItem || item.getState().isLocked();
      needChangeItem=needChangeItem || !item.getProperty().getLabel().replace(' ','_').equals(item.getProperty().getLabel());
      if (needChangeItem) {
        XmiResourceManager xmiMamanger=new XmiResourceManager();
        Resource loadProject=projectResourcMap.get(proTargetPath);
        if (loadProject == null) {
          URI projectUri=URI.createFileURI(proTargetPath.toPortableString());
          loadProject=xmiMamanger.resourceSet.getResource(projectUri,true);
          projectResourcMap.put(proTargetPath,loadProject);
        }
        URI propertyUri=URI.createFileURI(propertyPath.toPortableString());
        Resource propertyResource=xmiMamanger.resourceSet.getResource(propertyUri,true);
        Property loadProperty=(Property)EcoreUtil.getObjectByType(propertyResource.getContents(),PropertiesPackage.eINSTANCE.getProperty());
        Item newItem=loadProperty.getItem();
        fixItem(newItem);
        fixItemLockState(newItem);
        saveResources(xmiMamanger.resourceSet);
      }
      iterator.remove();
      TimeMeasure.step("String_Node_Str","String_Node_Str" + label);
      progressMonitor.worked(1);
    }
    ILibraryManagerService repositoryBundleService=CorePlugin.getDefault().getRepositoryBundleService();
    for (    String jarName : jarNameList) {
      IPath jarPath=new Path(getNeedProjectPath()).append("String_Node_Str");
      String filePath=new Path(destinationDirectory.toString()).append(jarPath.toString()).toPortableString();
      if (repositoryBundleService.contains(jarName)) {
        repositoryBundleService.retrieve(jarName,filePath,new NullProgressMonitor());
        toExport.put(new File(filePath,jarName),jarPath.append(jarName));
      }
    }
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
 finally {
    TimeMeasure.end("String_Node_Str");
    TimeMeasure.display=false;
    TimeMeasure.displaySteps=false;
    TimeMeasure.measureActive=false;
  }
  return toExport;
}

Fixed version (ground truth):
private Map<File,IPath> exportItems2(Collection<Item> items,File destinationDirectory,boolean projectFolderStructure,IProgressMonitor progressMonitor) throws Exception {
  Map<File,IPath> toExport=new HashMap<File,IPath>();
  progressMonitor.beginTask("String_Node_Str",items.size() + 1);
  TimeMeasure.display=CommonsPlugin.isDebugMode();
  TimeMeasure.displaySteps=CommonsPlugin.isDebugMode();
  TimeMeasure.measureActive=CommonsPlugin.isDebugMode();
  TimeMeasure.begin("String_Node_Str");
  try {
    Map<Item,Project> itemProjectMap=new HashMap<Item,Project>();
    Collection<Item> allItems=new ArrayList<Item>(items);
    items.clear();
    if (allItems.isEmpty()) {
      IPath proRelativePath=getProjectPath().append(FileConstants.LOCAL_PROJECT_FILENAME);
      IPath proSourcePath=workspacePath.append(proRelativePath);
      IPath proTargetPath=new Path(destinationDirectory.getAbsolutePath()).append(proRelativePath);
      FilesUtils.copyFile(new File(proSourcePath.toPortableString()),new File(proTargetPath.toPortableString()));
      toExport.put(proTargetPath.toFile(),proRelativePath);
      return toExport;
    }
    allItems=sortItemsByProject(allItems,itemProjectMap);
    ITransformService tdmService=null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITransformService.class)) {
      tdmService=(ITransformService)GlobalServiceRegister.getDefault().getService(ITransformService.class);
    }
    itemProjectMap.clear();
    Set<String> jarNameList=new HashSet<String>();
    Iterator<Item> iterator=allItems.iterator();
    Set<String> projectHasTdm=new HashSet<String>();
    while (iterator.hasNext()) {
      Item item=iterator.next();
      project=pManager.getProject(item);
      String label=item.getProperty().getLabel();
      IPath proRelativePath=getProjectPath().append(FileConstants.LOCAL_PROJECT_FILENAME);
      IPath proSourcePath=workspacePath.append(proRelativePath);
      IPath proTargetPath=new Path(destinationDirectory.getAbsolutePath()).append(proRelativePath);
      FilesUtils.copyFile(new File(proSourcePath.toPortableString()),new File(proTargetPath.toPortableString()));
      toExport.put(proTargetPath.toFile(),proRelativePath);
      String technicalLabel=project.getTechnicalLabel();
      if (tdmService != null && !projectHasTdm.contains(technicalLabel) && tdmService.isTransformItem(item)) {
        projectHasTdm.add(technicalLabel);
        IPath tdmPropsPath=getProjectPath().append(FileConstants.TDM_PROPS_PATH);
        IPath propsSourcePath=workspacePath.append(tdmPropsPath);
        IPath propsTargetPath=new Path(destinationDirectory.getAbsolutePath()).append(tdmPropsPath);
        File source=new File(propsSourcePath.toPortableString());
        if (source.exists()) {
          FilesUtils.copyFile(source,new File(propsTargetPath.toPortableString()));
          toExport.put(propsTargetPath.toFile(),tdmPropsPath);
        }
      }
      if (item.getProperty() instanceof FakePropertyImpl) {
        FakePropertyImpl fakeProperty=(FakePropertyImpl)item.getProperty();
        IPath itemResPath=fakeProperty.getItemPath().makeRelative();
        IPath itemSourcePath=workspacePath.append(itemResPath);
        IPath itemTargetPath=new Path(destinationDirectory.getAbsolutePath()).append(itemResPath);
        FilesUtils.copyFile(new File(itemSourcePath.toPortableString()),new File(itemTargetPath.toPortableString()));
        toExport.put(itemTargetPath.toFile(),itemResPath);
        continue;
      }
      XmiResourceManager localRepositoryManager=ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager();
      IPath propertyPath=null;
      for (      Resource curResource : localRepositoryManager.getAffectedResources(item.getProperty())) {
        URI uri=curResource.getURI();
        IPath relativeItemPath=URIHelper.convert(uri).makeRelative();
        IPath sourcePath=workspacePath.append(relativeItemPath);
        IPath targetPath=new Path(destinationDirectory.getAbsolutePath()).append(relativeItemPath);
        FilesUtils.copyFile(new File(sourcePath.toPortableString()),new File(targetPath.toPortableString()));
        toExport.put(targetPath.toFile(),relativeItemPath);
        if (uri.lastSegment() != null && uri.lastSegment().endsWith(FileConstants.PROPERTIES_FILE_SUFFIX)) {
          propertyPath=targetPath;
        }
      }
      if (propertyPath == null) {
        return toExport;
      }
      if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.JAVA)) {
        if (item instanceof RoutineItem) {
          List list=((RoutineItem)item).getImports();
          for (int i=0; i < list.size(); i++) {
            String jarName=((IMPORTTypeImpl)list.get(i)).getMODULE();
            jarNameList.add(jarName.toString());
          }
        }
      }
      boolean needChangeItem=false;
      needChangeItem=needChangeItem || item.getState().isLocked();
      needChangeItem=needChangeItem || !item.getProperty().getLabel().replace(' ','_').equals(item.getProperty().getLabel());
      if (needChangeItem) {
        XmiResourceManager xmiMamanger=new XmiResourceManager();
        Resource loadProject=projectResourcMap.get(proTargetPath);
        if (loadProject == null) {
          URI projectUri=URI.createFileURI(proTargetPath.toPortableString());
          loadProject=xmiMamanger.resourceSet.getResource(projectUri,true);
          projectResourcMap.put(proTargetPath,loadProject);
        }
        URI propertyUri=URI.createFileURI(propertyPath.toPortableString());
        Resource propertyResource=xmiMamanger.resourceSet.getResource(propertyUri,true);
        Property loadProperty=(Property)EcoreUtil.getObjectByType(propertyResource.getContents(),PropertiesPackage.eINSTANCE.getProperty());
        Item newItem=loadProperty.getItem();
        fixItem(newItem);
        fixItemLockState(newItem);
        saveResources(xmiMamanger.resourceSet);
      }
      iterator.remove();
      TimeMeasure.step("String_Node_Str","String_Node_Str" + label);
      progressMonitor.worked(1);
    }
    ILibraryManagerService repositoryBundleService=CorePlugin.getDefault().getRepositoryBundleService();
    for (    String jarName : jarNameList) {
      IPath jarPath=new Path(getNeedProjectPath()).append("String_Node_Str");
      String filePath=new Path(destinationDirectory.toString()).append(jarPath.toString()).toPortableString();
      if (repositoryBundleService.contains(jarName)) {
        repositoryBundleService.retrieve(jarName,filePath,new NullProgressMonitor());
        toExport.put(new File(filePath,jarName),jarPath.append(jarName));
      }
    }
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
 finally {
    TimeMeasure.end("String_Node_Str");
    TimeMeasure.display=false;
    TimeMeasure.displaySteps=false;
    TimeMeasure.measureActive=false;
  }
  return toExport;
}