Program: 124101
Project: 124101
Buggy source:
private void importItemRecord(ResourcesManager manager,ItemRecord itemRecord,boolean overwrite,IPath destinationPath,final Set<String> overwriteDeletedItems,String contentType,final IProgressMonitor monitor){
  monitor.subTask(Messages.getString("String_Node_Str") + itemRecord.getItemName());
  resolveItem(manager,itemRecord);
  int num=0;
  for (  Object obj : itemRecord.getResourceSet().getResources()) {
    if (!(obj instanceof PropertiesProjectResourceImpl)) {
      if (obj instanceof XMIResourceImpl) {
        num++;
        if (num > 2) {
          try {
            throw new InvocationTargetException(new PersistenceException("String_Node_Str" + itemRecord.getLabel() + "String_Node_Str"));
          }
 catch (          InvocationTargetException e) {
            ExceptionHandler.process(e);
          }
          return;
        }
      }
    }
  }
  final Item item=itemRecord.getItem();
  if (item != null) {
    ProxyRepositoryFactory repFactory=ProxyRepositoryFactory.getInstance();
    ERepositoryObjectType itemType=ERepositoryObjectType.getItemType(item);
    IPath path=new Path(item.getState().getPath());
    if (destinationPath != null && itemType.name().equals(contentType)) {
      path=destinationPath.append(path);
    }
    try {
      repFactory.createParentFoldersRecursively(ProjectManager.getInstance().getCurrentProject(),itemType,path,true);
    }
 catch (    Exception e) {
      logError(e);
      path=new Path("String_Node_Str");
    }
    try {
      Item tmpItem=item;
      String id=itemRecord.getProperty().getId();
      IRepositoryViewObject lastVersion=itemRecord.getExistingItemWithSameId();
      if (lastVersion != null && overwrite && !itemRecord.isLocked() && (itemRecord.getState() == State.ID_EXISTED || itemRecord.getState() == State.NAME_EXISTED || itemRecord.getState() == State.NAME_AND_ID_EXISTED) && !deletedItems.contains(id)) {
        if (!overwriteDeletedItems.contains(id)) {
          ERepositoryStatus status=repFactory.getStatus(lastVersion);
          if (status == ERepositoryStatus.DELETED) {
            repFactory.restoreObject(lastVersion,path);
          }
          overwriteDeletedItems.add(id);
        }
        if (itemRecord.getState().equals(ItemRecord.State.NAME_EXISTED) || itemRecord.getState().equals(ItemRecord.State.NAME_AND_ID_EXISTED)) {
          repFactory.forceDeleteObjectPhysical(lastVersion,itemRecord.getProperty().getVersion());
        }
        lastVersion=null;
      }
      User author=itemRecord.getProperty().getAuthor();
      if (author != null) {
        if (!repFactory.setAuthorByLogin(tmpItem,author.getLogin())) {
          tmpItem.getProperty().setAuthor(null);
        }
      }
      if (item instanceof JobletProcessItem) {
        hasJoblets=true;
      }
      if (tmpItem instanceof ProcessItem && !statAndLogsSettingsReloaded && !implicitSettingsReloaded) {
        ProcessItem processItem=(ProcessItem)tmpItem;
        ParametersType paType=processItem.getProcess().getParameters();
        boolean statsPSettingRemoved=false;
        if (itemRecord.isRemoveProjectStatslog()) {
          if (paType != null) {
            String paramName="String_Node_Str";
            EList listParamType=paType.getElementParameter();
            for (int j=0; j < listParamType.size(); j++) {
              ElementParameterType pType=(ElementParameterType)listParamType.get(j);
              if (pType != null && paramName.equals(pType.getName())) {
                pType.setValue(Boolean.FALSE.toString());
                statsPSettingRemoved=true;
                break;
              }
            }
          }
        }
        String statslogUsePSetting=null;
        String implicitUsePSetting=null;
        if (paType != null) {
          EList listParamType=paType.getElementParameter();
          for (int j=0; j < listParamType.size(); j++) {
            ElementParameterType pType=(ElementParameterType)listParamType.get(j);
            if (pType != null) {
              if (!statsPSettingRemoved && "String_Node_Str".equals(pType.getName())) {
                statslogUsePSetting=pType.getValue();
              }
              if ("String_Node_Str".equals(pType.getName())) {
                implicitUsePSetting=pType.getValue();
              }
              if (statsPSettingRemoved && implicitUsePSetting != null || !statsPSettingRemoved && implicitUsePSetting != null && statslogUsePSetting != null) {
                break;
              }
            }
          }
        }
        if (statslogUsePSetting != null && Boolean.parseBoolean(statslogUsePSetting) && !statAndLogsSettingsReloaded) {
          CorePlugin.getDefault().getDesignerCoreService().reloadParamFromProjectSettings(paType,"String_Node_Str");
          statAndLogsSettingsReloaded=true;
        }
        if (implicitUsePSetting != null && Boolean.parseBoolean(implicitUsePSetting) && !implicitSettingsReloaded) {
          CorePlugin.getDefault().getDesignerCoreService().reloadParamFromProjectSettings(paType,"String_Node_Str");
          implicitSettingsReloaded=true;
        }
      }
      if (lastVersion == null || itemRecord.getState().equals(ItemRecord.State.ID_EXISTED)) {
        boolean isConnectionEmptyBeforeMigration=tmpItem instanceof ConnectionItem && ((ConnectionItem)tmpItem).getConnection().eResource() == null && !itemRecord.getMigrationTasksToApply().isEmpty();
        repFactory.create(tmpItem,path,true);
        if (isConnectionEmptyBeforeMigration) {
          InputStream is=manager.getStream(itemRecord.getPath().removeFileExtension().addFileExtension(FileConstants.ITEM_EXTENSION));
          try {
            URI propertyResourceURI=EcoreUtil.getURI(((ConnectionItem)tmpItem).getProperty());
            URI relativePlateformDestUri=propertyResourceURI.trimFileExtension().appendFileExtension(FileConstants.ITEM_EXTENSION);
            URL fileURL=FileLocator.toFileURL(new java.net.URL("String_Node_Str" + relativePlateformDestUri.toPlatformString(true)));
            OutputStream os=new FileOutputStream(fileURL.getFile());
            try {
              FileCopyUtils.copyStreams(is,os);
            }
  finally {
              os.close();
            }
          }
  finally {
            is.close();
          }
        }
 else {
          copyScreenshotFile(manager,itemRecord);
          boolean haveRef=copyReferenceFiles(manager,tmpItem,itemRecord.getPath());
          if (haveRef) {
            repFactory.save(tmpItem,true);
          }
          repFactory.unloadResources(tmpItem.getProperty());
        }
        itemRecord.setImportPath(path.toPortableString());
        itemRecord.setRepositoryType(itemType);
        itemRecord.setItemId(itemRecord.getProperty().getId());
        itemRecord.setItemVersion(itemRecord.getProperty().getVersion());
        itemRecord.setImported(true);
        cache.addToCache(tmpItem);
      }
 else       if (VersionUtils.compareTo(lastVersion.getProperty().getVersion(),tmpItem.getProperty().getVersion()) < 0) {
        repFactory.forceCreate(tmpItem,path);
        itemRecord.setImportPath(path.toPortableString());
        itemRecord.setItemId(itemRecord.getProperty().getId());
        itemRecord.setRepositoryType(itemType);
        itemRecord.setItemVersion(itemRecord.getProperty().getVersion());
        itemRecord.setImported(true);
        cache.addToCache(tmpItem);
      }
 else {
        PersistenceException e=new PersistenceException(Messages.getString("String_Node_Str",tmpItem.getProperty()));
        itemRecord.addError(e.getMessage());
        logError(e);
      }
      if (tmpItem != null) {
        RelationshipItemBuilder.getInstance().addOrUpdateItem(tmpItem,true);
        if (tmpItem.getState() != null) {
          if (itemType != null) {
            final Set<String> folders=restoreFolder.getFolders(itemType);
            if (folders != null) {
              for (              String folderPath : folders) {
                if (folderPath != null && folderPath.equals(path.toString())) {
                  FolderItem folderItem=repFactory.getFolderItem(ProjectManager.getInstance().getCurrentProject(),itemType,path);
                  if (folderItem != null) {
                    folderItem.getState().setDeleted(false);
                    while (!(folderItem.getParent() instanceof Project)) {
                      folderItem=(FolderItem)folderItem.getParent();
                      if (folderItem.getType() == FolderType.SYSTEM_FOLDER_LITERAL) {
                        break;
                      }
                      folderItem.getState().setDeleted(false);
                    }
                  }
                  break;
                }
              }
            }
          }
        }
      }
    }
 catch (    Exception e) {
      itemRecord.addError(e.getMessage());
      logError(e);
    }
  }
  String label=itemRecord.getLabel();
  for (  Resource resource : itemRecord.getResourceSet().getResources()) {
    if (!(resource instanceof ByteArrayResource)) {
      resource.unload();
    }
  }
  TimeMeasure.step("String_Node_Str","String_Node_Str" + label);
  applyMigrationTasks(itemRecord,monitor);
  TimeMeasure.step("String_Node_Str","String_Node_Str" + label);
}

