@Test @WithMockUser void testHandleRequest() { ImportRun importRun = mock(ImportRun.class); when(importRunService.addImportRun("user", false)).thenReturn(importRun); HttpServletRequest httpServletRequest = mock(HttpServletRequest.class); BindingResult bindingResult = mock(BindingResult.class); ImportWizard wizard = mock(ImportWizard.class); when(wizard.getDataImportOption()).thenReturn("add"); when(wizard.getMetadataImportOption()).thenReturn("add"); assertNull(validationResultWizardPage.handleRequest(httpServletRequest, bindingResult, wizard)); }
@Override public String handleRequest(HttpServletRequest request, BindingResult result, Wizard wizard) { ImportWizardUtil.validateImportWizard(wizard); ImportWizard importWizard = (ImportWizard) wizard; String metadataImportOption = importWizard.getMetadataImportOption(); String dataImportOption = importWizard.getDataImportOption(); if (dataImportOption != null) { try { MetadataAction metadataAction = ImportWizardUtil.toMetadataAction(metadataImportOption); if (metadataAction == null) { throw new IOException("unknown metadata action: " + metadataImportOption); } DataAction dataAction = ImportWizardUtil.toDataAction(dataImportOption); if (dataAction == null) { throw new IOException("unknown data action: " + dataImportOption); } RepositoryCollection repositoryCollection = getFileRepositoryCollectionFactory() .createFileRepositoryCollection(importWizard.getFile()); ImportService importService = getImportServiceFactory() .getImportService(importWizard.getFile(), repositoryCollection); synchronized (this) { ImportRun importRun = getImportRunService().addImportRun(SecurityUtils.getCurrentUsername(), false); ((ImportWizard) wizard).setImportRunId(importRun.getId()); long callingThreadId = Thread.currentThread().getId(); getExecutorService() .execute( new ImportJob( importService, SecurityContextHolder.getContext(), repositoryCollection, metadataAction, dataAction, importRun.getId(), getImportRunService(), request.getSession(), importWizard.getSelectedPackage(), callingThreadId)); } } catch (RuntimeException | IOException e) { ImportWizardUtil.handleException(e, importWizard, result, LOG, dataImportOption); } } return null; }
ValidationResultWizardPage extends AbstractWizardPage { @Override public String handleRequest(HttpServletRequest request, BindingResult result, Wizard wizard) { ImportWizardUtil.validateImportWizard(wizard); ImportWizard importWizard = (ImportWizard) wizard; String metadataImportOption = importWizard.getMetadataImportOption(); String dataImportOption = importWizard.getDataImportOption(); if (dataImportOption != null) { try { MetadataAction metadataAction = ImportWizardUtil.toMetadataAction(metadataImportOption); if (metadataAction == null) { throw new IOException("unknown metadata action: " + metadataImportOption); } DataAction dataAction = ImportWizardUtil.toDataAction(dataImportOption); if (dataAction == null) { throw new IOException("unknown data action: " + dataImportOption); } RepositoryCollection repositoryCollection = getFileRepositoryCollectionFactory() .createFileRepositoryCollection(importWizard.getFile()); ImportService importService = getImportServiceFactory() .getImportService(importWizard.getFile(), repositoryCollection); synchronized (this) { ImportRun importRun = getImportRunService().addImportRun(SecurityUtils.getCurrentUsername(), false); ((ImportWizard) wizard).setImportRunId(importRun.getId()); long callingThreadId = Thread.currentThread().getId(); getExecutorService() .execute( new ImportJob( importService, SecurityContextHolder.getContext(), repositoryCollection, metadataAction, dataAction, importRun.getId(), getImportRunService(), request.getSession(), importWizard.getSelectedPackage(), callingThreadId)); } } catch (RuntimeException | IOException e) { ImportWizardUtil.handleException(e, importWizard, result, LOG, dataImportOption); } } return null; } }
ValidationResultWizardPage extends AbstractWizardPage { @Override public String handleRequest(HttpServletRequest request, BindingResult result, Wizard wizard) { ImportWizardUtil.validateImportWizard(wizard); ImportWizard importWizard = (ImportWizard) wizard; String metadataImportOption = importWizard.getMetadataImportOption(); String dataImportOption = importWizard.getDataImportOption(); if (dataImportOption != null) { try { MetadataAction metadataAction = ImportWizardUtil.toMetadataAction(metadataImportOption); if (metadataAction == null) { throw new IOException("unknown metadata action: " + metadataImportOption); } DataAction dataAction = ImportWizardUtil.toDataAction(dataImportOption); if (dataAction == null) { throw new IOException("unknown data action: " + dataImportOption); } RepositoryCollection repositoryCollection = getFileRepositoryCollectionFactory() .createFileRepositoryCollection(importWizard.getFile()); ImportService importService = getImportServiceFactory() .getImportService(importWizard.getFile(), repositoryCollection); synchronized (this) { ImportRun importRun = getImportRunService().addImportRun(SecurityUtils.getCurrentUsername(), false); ((ImportWizard) wizard).setImportRunId(importRun.getId()); long callingThreadId = Thread.currentThread().getId(); getExecutorService() .execute( new ImportJob( importService, SecurityContextHolder.getContext(), repositoryCollection, metadataAction, dataAction, importRun.getId(), getImportRunService(), request.getSession(), importWizard.getSelectedPackage(), callingThreadId)); } } catch (RuntimeException | IOException e) { ImportWizardUtil.handleException(e, importWizard, result, LOG, dataImportOption); } } return null; } ValidationResultWizardPage(
      ImportServiceFactory importServiceFactory,
      FileRepositoryCollectionFactory fileRepositoryCollectionFactory,
      ImportRunService importRunService); }
