@Test @RunWithCustomExecutor public void should_exec_workflow_and_return_build_status_OK() throws Exception { given(storageClient.getContainerAsync("other_binary_strategy", objectId, OBJECT, getNoLogAccessLog())) .willReturn(createOkResponse("image-files-with-data")); List<ItemStatus> status = plugin.executeList(parameter, handler); assertThat(status).extracting(ItemStatus::getGlobalStatus).containsOnly(OK); }
@Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { List<PreservationDistributionLine> entries = IntStream.range(0, workerParameters.getObjectNameList().size()) .mapToObj(index -> mapToParamsPreservationDistributionFile(workerParameters, index)) .collect(Collectors.toList()); String griffinId = entries.get(0).getGriffinId(); String batchId = GUIDFactory.newGUID().getId(); try { Path batchDirectory = createBatchDirectory(griffinId, batchId); copyInputFiles(batchDirectory, entries); String requestId = workerParameters.getRequestId(); Integer tenantId = VitamThreadUtils.getVitamSession().getTenantId(); createParametersBatchFile(entries, batchDirectory, requestId, batchId); int timeout = entries.get(0).getTimeout(); ResultPreservation result = launchGriffin(griffinId, batchDirectory, timeout); List<WorkflowBatchResult> workflowResults = generateWorkflowBatchResults(result, entries); handler.setCurrentObjectId(WorkflowBatchResults.NAME); handler.addOutputResult(0, new WorkflowBatchResults(batchDirectory, workflowResults)); createReport(workflowResults, entries, tenantId, requestId); return workflowResults.stream() .map(w -> buildItemStatus(PLUGIN_NAME, w.getGlobalStatus(), EventDetails.of(String.format("%s executed", PLUGIN_NAME)))) .collect(Collectors.toList()); } catch (Exception e) { tryDeleteLocalPreservationFiles(Paths.get(griffinInputFolder, griffinId, batchId)); throw new ProcessingException(e); } }
PreservationActionPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { List<PreservationDistributionLine> entries = IntStream.range(0, workerParameters.getObjectNameList().size()) .mapToObj(index -> mapToParamsPreservationDistributionFile(workerParameters, index)) .collect(Collectors.toList()); String griffinId = entries.get(0).getGriffinId(); String batchId = GUIDFactory.newGUID().getId(); try { Path batchDirectory = createBatchDirectory(griffinId, batchId); copyInputFiles(batchDirectory, entries); String requestId = workerParameters.getRequestId(); Integer tenantId = VitamThreadUtils.getVitamSession().getTenantId(); createParametersBatchFile(entries, batchDirectory, requestId, batchId); int timeout = entries.get(0).getTimeout(); ResultPreservation result = launchGriffin(griffinId, batchDirectory, timeout); List<WorkflowBatchResult> workflowResults = generateWorkflowBatchResults(result, entries); handler.setCurrentObjectId(WorkflowBatchResults.NAME); handler.addOutputResult(0, new WorkflowBatchResults(batchDirectory, workflowResults)); createReport(workflowResults, entries, tenantId, requestId); return workflowResults.stream() .map(w -> buildItemStatus(PLUGIN_NAME, w.getGlobalStatus(), EventDetails.of(String.format("%s executed", PLUGIN_NAME)))) .collect(Collectors.toList()); } catch (Exception e) { tryDeleteLocalPreservationFiles(Paths.get(griffinInputFolder, griffinId, batchId)); throw new ProcessingException(e); } } }
PreservationActionPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { List<PreservationDistributionLine> entries = IntStream.range(0, workerParameters.getObjectNameList().size()) .mapToObj(index -> mapToParamsPreservationDistributionFile(workerParameters, index)) .collect(Collectors.toList()); String griffinId = entries.get(0).getGriffinId(); String batchId = GUIDFactory.newGUID().getId(); try { Path batchDirectory = createBatchDirectory(griffinId, batchId); copyInputFiles(batchDirectory, entries); String requestId = workerParameters.getRequestId(); Integer tenantId = VitamThreadUtils.getVitamSession().getTenantId(); createParametersBatchFile(entries, batchDirectory, requestId, batchId); int timeout = entries.get(0).getTimeout(); ResultPreservation result = launchGriffin(griffinId, batchDirectory, timeout); List<WorkflowBatchResult> workflowResults = generateWorkflowBatchResults(result, entries); handler.setCurrentObjectId(WorkflowBatchResults.NAME); handler.addOutputResult(0, new WorkflowBatchResults(batchDirectory, workflowResults)); createReport(workflowResults, entries, tenantId, requestId); return workflowResults.stream() .map(w -> buildItemStatus(PLUGIN_NAME, w.getGlobalStatus(), EventDetails.of(String.format("%s executed", PLUGIN_NAME)))) .collect(Collectors.toList()); } catch (Exception e) { tryDeleteLocalPreservationFiles(Paths.get(griffinInputFolder, griffinId, batchId)); throw new ProcessingException(e); } } PreservationActionPlugin(); @VisibleForTesting  PreservationActionPlugin(StorageClientFactory storage, PreservationReportService report, String inputFolder,
        String execFolder); }
PreservationActionPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { List<PreservationDistributionLine> entries = IntStream.range(0, workerParameters.getObjectNameList().size()) .mapToObj(index -> mapToParamsPreservationDistributionFile(workerParameters, index)) .collect(Collectors.toList()); String griffinId = entries.get(0).getGriffinId(); String batchId = GUIDFactory.newGUID().getId(); try { Path batchDirectory = createBatchDirectory(griffinId, batchId); copyInputFiles(batchDirectory, entries); String requestId = workerParameters.getRequestId(); Integer tenantId = VitamThreadUtils.getVitamSession().getTenantId(); createParametersBatchFile(entries, batchDirectory, requestId, batchId); int timeout = entries.get(0).getTimeout(); ResultPreservation result = launchGriffin(griffinId, batchDirectory, timeout); List<WorkflowBatchResult> workflowResults = generateWorkflowBatchResults(result, entries); handler.setCurrentObjectId(WorkflowBatchResults.NAME); handler.addOutputResult(0, new WorkflowBatchResults(batchDirectory, workflowResults)); createReport(workflowResults, entries, tenantId, requestId); return workflowResults.stream() .map(w -> buildItemStatus(PLUGIN_NAME, w.getGlobalStatus(), EventDetails.of(String.format("%s executed", PLUGIN_NAME)))) .collect(Collectors.toList()); } catch (Exception e) { tryDeleteLocalPreservationFiles(Paths.get(griffinInputFolder, griffinId, batchId)); throw new ProcessingException(e); } } PreservationActionPlugin(); @VisibleForTesting  PreservationActionPlugin(StorageClientFactory storage, PreservationReportService report, String inputFolder,
        String execFolder); @Override List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler); }
PreservationActionPlugin extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { List<PreservationDistributionLine> entries = IntStream.range(0, workerParameters.getObjectNameList().size()) .mapToObj(index -> mapToParamsPreservationDistributionFile(workerParameters, index)) .collect(Collectors.toList()); String griffinId = entries.get(0).getGriffinId(); String batchId = GUIDFactory.newGUID().getId(); try { Path batchDirectory = createBatchDirectory(griffinId, batchId); copyInputFiles(batchDirectory, entries); String requestId = workerParameters.getRequestId(); Integer tenantId = VitamThreadUtils.getVitamSession().getTenantId(); createParametersBatchFile(entries, batchDirectory, requestId, batchId); int timeout = entries.get(0).getTimeout(); ResultPreservation result = launchGriffin(griffinId, batchDirectory, timeout); List<WorkflowBatchResult> workflowResults = generateWorkflowBatchResults(result, entries); handler.setCurrentObjectId(WorkflowBatchResults.NAME); handler.addOutputResult(0, new WorkflowBatchResults(batchDirectory, workflowResults)); createReport(workflowResults, entries, tenantId, requestId); return workflowResults.stream() .map(w -> buildItemStatus(PLUGIN_NAME, w.getGlobalStatus(), EventDetails.of(String.format("%s executed", PLUGIN_NAME)))) .collect(Collectors.toList()); } catch (Exception e) { tryDeleteLocalPreservationFiles(Paths.get(griffinInputFolder, griffinId, batchId)); throw new ProcessingException(e); } } PreservationActionPlugin(); @VisibleForTesting  PreservationActionPlugin(StorageClientFactory storage, PreservationReportService report, String inputFolder,
        String execFolder); @Override List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler);  }