@Test public void formatIdentificationWarning() throws Exception { when(formatIdentifier.analysePath(any())).thenReturn(getFormatIdentifierResponseList()); handlerIO.getInput().clear(); handlerIO.getInput().add(og); handlerIO.getInput().add(PropertiesUtils.getResourceFile(REFERENTIAL_INGEST_CONTRACT_DEFAULT_CONFIG)); when(adminManagementClient.getFormats(any())).thenReturn(getAdminManagementJson()); plugin = new FormatIdentificationActionPlugin(adminManagementClientFactory, formatIdentifierFactory); final WorkerParameters params = getDefaultWorkerParameters(); final ItemStatus response = plugin.execute(params, handlerIO); assertEquals(StatusCode.WARNING, response.getGlobalStatus()); assertFalse(response.getItemsStatus().get(FormatIdentificationActionPlugin.FILE_FORMAT) .getEvDetailData().isEmpty()); LinkedHashMap<String, ItemStatus> subTaskStatusMap = response.getItemsStatus().get(FormatIdentificationActionPlugin.FILE_FORMAT).getSubTaskStatus(); assertFalse(subTaskStatusMap.isEmpty()); List<ItemStatus> subTaskWithWarningStatusList = subTaskStatusMap.values().stream().filter(item -> item.getGlobalStatus().equals(StatusCode.WARNING)) .collect( Collectors.toList()); assertThat(subTaskWithWarningStatusList).hasSize(3); subTaskWithWarningStatusList.forEach(objectItem -> { objectItem.getEvDetailData().contains("+ PUID : fmt/293"); }); }
@Override public ItemStatus execute(WorkerParameters params, HandlerIO handlerIO) { checkMandatoryParameters(params); LOGGER.debug("FormatIdentificationActionHandler running ..."); final ItemStatus itemStatus = new ItemStatus(FILE_FORMAT); FormatIdentifier formatIdentifier; try { formatIdentifier = formatIdentifierFactory.getFormatIdentifierFor(FORMAT_IDENTIFIER_ID); } catch (final FormatIdentifierNotFoundException e) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.WORKER_FORMAT_IDENTIFIER_NOT_FOUND, FORMAT_IDENTIFIER_ID), e); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } catch (final FormatIdentifierFactoryException e) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.WORKER_FORMAT_IDENTIFIER_IMPLEMENTATION_NOT_FOUND, FORMAT_IDENTIFIER_ID), e); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } catch (final FormatIdentifierTechnicalException e) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.WORKER_FORMAT_IDENTIFIER_TECHNICAL_INTERNAL_ERROR), e); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } try { final JsonNode jsonOG = (JsonNode) handlerIO.getInput(OG_INPUT_RANK); boolean metadataUpdated = false; final Map<String, String> objectIdToUri = getMapOfObjectsIdsAndUris(jsonOG); final JsonNode qualifiers = jsonOG.get(SedaConstants.PREFIX_QUALIFIERS); if (qualifiers != null) { final List<JsonNode> versions = qualifiers.findValues(SedaConstants.TAG_VERSIONS); if (versions != null && !versions.isEmpty()) { for (final JsonNode versionsArray : versions) { for (final JsonNode version : versionsArray) { if (version.get(SedaConstants.TAG_PHYSICAL_ID) == null) { File file = null; try { final JsonNode jsonFormatIdentifier = version.get(SedaConstants.TAG_FORMAT_IDENTIFICATION); final String objectId = version.get(SedaConstants.PREFIX_ID).asText(); file = loadFileFromWorkspace(handlerIO, objectIdToUri.get(objectId)); final ObjectCheckFormatResult result = executeOneObjectFromOG(handlerIO, formatIdentifier, objectId, jsonFormatIdentifier, file, version); if(result.getMetadataUpdated()) { metadataUpdated = true; } ItemStatus subTaskItemStatus = new ItemStatus(FILE_FORMAT); subTaskItemStatus.increment(result.getStatus()); itemStatus.increment(result.getStatus()); if (result.getStatus().equals(StatusCode.KO)) { switch (result.getSubStatus()) { case FILE_FORMAT_NOT_FOUND: subTaskItemStatus.setGlobalOutcomeDetailSubcode(SUBSTATUS_UNKNOWN); break; case FILE_FORMAT_NOT_FOUND_REFERENTIAL_ERROR: case FILE_FORMAT_PUID_NOT_FOUND: subTaskItemStatus.setGlobalOutcomeDetailSubcode(SUBSTATUS_UNCHARTED); break; case FILE_FORMAT_REJECTED: subTaskItemStatus.setGlobalOutcomeDetailSubcode(SUBSTATUS_REJECTED); itemStatus.setGlobalOutcomeDetailSubcode(FILE_FORMAT_REJECTED); break; } LOGGER.error(JsonHandler.unprettyPrint(result)); } itemStatus.setSubTaskStatus(objectId, subTaskItemStatus); if (result.getEventDetailData() != null) { itemStatus.getSubTaskStatus().get(objectId).setEvDetailData(result.getEventDetailData()); } if (StatusCode.FATAL.equals(itemStatus.getGlobalStatus())) { return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } } finally { if (file != null) { try { Files.delete(file.toPath()); } catch (IOException e) { LOGGER.error(e); } } } } } } } } if (metadataUpdated) { handlerIO.transferJsonToWorkspace(IngestWorkflowConstants.OBJECT_GROUP_FOLDER, params.getObjectName(), jsonOG, false, false); } } catch (final ProcessingException e) { LOGGER.error(e); itemStatus.increment(StatusCode.FATAL); } if (itemStatus.getGlobalStatus().getStatusLevel() == StatusCode.UNKNOWN.getStatusLevel()) { itemStatus.increment(StatusCode.OK); } LOGGER.debug("FormatIdentificationActionHandler response: " + itemStatus.getGlobalStatus()); return new ItemStatus(FILE_FORMAT).setItemsStatus(itemStatus.getItemId(), itemStatus); }
FormatIdentificationActionPlugin extends ActionHandler implements VitamAutoCloseable { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handlerIO) { checkMandatoryParameters(params); LOGGER.debug("FormatIdentificationActionHandler running ..."); final ItemStatus itemStatus = new ItemStatus(FILE_FORMAT); FormatIdentifier formatIdentifier; try { formatIdentifier = formatIdentifierFactory.getFormatIdentifierFor(FORMAT_IDENTIFIER_ID); } catch (final FormatIdentifierNotFoundException e) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.WORKER_FORMAT_IDENTIFIER_NOT_FOUND, FORMAT_IDENTIFIER_ID), e); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } catch (final FormatIdentifierFactoryException e) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.WORKER_FORMAT_IDENTIFIER_IMPLEMENTATION_NOT_FOUND, FORMAT_IDENTIFIER_ID), e); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } catch (final FormatIdentifierTechnicalException e) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.WORKER_FORMAT_IDENTIFIER_TECHNICAL_INTERNAL_ERROR), e); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } try { final JsonNode jsonOG = (JsonNode) handlerIO.getInput(OG_INPUT_RANK); boolean metadataUpdated = false; final Map<String, String> objectIdToUri = getMapOfObjectsIdsAndUris(jsonOG); final JsonNode qualifiers = jsonOG.get(SedaConstants.PREFIX_QUALIFIERS); if (qualifiers != null) { final List<JsonNode> versions = qualifiers.findValues(SedaConstants.TAG_VERSIONS); if (versions != null && !versions.isEmpty()) { for (final JsonNode versionsArray : versions) { for (final JsonNode version : versionsArray) { if (version.get(SedaConstants.TAG_PHYSICAL_ID) == null) { File file = null; try { final JsonNode jsonFormatIdentifier = version.get(SedaConstants.TAG_FORMAT_IDENTIFICATION); final String objectId = version.get(SedaConstants.PREFIX_ID).asText(); file = loadFileFromWorkspace(handlerIO, objectIdToUri.get(objectId)); final ObjectCheckFormatResult result = executeOneObjectFromOG(handlerIO, formatIdentifier, objectId, jsonFormatIdentifier, file, version); if(result.getMetadataUpdated()) { metadataUpdated = true; } ItemStatus subTaskItemStatus = new ItemStatus(FILE_FORMAT); subTaskItemStatus.increment(result.getStatus()); itemStatus.increment(result.getStatus()); if (result.getStatus().equals(StatusCode.KO)) { switch (result.getSubStatus()) { case FILE_FORMAT_NOT_FOUND: subTaskItemStatus.setGlobalOutcomeDetailSubcode(SUBSTATUS_UNKNOWN); break; case FILE_FORMAT_NOT_FOUND_REFERENTIAL_ERROR: case FILE_FORMAT_PUID_NOT_FOUND: subTaskItemStatus.setGlobalOutcomeDetailSubcode(SUBSTATUS_UNCHARTED); break; case FILE_FORMAT_REJECTED: subTaskItemStatus.setGlobalOutcomeDetailSubcode(SUBSTATUS_REJECTED); itemStatus.setGlobalOutcomeDetailSubcode(FILE_FORMAT_REJECTED); break; } LOGGER.error(JsonHandler.unprettyPrint(result)); } itemStatus.setSubTaskStatus(objectId, subTaskItemStatus); if (result.getEventDetailData() != null) { itemStatus.getSubTaskStatus().get(objectId).setEvDetailData(result.getEventDetailData()); } if (StatusCode.FATAL.equals(itemStatus.getGlobalStatus())) { return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } } finally { if (file != null) { try { Files.delete(file.toPath()); } catch (IOException e) { LOGGER.error(e); } } } } } } } } if (metadataUpdated) { handlerIO.transferJsonToWorkspace(IngestWorkflowConstants.OBJECT_GROUP_FOLDER, params.getObjectName(), jsonOG, false, false); } } catch (final ProcessingException e) { LOGGER.error(e); itemStatus.increment(StatusCode.FATAL); } if (itemStatus.getGlobalStatus().getStatusLevel() == StatusCode.UNKNOWN.getStatusLevel()) { itemStatus.increment(StatusCode.OK); } LOGGER.debug("FormatIdentificationActionHandler response: " + itemStatus.getGlobalStatus()); return new ItemStatus(FILE_FORMAT).setItemsStatus(itemStatus.getItemId(), itemStatus); } }
FormatIdentificationActionPlugin extends ActionHandler implements VitamAutoCloseable { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handlerIO) { checkMandatoryParameters(params); LOGGER.debug("FormatIdentificationActionHandler running ..."); final ItemStatus itemStatus = new ItemStatus(FILE_FORMAT); FormatIdentifier formatIdentifier; try { formatIdentifier = formatIdentifierFactory.getFormatIdentifierFor(FORMAT_IDENTIFIER_ID); } catch (final FormatIdentifierNotFoundException e) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.WORKER_FORMAT_IDENTIFIER_NOT_FOUND, FORMAT_IDENTIFIER_ID), e); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } catch (final FormatIdentifierFactoryException e) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.WORKER_FORMAT_IDENTIFIER_IMPLEMENTATION_NOT_FOUND, FORMAT_IDENTIFIER_ID), e); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } catch (final FormatIdentifierTechnicalException e) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.WORKER_FORMAT_IDENTIFIER_TECHNICAL_INTERNAL_ERROR), e); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } try { final JsonNode jsonOG = (JsonNode) handlerIO.getInput(OG_INPUT_RANK); boolean metadataUpdated = false; final Map<String, String> objectIdToUri = getMapOfObjectsIdsAndUris(jsonOG); final JsonNode qualifiers = jsonOG.get(SedaConstants.PREFIX_QUALIFIERS); if (qualifiers != null) { final List<JsonNode> versions = qualifiers.findValues(SedaConstants.TAG_VERSIONS); if (versions != null && !versions.isEmpty()) { for (final JsonNode versionsArray : versions) { for (final JsonNode version : versionsArray) { if (version.get(SedaConstants.TAG_PHYSICAL_ID) == null) { File file = null; try { final JsonNode jsonFormatIdentifier = version.get(SedaConstants.TAG_FORMAT_IDENTIFICATION); final String objectId = version.get(SedaConstants.PREFIX_ID).asText(); file = loadFileFromWorkspace(handlerIO, objectIdToUri.get(objectId)); final ObjectCheckFormatResult result = executeOneObjectFromOG(handlerIO, formatIdentifier, objectId, jsonFormatIdentifier, file, version); if(result.getMetadataUpdated()) { metadataUpdated = true; } ItemStatus subTaskItemStatus = new ItemStatus(FILE_FORMAT); subTaskItemStatus.increment(result.getStatus()); itemStatus.increment(result.getStatus()); if (result.getStatus().equals(StatusCode.KO)) { switch (result.getSubStatus()) { case FILE_FORMAT_NOT_FOUND: subTaskItemStatus.setGlobalOutcomeDetailSubcode(SUBSTATUS_UNKNOWN); break; case FILE_FORMAT_NOT_FOUND_REFERENTIAL_ERROR: case FILE_FORMAT_PUID_NOT_FOUND: subTaskItemStatus.setGlobalOutcomeDetailSubcode(SUBSTATUS_UNCHARTED); break; case FILE_FORMAT_REJECTED: subTaskItemStatus.setGlobalOutcomeDetailSubcode(SUBSTATUS_REJECTED); itemStatus.setGlobalOutcomeDetailSubcode(FILE_FORMAT_REJECTED); break; } LOGGER.error(JsonHandler.unprettyPrint(result)); } itemStatus.setSubTaskStatus(objectId, subTaskItemStatus); if (result.getEventDetailData() != null) { itemStatus.getSubTaskStatus().get(objectId).setEvDetailData(result.getEventDetailData()); } if (StatusCode.FATAL.equals(itemStatus.getGlobalStatus())) { return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } } finally { if (file != null) { try { Files.delete(file.toPath()); } catch (IOException e) { LOGGER.error(e); } } } } } } } } if (metadataUpdated) { handlerIO.transferJsonToWorkspace(IngestWorkflowConstants.OBJECT_GROUP_FOLDER, params.getObjectName(), jsonOG, false, false); } } catch (final ProcessingException e) { LOGGER.error(e); itemStatus.increment(StatusCode.FATAL); } if (itemStatus.getGlobalStatus().getStatusLevel() == StatusCode.UNKNOWN.getStatusLevel()) { itemStatus.increment(StatusCode.OK); } LOGGER.debug("FormatIdentificationActionHandler response: " + itemStatus.getGlobalStatus()); return new ItemStatus(FILE_FORMAT).setItemsStatus(itemStatus.getItemId(), itemStatus); } FormatIdentificationActionPlugin(); @VisibleForTesting  FormatIdentificationActionPlugin(
        AdminManagementClientFactory adminManagementClientFactory,
        FormatIdentifierFactory formatIdentifierFactory); }