Fixed version (ground truth):
private void importItemRecord(ResourcesManager manager,ItemRecord itemRecord,boolean overwrite,IPath destinationPath,final Set<String> overwriteDeletedItems,String contentType,final IProgressMonitor monitor){
  monitor.subTask(Messages.getString("String_Node_Str") + itemRecord.getItemName());
  resolveItem(manager,itemRecord);
  int num=0;
  for (  Object obj : itemRecord.getResourceSet().getResources()) {
    if (!(obj instanceof PropertiesProjectResourceImpl)) {
      if (obj instanceof XMIResourceImpl) {
        num++;
        if (num > 2) {
          try {
            throw new InvocationTargetException(new PersistenceException("String_Node_Str" + itemRecord.getLabel() + "String_Node_Str"));
          }
 catch (          InvocationTargetException e) {
            ExceptionHandler.process(e);
          }
          return;
        }
      }
    }
  }
  final Item item=itemRecord.getItem();
  if (item != null) {
    ProxyRepositoryFactory repFactory=ProxyRepositoryFactory.getInstance();
    ERepositoryObjectType itemType=ERepositoryObjectType.getItemType(item);
    IPath path=new Path(item.getState().getPath());
    if (destinationPath != null && itemType.name().equals(contentType)) {
      path=destinationPath.append(path);
    }
    try {
      repFactory.createParentFoldersRecursively(ProjectManager.getInstance().getCurrentProject(),itemType,path,true);
    }
 catch (    Exception e) {
      logError(e);
      path=new Path("String_Node_Str");
    }
    try {
      Item tmpItem=item;
      String id=itemRecord.getProperty().getId();
      IRepositoryViewObject lastVersion=itemRecord.getExistingItemWithSameId();
      if (lastVersion != null && overwrite && !itemRecord.isLocked() && (itemRecord.getState() == State.ID_EXISTED || itemRecord.getState() == State.NAME_EXISTED || itemRecord.getState() == State.NAME_AND_ID_EXISTED) && !deletedItems.contains(id)) {
        if (!overwriteDeletedItems.contains(id)) {
          ERepositoryStatus status=repFactory.getStatus(lastVersion);
          if (status == ERepositoryStatus.DELETED) {
            repFactory.restoreObject(lastVersion,path);
          }
          overwriteDeletedItems.add(id);
        }
        if (itemRecord.getState().equals(ItemRecord.State.NAME_EXISTED) || itemRecord.getState().equals(ItemRecord.State.NAME_AND_ID_EXISTED)) {
          repFactory.forceDeleteObjectPhysical(lastVersion,itemRecord.getProperty().getVersion());
        }
        lastVersion=null;
      }
      User author=itemRecord.getProperty().getAuthor();
      if (author != null) {
        if (!repFactory.setAuthorByLogin(tmpItem,author.getLogin())) {
          tmpItem.getProperty().setAuthor(null);
        }
      }
      if (item instanceof JobletProcessItem) {
        hasJoblets=true;
      }
      if (tmpItem instanceof ProcessItem && !statAndLogsSettingsReloaded && !implicitSettingsReloaded) {
        ProcessItem processItem=(ProcessItem)tmpItem;
        ParametersType paType=processItem.getProcess().getParameters();
        boolean statsPSettingRemoved=false;
        if (itemRecord.isRemoveProjectStatslog()) {
          if (paType != null) {
            String paramName="String_Node_Str";
            EList listParamType=paType.getElementParameter();
            for (int j=0; j < listParamType.size(); j++) {
              ElementParameterType pType=(ElementParameterType)listParamType.get(j);
              if (pType != null && paramName.equals(pType.getName())) {
                pType.setValue(Boolean.FALSE.toString());
                statsPSettingRemoved=true;
                break;
              }
            }
          }
        }
        String statslogUsePSetting=null;
        String implicitUsePSetting=null;
        if (paType != null) {
          EList listParamType=paType.getElementParameter();
          for (int j=0; j < listParamType.size(); j++) {
            ElementParameterType pType=(ElementParameterType)listParamType.get(j);
            if (pType != null) {
              if (!statsPSettingRemoved && "String_Node_Str".equals(pType.getName())) {
                statslogUsePSetting=pType.getValue();
              }
              if ("String_Node_Str".equals(pType.getName())) {
                implicitUsePSetting=pType.getValue();
              }
              if (statsPSettingRemoved && implicitUsePSetting != null || !statsPSettingRemoved && implicitUsePSetting != null && statslogUsePSetting != null) {
                break;
              }
            }
          }
        }
        if (statslogUsePSetting != null && Boolean.parseBoolean(statslogUsePSetting) && !statAndLogsSettingsReloaded) {
          CorePlugin.getDefault().getDesignerCoreService().reloadParamFromProjectSettings(paType,"String_Node_Str");
          statAndLogsSettingsReloaded=true;
        }
        if (implicitUsePSetting != null && Boolean.parseBoolean(implicitUsePSetting) && !implicitSettingsReloaded) {
          CorePlugin.getDefault().getDesignerCoreService().reloadParamFromProjectSettings(paType,"String_Node_Str");
          implicitSettingsReloaded=true;
        }
      }
      if (lastVersion == null || itemRecord.getState().equals(ItemRecord.State.ID_EXISTED)) {
        boolean isConnectionEmptyBeforeMigration=tmpItem instanceof ConnectionItem && ((ConnectionItem)tmpItem).getConnection().eResource() == null && !itemRecord.getMigrationTasksToApply().isEmpty();
        repFactory.create(tmpItem,path,true);
        if (isConnectionEmptyBeforeMigration) {
          InputStream is=manager.getStream(itemRecord.getPath().removeFileExtension().addFileExtension(FileConstants.ITEM_EXTENSION));
          try {
            URI propertyResourceURI=EcoreUtil.getURI(((ConnectionItem)tmpItem).getProperty());
            URI relativePlateformDestUri=propertyResourceURI.trimFileExtension().appendFileExtension(FileConstants.ITEM_EXTENSION);
            URL fileURL=FileLocator.toFileURL(new java.net.URL("String_Node_Str" + relativePlateformDestUri.toPlatformString(true)));
            OutputStream os=new FileOutputStream(fileURL.getFile());
            try {
              FileCopyUtils.copyStreams(is,os);
            }
  finally {
              os.close();
            }
          }
  finally {
            is.close();
          }
        }
 else {
          copyScreenshotFile(manager,itemRecord);
          boolean haveRef=copyReferenceFiles(manager,tmpItem,itemRecord.getPath());
          if (haveRef) {
            repFactory.save(tmpItem,true);
          }
        }
        repFactory.unloadResources(tmpItem.getProperty());
        itemRecord.setImportPath(path.toPortableString());
        itemRecord.setRepositoryType(itemType);
        itemRecord.setItemId(itemRecord.getProperty().getId());
        itemRecord.setItemVersion(itemRecord.getProperty().getVersion());
        itemRecord.setImported(true);
        cache.addToCache(tmpItem);
      }
 else       if (VersionUtils.compareTo(lastVersion.getProperty().getVersion(),tmpItem.getProperty().getVersion()) < 0) {
        repFactory.forceCreate(tmpItem,path);
        itemRecord.setImportPath(path.toPortableString());
        itemRecord.setItemId(itemRecord.getProperty().getId());
        itemRecord.setRepositoryType(itemType);
        itemRecord.setItemVersion(itemRecord.getProperty().getVersion());
        itemRecord.setImported(true);
        cache.addToCache(tmpItem);
      }
 else {
        PersistenceException e=new PersistenceException(Messages.getString("String_Node_Str",tmpItem.getProperty()));
        itemRecord.addError(e.getMessage());
        logError(e);
      }
      if (tmpItem != null) {
        RelationshipItemBuilder.getInstance().addOrUpdateItem(tmpItem,true);
        if (tmpItem.getState() != null) {
          if (itemType != null) {
            final Set<String> folders=restoreFolder.getFolders(itemType);
            if (folders != null) {
              for (              String folderPath : folders) {
                if (folderPath != null && folderPath.equals(path.toString())) {
                  FolderItem folderItem=repFactory.getFolderItem(ProjectManager.getInstance().getCurrentProject(),itemType,path);
                  if (folderItem != null) {
                    folderItem.getState().setDeleted(false);
                    while (!(folderItem.getParent() instanceof Project)) {
                      folderItem=(FolderItem)folderItem.getParent();
                      if (folderItem.getType() == FolderType.SYSTEM_FOLDER_LITERAL) {
                        break;
                      }
                      folderItem.getState().setDeleted(false);
                    }
                  }
                  break;
                }
              }
            }
          }
        }
      }
    }
 catch (    Exception e) {
      itemRecord.addError(e.getMessage());
      logError(e);
    }
  }
  String label=itemRecord.getLabel();
  for (  Resource resource : itemRecord.getResourceSet().getResources()) {
    if (!(resource instanceof ByteArrayResource)) {
      resource.unload();
    }
  }
  TimeMeasure.step("String_Node_Str","String_Node_Str" + label);
  applyMigrationTasks(itemRecord,monitor);
  TimeMeasure.step("String_Node_Str","String_Node_Str" + label);
}