ValidationResultWizardPage extends AbstractWizardPage { @Override public String handleRequest(HttpServletRequest request, BindingResult result, Wizard wizard) { ImportWizardUtil.validateImportWizard(wizard); ImportWizard importWizard = (ImportWizard) wizard; String metadataImportOption = importWizard.getMetadataImportOption(); String dataImportOption = importWizard.getDataImportOption(); if (dataImportOption != null) { try { MetadataAction metadataAction = ImportWizardUtil.toMetadataAction(metadataImportOption); if (metadataAction == null) { throw new IOException("unknown metadata action: " + metadataImportOption); } DataAction dataAction = ImportWizardUtil.toDataAction(dataImportOption); if (dataAction == null) { throw new IOException("unknown data action: " + dataImportOption); } RepositoryCollection repositoryCollection = getFileRepositoryCollectionFactory() .createFileRepositoryCollection(importWizard.getFile()); ImportService importService = getImportServiceFactory() .getImportService(importWizard.getFile(), repositoryCollection); synchronized (this) { ImportRun importRun = getImportRunService().addImportRun(SecurityUtils.getCurrentUsername(), false); ((ImportWizard) wizard).setImportRunId(importRun.getId()); long callingThreadId = Thread.currentThread().getId(); getExecutorService() .execute( new ImportJob( importService, SecurityContextHolder.getContext(), repositoryCollection, metadataAction, dataAction, importRun.getId(), getImportRunService(), request.getSession(), importWizard.getSelectedPackage(), callingThreadId)); } } catch (RuntimeException | IOException e) { ImportWizardUtil.handleException(e, importWizard, result, LOG, dataImportOption); } } return null; } ValidationResultWizardPage(
      ImportServiceFactory importServiceFactory,
      FileRepositoryCollectionFactory fileRepositoryCollectionFactory,
      ImportRunService importRunService); @Override String getTitle(); @Override String handleRequest(HttpServletRequest request, BindingResult result, Wizard wizard); }
ValidationResultWizardPage extends AbstractWizardPage { @Override public String handleRequest(HttpServletRequest request, BindingResult result, Wizard wizard) { ImportWizardUtil.validateImportWizard(wizard); ImportWizard importWizard = (ImportWizard) wizard; String metadataImportOption = importWizard.getMetadataImportOption(); String dataImportOption = importWizard.getDataImportOption(); if (dataImportOption != null) { try { MetadataAction metadataAction = ImportWizardUtil.toMetadataAction(metadataImportOption); if (metadataAction == null) { throw new IOException("unknown metadata action: " + metadataImportOption); } DataAction dataAction = ImportWizardUtil.toDataAction(dataImportOption); if (dataAction == null) { throw new IOException("unknown data action: " + dataImportOption); } RepositoryCollection repositoryCollection = getFileRepositoryCollectionFactory() .createFileRepositoryCollection(importWizard.getFile()); ImportService importService = getImportServiceFactory() .getImportService(importWizard.getFile(), repositoryCollection); synchronized (this) { ImportRun importRun = getImportRunService().addImportRun(SecurityUtils.getCurrentUsername(), false); ((ImportWizard) wizard).setImportRunId(importRun.getId()); long callingThreadId = Thread.currentThread().getId(); getExecutorService() .execute( new ImportJob( importService, SecurityContextHolder.getContext(), repositoryCollection, metadataAction, dataAction, importRun.getId(), getImportRunService(), request.getSession(), importWizard.getSelectedPackage(), callingThreadId)); } } catch (RuntimeException | IOException e) { ImportWizardUtil.handleException(e, importWizard, result, LOG, dataImportOption); } } return null; } ValidationResultWizardPage(
      ImportServiceFactory importServiceFactory,
      FileRepositoryCollectionFactory fileRepositoryCollectionFactory,
      ImportRunService importRunService); @Override String getTitle(); @Override String handleRequest(HttpServletRequest request, BindingResult result, Wizard wizard);  }