@Test public void checkInvalidDigestMessage() throws Exception { InputStream objectGroupInvalideDigest = PropertiesUtils.getResourceAsStream(OBJECT_GROUP_DIGEST_INVALID); when(workspaceClient.getObject(any(), eq("ObjectGroup/objectName3"))) .thenReturn(Response.status(Status.OK).entity(objectGroupInvalideDigest).build()); when(workspaceClient.getObject(any(), eq("SIP/Content/5zC1uD6CvaYDipUhETOyUWVEbxHmE1.pdf"))) .thenReturn(Response.status(Status.OK).entity(PropertiesUtils .getResourceAsStream("checkConformityActionPlugin/binaryObject/5zC1uD6CvaYDipUhETOyUWVEbxHmE1.pdf")) .build()); CheckConformityActionPlugin plugin = new CheckConformityActionPlugin(); final WorkerParameters params = getDefaultWorkerParameters(); params.setObjectName("objectName3"); String objectId = "objectId"; final HandlerIOImpl handlerIO = new HandlerIOImpl(workspaceClientFactory, logbookLifeCyclesClientFactory, "CheckConformityActionHandlerTest", "workerId", Lists.newArrayList(objectId)); handlerIO.setCurrentObjectId(objectId); final List<IOParameter> out = new ArrayList<>(); out.add(new IOParameter().setUri(new ProcessingUri(UriPrefix.MEMORY, "objectGroupId.json"))); final List<IOParameter> in = new ArrayList<>(); in.add(new IOParameter().setUri(new ProcessingUri(UriPrefix.VALUE, "SHA-512"))); handlerIO.addInIOParameters(in); handlerIO.addOutIOParameters(out); final ItemStatus response = plugin.execute(params, handlerIO); assertEquals(StatusCode.KO, response.getGlobalStatus()); LinkedHashMap<String, ItemStatus> subTasks = response.getItemsStatus().get(CALC_CHECK).getSubTaskStatus(); assertEquals(1, subTasks.size()); ItemStatus subtask = subTasks.entrySet().iterator().next().getValue(); assertEquals("INVALID", subtask.getGlobalOutcomeDetailSubcode()); handlerIO.close(); }
@Override public ItemStatus execute(WorkerParameters params, HandlerIO handlerIO) throws ProcessingException { checkMandatoryParameters(params); LOGGER.debug("CheckConformityActionHandler running ..."); final ItemStatus itemStatus = new ItemStatus(CALC_CHECK); try { final JsonNode jsonOG = handlerIO.getJsonFromWorkspace( IngestWorkflowConstants.OBJECT_GROUP_FOLDER + "/" + params.getObjectName()); handlerIO.addOutputResult(OG_OUT_RANK, jsonOG, true, false); final Map<String, DataObjectInfo> binaryObjects = getBinaryObjects(jsonOG); boolean oneOrMoreMessagesDigestUpdated = false; 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) { final String objectId = version.get(SedaConstants.PREFIX_ID).asText(); boolean messagesDigestUpdated = checkMessageDigest(binaryObjects.get(objectId), version, itemStatus, handlerIO); if(messagesDigestUpdated) { oneOrMoreMessagesDigestUpdated = true; } } } } } } if (oneOrMoreMessagesDigestUpdated) { handlerIO.transferJsonToWorkspace(IngestWorkflowConstants.OBJECT_GROUP_FOLDER, params.getObjectName(), jsonOG, false, false); } } catch (VitamMissingBinaryObjectSizeException e) { LOGGER.error(e); itemStatus.increment(StatusCode.KO); itemStatus.setGlobalOutcomeDetailSubcode("CHECK_OBJECT_SIZE"); } catch (ProcessingException e) { LOGGER.error(e); itemStatus.increment(StatusCode.FATAL); } if (itemStatus.getGlobalStatus().getStatusLevel() == StatusCode.UNKNOWN.getStatusLevel()) { itemStatus.increment(StatusCode.OK); } LOGGER.debug("CheckConformityActionHandler response: " + itemStatus.getGlobalStatus()); return new ItemStatus(CALC_CHECK).setItemsStatus(CALC_CHECK, itemStatus); }
CheckConformityActionPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handlerIO) throws ProcessingException { checkMandatoryParameters(params); LOGGER.debug("CheckConformityActionHandler running ..."); final ItemStatus itemStatus = new ItemStatus(CALC_CHECK); try { final JsonNode jsonOG = handlerIO.getJsonFromWorkspace( IngestWorkflowConstants.OBJECT_GROUP_FOLDER + "/" + params.getObjectName()); handlerIO.addOutputResult(OG_OUT_RANK, jsonOG, true, false); final Map<String, DataObjectInfo> binaryObjects = getBinaryObjects(jsonOG); boolean oneOrMoreMessagesDigestUpdated = false; 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) { final String objectId = version.get(SedaConstants.PREFIX_ID).asText(); boolean messagesDigestUpdated = checkMessageDigest(binaryObjects.get(objectId), version, itemStatus, handlerIO); if(messagesDigestUpdated) { oneOrMoreMessagesDigestUpdated = true; } } } } } } if (oneOrMoreMessagesDigestUpdated) { handlerIO.transferJsonToWorkspace(IngestWorkflowConstants.OBJECT_GROUP_FOLDER, params.getObjectName(), jsonOG, false, false); } } catch (VitamMissingBinaryObjectSizeException e) { LOGGER.error(e); itemStatus.increment(StatusCode.KO); itemStatus.setGlobalOutcomeDetailSubcode("CHECK_OBJECT_SIZE"); } catch (ProcessingException e) { LOGGER.error(e); itemStatus.increment(StatusCode.FATAL); } if (itemStatus.getGlobalStatus().getStatusLevel() == StatusCode.UNKNOWN.getStatusLevel()) { itemStatus.increment(StatusCode.OK); } LOGGER.debug("CheckConformityActionHandler response: " + itemStatus.getGlobalStatus()); return new ItemStatus(CALC_CHECK).setItemsStatus(CALC_CHECK, itemStatus); } }
CheckConformityActionPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handlerIO) throws ProcessingException { checkMandatoryParameters(params); LOGGER.debug("CheckConformityActionHandler running ..."); final ItemStatus itemStatus = new ItemStatus(CALC_CHECK); try { final JsonNode jsonOG = handlerIO.getJsonFromWorkspace( IngestWorkflowConstants.OBJECT_GROUP_FOLDER + "/" + params.getObjectName()); handlerIO.addOutputResult(OG_OUT_RANK, jsonOG, true, false); final Map<String, DataObjectInfo> binaryObjects = getBinaryObjects(jsonOG); boolean oneOrMoreMessagesDigestUpdated = false; 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) { final String objectId = version.get(SedaConstants.PREFIX_ID).asText(); boolean messagesDigestUpdated = checkMessageDigest(binaryObjects.get(objectId), version, itemStatus, handlerIO); if(messagesDigestUpdated) { oneOrMoreMessagesDigestUpdated = true; } } } } } } if (oneOrMoreMessagesDigestUpdated) { handlerIO.transferJsonToWorkspace(IngestWorkflowConstants.OBJECT_GROUP_FOLDER, params.getObjectName(), jsonOG, false, false); } } catch (VitamMissingBinaryObjectSizeException e) { LOGGER.error(e); itemStatus.increment(StatusCode.KO); itemStatus.setGlobalOutcomeDetailSubcode("CHECK_OBJECT_SIZE"); } catch (ProcessingException e) { LOGGER.error(e); itemStatus.increment(StatusCode.FATAL); } if (itemStatus.getGlobalStatus().getStatusLevel() == StatusCode.UNKNOWN.getStatusLevel()) { itemStatus.increment(StatusCode.OK); } LOGGER.debug("CheckConformityActionHandler response: " + itemStatus.getGlobalStatus()); return new ItemStatus(CALC_CHECK).setItemsStatus(CALC_CHECK, itemStatus); } CheckConformityActionPlugin(); }
CheckConformityActionPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handlerIO) throws ProcessingException { checkMandatoryParameters(params); LOGGER.debug("CheckConformityActionHandler running ..."); final ItemStatus itemStatus = new ItemStatus(CALC_CHECK); try { final JsonNode jsonOG = handlerIO.getJsonFromWorkspace( IngestWorkflowConstants.OBJECT_GROUP_FOLDER + "/" + params.getObjectName()); handlerIO.addOutputResult(OG_OUT_RANK, jsonOG, true, false); final Map<String, DataObjectInfo> binaryObjects = getBinaryObjects(jsonOG); boolean oneOrMoreMessagesDigestUpdated = false; 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) { final String objectId = version.get(SedaConstants.PREFIX_ID).asText(); boolean messagesDigestUpdated = checkMessageDigest(binaryObjects.get(objectId), version, itemStatus, handlerIO); if(messagesDigestUpdated) { oneOrMoreMessagesDigestUpdated = true; } } } } } } if (oneOrMoreMessagesDigestUpdated) { handlerIO.transferJsonToWorkspace(IngestWorkflowConstants.OBJECT_GROUP_FOLDER, params.getObjectName(), jsonOG, false, false); } } catch (VitamMissingBinaryObjectSizeException e) { LOGGER.error(e); itemStatus.increment(StatusCode.KO); itemStatus.setGlobalOutcomeDetailSubcode("CHECK_OBJECT_SIZE"); } catch (ProcessingException e) { LOGGER.error(e); itemStatus.increment(StatusCode.FATAL); } if (itemStatus.getGlobalStatus().getStatusLevel() == StatusCode.UNKNOWN.getStatusLevel()) { itemStatus.increment(StatusCode.OK); } LOGGER.debug("CheckConformityActionHandler response: " + itemStatus.getGlobalStatus()); return new ItemStatus(CALC_CHECK).setItemsStatus(CALC_CHECK, itemStatus); } CheckConformityActionPlugin(); @Override ItemStatus execute(WorkerParameters params, HandlerIO handlerIO); @Override void checkMandatoryIOParameter(HandlerIO handler); }
CheckConformityActionPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO handlerIO) throws ProcessingException { checkMandatoryParameters(params); LOGGER.debug("CheckConformityActionHandler running ..."); final ItemStatus itemStatus = new ItemStatus(CALC_CHECK); try { final JsonNode jsonOG = handlerIO.getJsonFromWorkspace( IngestWorkflowConstants.OBJECT_GROUP_FOLDER + "/" + params.getObjectName()); handlerIO.addOutputResult(OG_OUT_RANK, jsonOG, true, false); final Map<String, DataObjectInfo> binaryObjects = getBinaryObjects(jsonOG); boolean oneOrMoreMessagesDigestUpdated = false; 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) { final String objectId = version.get(SedaConstants.PREFIX_ID).asText(); boolean messagesDigestUpdated = checkMessageDigest(binaryObjects.get(objectId), version, itemStatus, handlerIO); if(messagesDigestUpdated) { oneOrMoreMessagesDigestUpdated = true; } } } } } } if (oneOrMoreMessagesDigestUpdated) { handlerIO.transferJsonToWorkspace(IngestWorkflowConstants.OBJECT_GROUP_FOLDER, params.getObjectName(), jsonOG, false, false); } } catch (VitamMissingBinaryObjectSizeException e) { LOGGER.error(e); itemStatus.increment(StatusCode.KO); itemStatus.setGlobalOutcomeDetailSubcode("CHECK_OBJECT_SIZE"); } catch (ProcessingException e) { LOGGER.error(e); itemStatus.increment(StatusCode.FATAL); } if (itemStatus.getGlobalStatus().getStatusLevel() == StatusCode.UNKNOWN.getStatusLevel()) { itemStatus.increment(StatusCode.OK); } LOGGER.debug("CheckConformityActionHandler response: " + itemStatus.getGlobalStatus()); return new ItemStatus(CALC_CHECK).setItemsStatus(CALC_CHECK, itemStatus); } CheckConformityActionPlugin(); @Override ItemStatus execute(WorkerParameters params, HandlerIO handlerIO); @Override void checkMandatoryIOParameter(HandlerIO handler); static final String CALC_CHECK; }