FormatIdentificationActionPlugin extends ActionHandler implements VitamAutoCloseable { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handlerIO) { checkMandatoryParameters(params); LOGGER.debug("FormatIdentificationActionHandler running ..."); final ItemStatus itemStatus = new ItemStatus(FILE_FORMAT); FormatIdentifier formatIdentifier; try { formatIdentifier = formatIdentifierFactory.getFormatIdentifierFor(FORMAT_IDENTIFIER_ID); } catch (final FormatIdentifierNotFoundException e) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.WORKER_FORMAT_IDENTIFIER_NOT_FOUND, FORMAT_IDENTIFIER_ID), e); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } catch (final FormatIdentifierFactoryException e) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.WORKER_FORMAT_IDENTIFIER_IMPLEMENTATION_NOT_FOUND, FORMAT_IDENTIFIER_ID), e); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } catch (final FormatIdentifierTechnicalException e) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.WORKER_FORMAT_IDENTIFIER_TECHNICAL_INTERNAL_ERROR), e); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } try { final JsonNode jsonOG = (JsonNode) handlerIO.getInput(OG_INPUT_RANK); boolean metadataUpdated = false; final Map<String, String> objectIdToUri = getMapOfObjectsIdsAndUris(jsonOG); final JsonNode qualifiers = jsonOG.get(SedaConstants.PREFIX_QUALIFIERS); if (qualifiers != null) { final List<JsonNode> versions = qualifiers.findValues(SedaConstants.TAG_VERSIONS); if (versions != null && !versions.isEmpty()) { for (final JsonNode versionsArray : versions) { for (final JsonNode version : versionsArray) { if (version.get(SedaConstants.TAG_PHYSICAL_ID) == null) { File file = null; try { final JsonNode jsonFormatIdentifier = version.get(SedaConstants.TAG_FORMAT_IDENTIFICATION); final String objectId = version.get(SedaConstants.PREFIX_ID).asText(); file = loadFileFromWorkspace(handlerIO, objectIdToUri.get(objectId)); final ObjectCheckFormatResult result = executeOneObjectFromOG(handlerIO, formatIdentifier, objectId, jsonFormatIdentifier, file, version); if(result.getMetadataUpdated()) { metadataUpdated = true; } ItemStatus subTaskItemStatus = new ItemStatus(FILE_FORMAT); subTaskItemStatus.increment(result.getStatus()); itemStatus.increment(result.getStatus()); if (result.getStatus().equals(StatusCode.KO)) { switch (result.getSubStatus()) { case FILE_FORMAT_NOT_FOUND: subTaskItemStatus.setGlobalOutcomeDetailSubcode(SUBSTATUS_UNKNOWN); break; case FILE_FORMAT_NOT_FOUND_REFERENTIAL_ERROR: case FILE_FORMAT_PUID_NOT_FOUND: subTaskItemStatus.setGlobalOutcomeDetailSubcode(SUBSTATUS_UNCHARTED); break; case FILE_FORMAT_REJECTED: subTaskItemStatus.setGlobalOutcomeDetailSubcode(SUBSTATUS_REJECTED); itemStatus.setGlobalOutcomeDetailSubcode(FILE_FORMAT_REJECTED); break; } LOGGER.error(JsonHandler.unprettyPrint(result)); } itemStatus.setSubTaskStatus(objectId, subTaskItemStatus); if (result.getEventDetailData() != null) { itemStatus.getSubTaskStatus().get(objectId).setEvDetailData(result.getEventDetailData()); } if (StatusCode.FATAL.equals(itemStatus.getGlobalStatus())) { return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } } finally { if (file != null) { try { Files.delete(file.toPath()); } catch (IOException e) { LOGGER.error(e); } } } } } } } } if (metadataUpdated) { handlerIO.transferJsonToWorkspace(IngestWorkflowConstants.OBJECT_GROUP_FOLDER, params.getObjectName(), jsonOG, false, false); } } catch (final ProcessingException e) { LOGGER.error(e); itemStatus.increment(StatusCode.FATAL); } if (itemStatus.getGlobalStatus().getStatusLevel() == StatusCode.UNKNOWN.getStatusLevel()) { itemStatus.increment(StatusCode.OK); } LOGGER.debug("FormatIdentificationActionHandler response: " + itemStatus.getGlobalStatus()); return new ItemStatus(FILE_FORMAT).setItemsStatus(itemStatus.getItemId(), itemStatus); } FormatIdentificationActionPlugin(); @VisibleForTesting  FormatIdentificationActionPlugin(
        AdminManagementClientFactory adminManagementClientFactory,
        FormatIdentifierFactory formatIdentifierFactory); @Override ItemStatus execute(WorkerParameters params, HandlerIO handlerIO); @Override void checkMandatoryIOParameter(HandlerIO handler); }
