@Test public void should_disable_lfc_when_not_GENERATE_action() throws Exception { OutputPreservation output = new OutputPreservation(); output.setStatus(PreservationStatus.OK); output.setAction(ActionTypePreservation.ANALYSE); List<OutputExtra> outputExtras = Collections.singletonList(OutputExtra.of(output)); WorkflowBatchResult batchResult = WorkflowBatchResult.of("", "", "", "", outputExtras, "", ""); List<WorkflowBatchResult> workflowBatchResults = Collections.singletonList(batchResult); WorkflowBatchResults batchResults = new WorkflowBatchResults(Paths.get("tmp"), workflowBatchResults); handler.addOutputResult(0, batchResults); List<ItemStatus> itemStatuses = securityChecksPlugin.executeList(null, handler); assertThat(itemStatuses).extracting(ItemStatus::isLifecycleEnable).containsOnly(false); }
@Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { logger.debug("Starting {}.", ITEM_ID); handler.setCurrentObjectId(WorkflowBatchResults.NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(0); List<ItemStatus> itemStatuses = new ArrayList<>(); List<WorkflowBatchResult> workflowBatchResults = new ArrayList<>(); for (WorkflowBatchResult workflowBatchResult : results.getWorkflowBatchResults()) { List<OutputExtra> outputExtras = workflowBatchResult.getOutputExtras() .stream() .filter(OutputExtra::isOkAndExtracted) .map(this::checkMetadataAndAddExtractedMetadata) .collect(Collectors.toList()); if (outputExtras.isEmpty()) { workflowBatchResults.add(workflowBatchResult); ItemStatus itemStatus = new ItemStatus(ITEM_ID); itemStatus.disableLfc(); itemStatuses.add(itemStatus); continue; } itemStatuses.add(getItemStatus(outputExtras)); workflowBatchResults.add(WorkflowBatchResult.of(workflowBatchResult, getOutputExtrasWithoutErrors(workflowBatchResult, outputExtras))); } handler.addOutputResult(0, new WorkflowBatchResults(results.getBatchDirectory(), workflowBatchResults)); return itemStatuses; }
PreservationMetadataSecurityChecks extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { logger.debug("Starting {}.", ITEM_ID); handler.setCurrentObjectId(WorkflowBatchResults.NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(0); List<ItemStatus> itemStatuses = new ArrayList<>(); List<WorkflowBatchResult> workflowBatchResults = new ArrayList<>(); for (WorkflowBatchResult workflowBatchResult : results.getWorkflowBatchResults()) { List<OutputExtra> outputExtras = workflowBatchResult.getOutputExtras() .stream() .filter(OutputExtra::isOkAndExtracted) .map(this::checkMetadataAndAddExtractedMetadata) .collect(Collectors.toList()); if (outputExtras.isEmpty()) { workflowBatchResults.add(workflowBatchResult); ItemStatus itemStatus = new ItemStatus(ITEM_ID); itemStatus.disableLfc(); itemStatuses.add(itemStatus); continue; } itemStatuses.add(getItemStatus(outputExtras)); workflowBatchResults.add(WorkflowBatchResult.of(workflowBatchResult, getOutputExtrasWithoutErrors(workflowBatchResult, outputExtras))); } handler.addOutputResult(0, new WorkflowBatchResults(results.getBatchDirectory(), workflowBatchResults)); return itemStatuses; } }
PreservationMetadataSecurityChecks extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { logger.debug("Starting {}.", ITEM_ID); handler.setCurrentObjectId(WorkflowBatchResults.NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(0); List<ItemStatus> itemStatuses = new ArrayList<>(); List<WorkflowBatchResult> workflowBatchResults = new ArrayList<>(); for (WorkflowBatchResult workflowBatchResult : results.getWorkflowBatchResults()) { List<OutputExtra> outputExtras = workflowBatchResult.getOutputExtras() .stream() .filter(OutputExtra::isOkAndExtracted) .map(this::checkMetadataAndAddExtractedMetadata) .collect(Collectors.toList()); if (outputExtras.isEmpty()) { workflowBatchResults.add(workflowBatchResult); ItemStatus itemStatus = new ItemStatus(ITEM_ID); itemStatus.disableLfc(); itemStatuses.add(itemStatus); continue; } itemStatuses.add(getItemStatus(outputExtras)); workflowBatchResults.add(WorkflowBatchResult.of(workflowBatchResult, getOutputExtrasWithoutErrors(workflowBatchResult, outputExtras))); } handler.addOutputResult(0, new WorkflowBatchResults(results.getBatchDirectory(), workflowBatchResults)); return itemStatuses; }  }
PreservationMetadataSecurityChecks extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { logger.debug("Starting {}.", ITEM_ID); handler.setCurrentObjectId(WorkflowBatchResults.NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(0); List<ItemStatus> itemStatuses = new ArrayList<>(); List<WorkflowBatchResult> workflowBatchResults = new ArrayList<>(); for (WorkflowBatchResult workflowBatchResult : results.getWorkflowBatchResults()) { List<OutputExtra> outputExtras = workflowBatchResult.getOutputExtras() .stream() .filter(OutputExtra::isOkAndExtracted) .map(this::checkMetadataAndAddExtractedMetadata) .collect(Collectors.toList()); if (outputExtras.isEmpty()) { workflowBatchResults.add(workflowBatchResult); ItemStatus itemStatus = new ItemStatus(ITEM_ID); itemStatus.disableLfc(); itemStatuses.add(itemStatus); continue; } itemStatuses.add(getItemStatus(outputExtras)); workflowBatchResults.add(WorkflowBatchResult.of(workflowBatchResult, getOutputExtrasWithoutErrors(workflowBatchResult, outputExtras))); } handler.addOutputResult(0, new WorkflowBatchResults(results.getBatchDirectory(), workflowBatchResults)); return itemStatuses; }  @Override List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler); }
PreservationMetadataSecurityChecks extends ActionHandler { @Override public List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler) throws ProcessingException { logger.debug("Starting {}.", ITEM_ID); handler.setCurrentObjectId(WorkflowBatchResults.NAME); WorkflowBatchResults results = (WorkflowBatchResults) handler.getInput(0); List<ItemStatus> itemStatuses = new ArrayList<>(); List<WorkflowBatchResult> workflowBatchResults = new ArrayList<>(); for (WorkflowBatchResult workflowBatchResult : results.getWorkflowBatchResults()) { List<OutputExtra> outputExtras = workflowBatchResult.getOutputExtras() .stream() .filter(OutputExtra::isOkAndExtracted) .map(this::checkMetadataAndAddExtractedMetadata) .collect(Collectors.toList()); if (outputExtras.isEmpty()) { workflowBatchResults.add(workflowBatchResult); ItemStatus itemStatus = new ItemStatus(ITEM_ID); itemStatus.disableLfc(); itemStatuses.add(itemStatus); continue; } itemStatuses.add(getItemStatus(outputExtras)); workflowBatchResults.add(WorkflowBatchResult.of(workflowBatchResult, getOutputExtrasWithoutErrors(workflowBatchResult, outputExtras))); } handler.addOutputResult(0, new WorkflowBatchResults(results.getBatchDirectory(), workflowBatchResults)); return itemStatuses; }  @Override List<ItemStatus> executeList(WorkerParameters workerParameters, HandlerIO handler); static final String ITEM_ID; }