@Test public void should_check_extracted_metadata_and_fill_output_extra_WARNING() throws Exception { OutputPreservation output = getOutputPreservationExtracted("<!doctype html><html lang=\"en\"><head> <meta charset=\"utf-8\"> <title>The HTML5 Herald</title> <meta name=\"description\" content=\"The HTML5 example\"> <meta name=\"author\" content=\"yeah\"> <link rel=\"stylesheet\" href=\"css/styles.css?v=1.0\"></head><body> <script src=\"js/scripts.js\"></script></body></html>"); OutputPreservation output2 = getOutputPreservationExtracted("yeah"); List<OutputExtra> outputExtras = Arrays.asList(OutputExtra.of(output), OutputExtra.of(output2)); 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::getGlobalStatus).containsOnly(WARNING); }
@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; }