FormatIdentificationActionPlugin extends ActionHandler implements VitamAutoCloseable { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handlerIO) { checkMandatoryParameters(params); LOGGER.debug("FormatIdentificationActionHandler running ..."); final ItemStatus itemStatus = new ItemStatus(FILE_FORMAT); FormatIdentifier formatIdentifier; try { formatIdentifier = formatIdentifierFactory.getFormatIdentifierFor(FORMAT_IDENTIFIER_ID); } catch (final FormatIdentifierNotFoundException e) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.WORKER_FORMAT_IDENTIFIER_NOT_FOUND, FORMAT_IDENTIFIER_ID), e); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } catch (final FormatIdentifierFactoryException e) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.WORKER_FORMAT_IDENTIFIER_IMPLEMENTATION_NOT_FOUND, FORMAT_IDENTIFIER_ID), e); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } catch (final FormatIdentifierTechnicalException e) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.WORKER_FORMAT_IDENTIFIER_TECHNICAL_INTERNAL_ERROR), e); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } try { final JsonNode jsonOG = (JsonNode) handlerIO.getInput(OG_INPUT_RANK); boolean metadataUpdated = false; final Map<String, String> objectIdToUri = getMapOfObjectsIdsAndUris(jsonOG); final JsonNode qualifiers = jsonOG.get(SedaConstants.PREFIX_QUALIFIERS); if (qualifiers != null) { final List<JsonNode> versions = qualifiers.findValues(SedaConstants.TAG_VERSIONS); if (versions != null && !versions.isEmpty()) { for (final JsonNode versionsArray : versions) { for (final JsonNode version : versionsArray) { if (version.get(SedaConstants.TAG_PHYSICAL_ID) == null) { File file = null; try { final JsonNode jsonFormatIdentifier = version.get(SedaConstants.TAG_FORMAT_IDENTIFICATION); final String objectId = version.get(SedaConstants.PREFIX_ID).asText(); file = loadFileFromWorkspace(handlerIO, objectIdToUri.get(objectId)); final ObjectCheckFormatResult result = executeOneObjectFromOG(handlerIO, formatIdentifier, objectId, jsonFormatIdentifier, file, version); if(result.getMetadataUpdated()) { metadataUpdated = true; } ItemStatus subTaskItemStatus = new ItemStatus(FILE_FORMAT); subTaskItemStatus.increment(result.getStatus()); itemStatus.increment(result.getStatus()); if (result.getStatus().equals(StatusCode.KO)) { switch (result.getSubStatus()) { case FILE_FORMAT_NOT_FOUND: subTaskItemStatus.setGlobalOutcomeDetailSubcode(SUBSTATUS_UNKNOWN); break; case FILE_FORMAT_NOT_FOUND_REFERENTIAL_ERROR: case FILE_FORMAT_PUID_NOT_FOUND: subTaskItemStatus.setGlobalOutcomeDetailSubcode(SUBSTATUS_UNCHARTED); break; case FILE_FORMAT_REJECTED: subTaskItemStatus.setGlobalOutcomeDetailSubcode(SUBSTATUS_REJECTED); itemStatus.setGlobalOutcomeDetailSubcode(FILE_FORMAT_REJECTED); break; } LOGGER.error(JsonHandler.unprettyPrint(result)); } itemStatus.setSubTaskStatus(objectId, subTaskItemStatus); if (result.getEventDetailData() != null) { itemStatus.getSubTaskStatus().get(objectId).setEvDetailData(result.getEventDetailData()); } if (StatusCode.FATAL.equals(itemStatus.getGlobalStatus())) { return new ItemStatus(FILE_FORMAT).setItemsStatus(FILE_FORMAT, itemStatus); } } finally { if (file != null) { try { Files.delete(file.toPath()); } catch (IOException e) { LOGGER.error(e); } } } } } } } } if (metadataUpdated) { handlerIO.transferJsonToWorkspace(IngestWorkflowConstants.OBJECT_GROUP_FOLDER, params.getObjectName(), jsonOG, false, false); } } catch (final ProcessingException e) { LOGGER.error(e); itemStatus.increment(StatusCode.FATAL); } if (itemStatus.getGlobalStatus().getStatusLevel() == StatusCode.UNKNOWN.getStatusLevel()) { itemStatus.increment(StatusCode.OK); } LOGGER.debug("FormatIdentificationActionHandler response: " + itemStatus.getGlobalStatus()); return new ItemStatus(FILE_FORMAT).setItemsStatus(itemStatus.getItemId(), itemStatus); } FormatIdentificationActionPlugin(); @VisibleForTesting  FormatIdentificationActionPlugin(
        AdminManagementClientFactory adminManagementClientFactory,
        FormatIdentifierFactory formatIdentifierFactory); @Override ItemStatus execute(WorkerParameters params, HandlerIO handlerIO); @Override void checkMandatoryIOParameter(HandlerIO handler); static final String FILE_FORMAT; static final String PUID; }