Source:
public String handleRequest(HttpServletRequest request, BindingResult result, Wizard wizard) { ImportWizardUtil.validateImportWizard(wizard); ImportWizard importWizard = (ImportWizard) wizard; String entityImportOption = importWizard.getEntityImportOption(); if (entityImportOption != null) { try { DatabaseAction entityDbAction = ImportWizardUtil.toDatabaseAction(entityImportOption); if (entityDbAction == null) throw new IOException("unknown database action: " + entityImportOption); RepositoryCollection repositoryCollection = fileRepositoryCollectionFactory.createFileRepositoryCollection( importWizard.getFile()); ImportService importService = importServiceFactory.getImportService(importWizard.getFile(), repositoryCollection); if (!importWizard.getEntitiesImportable().containsValue(false)) { String selectedPackage = request.getParameter("selectedPackage"); Map<String, Boolean> entitiesImportable = importService.determineImportableEntities(metaDataService, repositoryCollection, selectedPackage); updateFieldReports(importWizard, selectedPackage, entitiesImportable); importWizard.setEntitiesImportable(entitiesImportable); List<String> entitiesNotImportable = entitiesImportable.entrySet() .stream() .filter(entity -> !entity.getValue()) .map(Map.Entry::getKey) .collect(toList()); if (!entitiesNotImportable.isEmpty()) throw new MolgenisDataException( "You are trying to upload entities that are not compatible with the already existing entities: " + entitiesNotImportable.toString()); } } catch (RuntimeException | IOException e) { ImportWizardUtil.handleException(e, importWizard, result, LOG, entityImportOption); } } return null; }

Target:
public String handleRequest(HttpServletRequest request, BindingResult result, Wizard wizard) { ImportWizardUtil.validateImportWizard(wizard); ImportWizard importWizard = (ImportWizard) wizard; String entityImportOption = importWizard.getEntityImportOption(); if (entityImportOption != null) { try { DatabaseAction entityDbAction = ImportWizardUtil.toDatabaseAction(entityImportOption); if (entityDbAction == null) { throw new IOException("unknown database action: " + entityImportOption); } RepositoryCollection repositoryCollection = fileRepositoryCollectionFactory.createFileRepositoryCollection( importWizard.getFile()); ImportService importService = importServiceFactory.getImportService(importWizard.getFile(), repositoryCollection); if (!importWizard.getEntitiesImportable().containsValue(false)) { String selectedPackage = request.getParameter("selectedPackage"); Map<String, Boolean> entitiesImportable = importService.determineImportableEntities(metaDataService, repositoryCollection, selectedPackage); updateFieldReports(importWizard, selectedPackage, entitiesImportable); importWizard.setEntitiesImportable(entitiesImportable); List<String> entitiesNotImportable = entitiesImportable.entrySet() .stream() .filter(entity -> !entity.getValue()) .map(Map.Entry::getKey) .collect(toList()); if (!entitiesNotImportable.isEmpty()) { throw new MolgenisDataException( "You are trying to upload entities that are not compatible with the already existing entities: " + entitiesNotImportable.toString()); } } } catch (RuntimeException | IOException e) { ImportWizardUtil.handleException(e, importWizard, result, LOG, entityImportOption); } } return null; }