@Test public void should_return_item_status_KO_on_checks() throws Exception { ObjectNode metadata = objectMapper.createObjectNode(); metadata.set("unitIds", objectMapper.createArrayNode().add("unitId")); metadata.put("usageVersion", "BinaryMaster_25"); String objectGroupId = "objectGroupId"; String versionId = "VERSION_ID"; WorkerParameters param = workerParameterBuilder() .withObjectName(objectGroupId) .withObjectMetadata(metadata) .build(); File reportFile = tempFolder.newFile(); TestHandlerIO handler = new TestHandlerIO(); handler.setNewLocalFile(reportFile); String storageId = "storage_id_1"; String usageVersion = "BinaryMaster_25"; String strategyId = "other_strategy"; String opi = "OPI"; String logbookLFCDate = "lastPersistedDate"; String logbookOperationLastpersiteddate = "LOGBOOK_OPERATION_lastpersiteddate"; LogbookOperation logBookOperationWith = createLogBookOperationWith("dateOp1", OBJECTGROUP_LFC_TRACEABILITY.getEventType(), "op1", "fileName"); LogbookOperation logBookOperationWith1 = createLogBookOperationWith("dateOp2", LOGBOOK_TRACEABILITY.getEventType(), "op2", "fileName"); given(metaDataClient.getObjectGroupByIdRaw(objectGroupId)).willReturn(getResponseWith(versionId, storageId, strategyId, usageVersion, opi)); given(storageClient.getInformation(strategyId, OBJECT, versionId, Collections.singletonList(storageId), true)).willReturn(createStorageInformationWithDigest(storageId, "DIGEST_FROM_STORAGE")); given(logbookLifeCyclesClient.getRawObjectGroupLifeCycleById(objectGroupId)).willReturn(objectMapper.valueToTree(createObjectGroupLifecycleFrom(versionId, "awesomedigest", logbookLFCDate))); given(logbookOperationsClient.selectOperationById(opi)).willReturn(objectMapper.valueToTree(createOperation(createLogBookOperationWith(logbookOperationLastpersiteddate, "INGEST_OPERATION", "opIngest")))); given(logbookOperationsClient.selectOperation(createSelectTraceabilityWith(OBJECTGROUP_LFC_TRACEABILITY.getEventType(), logbookLFCDate))).willReturn(objectMapper.valueToTree(createOperation(logBookOperationWith))); given(logbookOperationsClient.selectOperation(createSelectTraceabilityWith(LOGBOOK_TRACEABILITY.getEventType(), logbookOperationLastpersiteddate))).willReturn(objectMapper.valueToTree(createOperation(logBookOperationWith1))); given(logbookOperationsClient.selectOperation(createSelectClosestTraceabilityWith(logBookOperationWith))).willReturn(objectMapper.valueToTree(createOperation(createLogBookOperationWith("", OBJECTGROUP_LFC_TRACEABILITY.getEventType(), "op1Closest", "fileName")))); given(logbookOperationsClient.selectOperation(createSelectClosestTraceabilityWith(logBookOperationWith1))).willReturn(objectMapper.valueToTree(createOperation(createLogBookOperationWith("", LOGBOOK_TRACEABILITY.getEventType(), "op2Closest", "fileName")))); ItemStatus itemStatus = probativeCreateReportEntry.execute(param, handler); assertThat(itemStatus.getGlobalStatus()).isEqualTo(KO); }
@Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { String startEntryCreation = LocalDateUtil.getFormattedDateForMongo(LocalDateTime.now()); String objectGroupId = param.getObjectName(); String usageVersion = param.getObjectMetadata().get("usageVersion").asText(); try (MetaDataClient metaDataClient = metaDataClientFactory.getClient(); LogbookLifeCyclesClient logbookLifeCyclesClient = logbookLifeCyclesClientFactory.getClient(); StorageClient storageClient = storageClientFactory.getClient(); LogbookOperationsClient logbookOperationsClient = logbookOperationsClientFactory.getClient()) { List<String> unitIds = JsonHandler.getFromJsonNode(param.getObjectMetadata().get("unitIds"), LIST_STRING); RequestResponse<JsonNode> requestResponse = metaDataClient.getObjectGroupByIdRaw(objectGroupId); if (!requestResponse.isOk()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, FATAL, EventDetails.of(String.format("Cannot retrieve metadata for GOT %s.", objectGroupId))); } Optional<DbVersionsModel> versionOptional = getVersion(usageVersion, requestResponse); if (!versionOptional.isPresent()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found version for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<StorageStrategy> storageStrategies = loadStorageStrategies(handler); DbVersionsModel dbVersionsModel = versionOptional.get(); String strategyId = dbVersionsModel.getStorage().getStrategyId(); List<String> offerIds = StorageStrategyUtils.loadOfferIds(strategyId, storageStrategies); List<String> offerDigests = getOfferDigests(storageClient, dbVersionsModel.getId(), strategyId, offerIds); if (offerDigests.isEmpty() || offerIds.size() != offerDigests.size()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found storage offer digest for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } JsonNode rawLogbookObjectGroupLFC = logbookLifeCyclesClient.getRawObjectGroupLifeCycleById(objectGroupId); LogbookLifecycle logbookObjectGroupLFC = JsonHandler.getFromJsonNode(rawLogbookObjectGroupLFC, LogbookLifecycle.class); Set<String> lifecycleDigests = getLifeCycleDigests(logbookObjectGroupLFC, dbVersionsModel); if (lifecycleDigests.isEmpty()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found lifecycle offer digest for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } JsonNode logbookOperationVersionModelResult = logbookOperationsClient.selectOperationById(dbVersionsModel.getOpi()); RequestResponseOK<JsonNode> logbookOperationVersionModelResponseOK = RequestResponseOK.getFromJsonNode(logbookOperationVersionModelResult); LogbookOperation logbookOperationVersionModel = JsonHandler.getFromJsonNode(logbookOperationVersionModelResponseOK.getFirstResult(), LogbookOperation.class); String objectGroupLFCLastPersistedDate = getObjectGroupLFCLastPersistedDate(logbookObjectGroupLFC, dbVersionsModel); List<LogbookOperation> traceabilityOperations = getTraceabilityLogbookOperation(logbookOperationsClient, logbookOperationVersionModel.getLastPersistedDate(), objectGroupLFCLastPersistedDate); if (traceabilityOperations.isEmpty()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found traceability logbook operation id for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<OperationWithClosestPreviousOperation> operationsAndClosestPreviousOperations = traceabilityOperations.stream() .map(op -> getTraceabilityOperation(logbookOperationsClient, op)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); if (operationsAndClosestPreviousOperations.isEmpty()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found all traceability logbook operation ids for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<ProbativeOperation> probativeOperations = operationsAndClosestPreviousOperations.stream() .map(op -> logbookOperationTo(op.getOperation())) .collect(Collectors.toList()); ProbativeOperation probativeOperationIngest = logbookOperationTo(logbookOperationVersionModel); probativeOperations.add(probativeOperationIngest); Map<String, Optional<OperationTraceabilityFiles>> traceabilityFiles = operationsAndClosestPreviousOperations.stream() .collect(Collectors.toMap(op -> op.getOperation().getEvType(), op -> getTraceabilityFile(op.getOperation(), storageClient, handler, objectGroupId))); if (traceabilityFiles.size() != traceabilityOperations.size() || !traceabilityFiles.values().stream().allMatch(Optional::isPresent)) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion, probativeOperations)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found traceability logbook operation files for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<ProbativeCheck> probativeChecks = operationsAndClosestPreviousOperations.stream() .flatMap(operationWithClosestPreviousOperation -> doChecks(traceabilityFiles.get(operationWithClosestPreviousOperation.getOperation().getEvType()).get(), operationWithClosestPreviousOperation, dbVersionsModel, rawLogbookObjectGroupLFC, logbookOperationVersionModel, handler)) .collect(Collectors.toList()); ProbativeCheck databaseOfferFileDigestCheck = fileDigestComparison(FILE_DIGEST_OFFER_DATABASE_COMPARISON, dbVersionsModel.getMessageDigest(), new HashSet<>(offerDigests)); ProbativeCheck databaseGotLfcFileDigestCheck = fileDigestComparison(FILE_DIGEST_LFC_DATABASE_COMPARISON, dbVersionsModel.getMessageDigest(), lifecycleDigests); probativeChecks.add(databaseOfferFileDigestCheck); probativeChecks.add(databaseGotLfcFileDigestCheck); if (probativeChecks.size() != ChecksInformation.values().length) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion, probativeOperations, probativeChecks)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found ALL %s checks for GOT %s and with VERSION %s.", ChecksInformation.values().length, objectGroupId, usageVersion))); } ProbativeReportEntry probativeReportEntry = new ProbativeReportEntry(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion, probativeOperations, probativeChecks); transferReportEntryToWorkspace(handler, objectGroupId, probativeReportEntry); return buildItemStatus(HANDLER_ID, OK, EventDetails.of(String.format("Entry build for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } catch (StorageStrategyNotFoundException | ProcessingStatusException e) { LOGGER.error(e); tryTransferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, Collections.emptyList(), objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, FATAL, EventDetails.of(String.format("Error while using storage strategies for GOT %s.", objectGroupId))); } catch (Exception e) { LOGGER.error(e); tryTransferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, Collections.emptyList(), objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Error while building probative value for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } }
ProbativeCreateReportEntry extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { String startEntryCreation = LocalDateUtil.getFormattedDateForMongo(LocalDateTime.now()); String objectGroupId = param.getObjectName(); String usageVersion = param.getObjectMetadata().get("usageVersion").asText(); try (MetaDataClient metaDataClient = metaDataClientFactory.getClient(); LogbookLifeCyclesClient logbookLifeCyclesClient = logbookLifeCyclesClientFactory.getClient(); StorageClient storageClient = storageClientFactory.getClient(); LogbookOperationsClient logbookOperationsClient = logbookOperationsClientFactory.getClient()) { List<String> unitIds = JsonHandler.getFromJsonNode(param.getObjectMetadata().get("unitIds"), LIST_STRING); RequestResponse<JsonNode> requestResponse = metaDataClient.getObjectGroupByIdRaw(objectGroupId); if (!requestResponse.isOk()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, FATAL, EventDetails.of(String.format("Cannot retrieve metadata for GOT %s.", objectGroupId))); } Optional<DbVersionsModel> versionOptional = getVersion(usageVersion, requestResponse); if (!versionOptional.isPresent()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found version for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<StorageStrategy> storageStrategies = loadStorageStrategies(handler); DbVersionsModel dbVersionsModel = versionOptional.get(); String strategyId = dbVersionsModel.getStorage().getStrategyId(); List<String> offerIds = StorageStrategyUtils.loadOfferIds(strategyId, storageStrategies); List<String> offerDigests = getOfferDigests(storageClient, dbVersionsModel.getId(), strategyId, offerIds); if (offerDigests.isEmpty() || offerIds.size() != offerDigests.size()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found storage offer digest for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } JsonNode rawLogbookObjectGroupLFC = logbookLifeCyclesClient.getRawObjectGroupLifeCycleById(objectGroupId); LogbookLifecycle logbookObjectGroupLFC = JsonHandler.getFromJsonNode(rawLogbookObjectGroupLFC, LogbookLifecycle.class); Set<String> lifecycleDigests = getLifeCycleDigests(logbookObjectGroupLFC, dbVersionsModel); if (lifecycleDigests.isEmpty()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found lifecycle offer digest for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } JsonNode logbookOperationVersionModelResult = logbookOperationsClient.selectOperationById(dbVersionsModel.getOpi()); RequestResponseOK<JsonNode> logbookOperationVersionModelResponseOK = RequestResponseOK.getFromJsonNode(logbookOperationVersionModelResult); LogbookOperation logbookOperationVersionModel = JsonHandler.getFromJsonNode(logbookOperationVersionModelResponseOK.getFirstResult(), LogbookOperation.class); String objectGroupLFCLastPersistedDate = getObjectGroupLFCLastPersistedDate(logbookObjectGroupLFC, dbVersionsModel); List<LogbookOperation> traceabilityOperations = getTraceabilityLogbookOperation(logbookOperationsClient, logbookOperationVersionModel.getLastPersistedDate(), objectGroupLFCLastPersistedDate); if (traceabilityOperations.isEmpty()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found traceability logbook operation id for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<OperationWithClosestPreviousOperation> operationsAndClosestPreviousOperations = traceabilityOperations.stream() .map(op -> getTraceabilityOperation(logbookOperationsClient, op)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); if (operationsAndClosestPreviousOperations.isEmpty()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found all traceability logbook operation ids for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<ProbativeOperation> probativeOperations = operationsAndClosestPreviousOperations.stream() .map(op -> logbookOperationTo(op.getOperation())) .collect(Collectors.toList()); ProbativeOperation probativeOperationIngest = logbookOperationTo(logbookOperationVersionModel); probativeOperations.add(probativeOperationIngest); Map<String, Optional<OperationTraceabilityFiles>> traceabilityFiles = operationsAndClosestPreviousOperations.stream() .collect(Collectors.toMap(op -> op.getOperation().getEvType(), op -> getTraceabilityFile(op.getOperation(), storageClient, handler, objectGroupId))); if (traceabilityFiles.size() != traceabilityOperations.size() || !traceabilityFiles.values().stream().allMatch(Optional::isPresent)) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion, probativeOperations)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found traceability logbook operation files for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<ProbativeCheck> probativeChecks = operationsAndClosestPreviousOperations.stream() .flatMap(operationWithClosestPreviousOperation -> doChecks(traceabilityFiles.get(operationWithClosestPreviousOperation.getOperation().getEvType()).get(), operationWithClosestPreviousOperation, dbVersionsModel, rawLogbookObjectGroupLFC, logbookOperationVersionModel, handler)) .collect(Collectors.toList()); ProbativeCheck databaseOfferFileDigestCheck = fileDigestComparison(FILE_DIGEST_OFFER_DATABASE_COMPARISON, dbVersionsModel.getMessageDigest(), new HashSet<>(offerDigests)); ProbativeCheck databaseGotLfcFileDigestCheck = fileDigestComparison(FILE_DIGEST_LFC_DATABASE_COMPARISON, dbVersionsModel.getMessageDigest(), lifecycleDigests); probativeChecks.add(databaseOfferFileDigestCheck); probativeChecks.add(databaseGotLfcFileDigestCheck); if (probativeChecks.size() != ChecksInformation.values().length) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion, probativeOperations, probativeChecks)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found ALL %s checks for GOT %s and with VERSION %s.", ChecksInformation.values().length, objectGroupId, usageVersion))); } ProbativeReportEntry probativeReportEntry = new ProbativeReportEntry(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion, probativeOperations, probativeChecks); transferReportEntryToWorkspace(handler, objectGroupId, probativeReportEntry); return buildItemStatus(HANDLER_ID, OK, EventDetails.of(String.format("Entry build for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } catch (StorageStrategyNotFoundException | ProcessingStatusException e) { LOGGER.error(e); tryTransferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, Collections.emptyList(), objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, FATAL, EventDetails.of(String.format("Error while using storage strategies for GOT %s.", objectGroupId))); } catch (Exception e) { LOGGER.error(e); tryTransferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, Collections.emptyList(), objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Error while building probative value for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } } }
ProbativeCreateReportEntry extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { String startEntryCreation = LocalDateUtil.getFormattedDateForMongo(LocalDateTime.now()); String objectGroupId = param.getObjectName(); String usageVersion = param.getObjectMetadata().get("usageVersion").asText(); try (MetaDataClient metaDataClient = metaDataClientFactory.getClient(); LogbookLifeCyclesClient logbookLifeCyclesClient = logbookLifeCyclesClientFactory.getClient(); StorageClient storageClient = storageClientFactory.getClient(); LogbookOperationsClient logbookOperationsClient = logbookOperationsClientFactory.getClient()) { List<String> unitIds = JsonHandler.getFromJsonNode(param.getObjectMetadata().get("unitIds"), LIST_STRING); RequestResponse<JsonNode> requestResponse = metaDataClient.getObjectGroupByIdRaw(objectGroupId); if (!requestResponse.isOk()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, FATAL, EventDetails.of(String.format("Cannot retrieve metadata for GOT %s.", objectGroupId))); } Optional<DbVersionsModel> versionOptional = getVersion(usageVersion, requestResponse); if (!versionOptional.isPresent()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found version for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<StorageStrategy> storageStrategies = loadStorageStrategies(handler); DbVersionsModel dbVersionsModel = versionOptional.get(); String strategyId = dbVersionsModel.getStorage().getStrategyId(); List<String> offerIds = StorageStrategyUtils.loadOfferIds(strategyId, storageStrategies); List<String> offerDigests = getOfferDigests(storageClient, dbVersionsModel.getId(), strategyId, offerIds); if (offerDigests.isEmpty() || offerIds.size() != offerDigests.size()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found storage offer digest for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } JsonNode rawLogbookObjectGroupLFC = logbookLifeCyclesClient.getRawObjectGroupLifeCycleById(objectGroupId); LogbookLifecycle logbookObjectGroupLFC = JsonHandler.getFromJsonNode(rawLogbookObjectGroupLFC, LogbookLifecycle.class); Set<String> lifecycleDigests = getLifeCycleDigests(logbookObjectGroupLFC, dbVersionsModel); if (lifecycleDigests.isEmpty()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found lifecycle offer digest for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } JsonNode logbookOperationVersionModelResult = logbookOperationsClient.selectOperationById(dbVersionsModel.getOpi()); RequestResponseOK<JsonNode> logbookOperationVersionModelResponseOK = RequestResponseOK.getFromJsonNode(logbookOperationVersionModelResult); LogbookOperation logbookOperationVersionModel = JsonHandler.getFromJsonNode(logbookOperationVersionModelResponseOK.getFirstResult(), LogbookOperation.class); String objectGroupLFCLastPersistedDate = getObjectGroupLFCLastPersistedDate(logbookObjectGroupLFC, dbVersionsModel); List<LogbookOperation> traceabilityOperations = getTraceabilityLogbookOperation(logbookOperationsClient, logbookOperationVersionModel.getLastPersistedDate(), objectGroupLFCLastPersistedDate); if (traceabilityOperations.isEmpty()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found traceability logbook operation id for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<OperationWithClosestPreviousOperation> operationsAndClosestPreviousOperations = traceabilityOperations.stream() .map(op -> getTraceabilityOperation(logbookOperationsClient, op)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); if (operationsAndClosestPreviousOperations.isEmpty()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found all traceability logbook operation ids for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<ProbativeOperation> probativeOperations = operationsAndClosestPreviousOperations.stream() .map(op -> logbookOperationTo(op.getOperation())) .collect(Collectors.toList()); ProbativeOperation probativeOperationIngest = logbookOperationTo(logbookOperationVersionModel); probativeOperations.add(probativeOperationIngest); Map<String, Optional<OperationTraceabilityFiles>> traceabilityFiles = operationsAndClosestPreviousOperations.stream() .collect(Collectors.toMap(op -> op.getOperation().getEvType(), op -> getTraceabilityFile(op.getOperation(), storageClient, handler, objectGroupId))); if (traceabilityFiles.size() != traceabilityOperations.size() || !traceabilityFiles.values().stream().allMatch(Optional::isPresent)) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion, probativeOperations)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found traceability logbook operation files for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<ProbativeCheck> probativeChecks = operationsAndClosestPreviousOperations.stream() .flatMap(operationWithClosestPreviousOperation -> doChecks(traceabilityFiles.get(operationWithClosestPreviousOperation.getOperation().getEvType()).get(), operationWithClosestPreviousOperation, dbVersionsModel, rawLogbookObjectGroupLFC, logbookOperationVersionModel, handler)) .collect(Collectors.toList()); ProbativeCheck databaseOfferFileDigestCheck = fileDigestComparison(FILE_DIGEST_OFFER_DATABASE_COMPARISON, dbVersionsModel.getMessageDigest(), new HashSet<>(offerDigests)); ProbativeCheck databaseGotLfcFileDigestCheck = fileDigestComparison(FILE_DIGEST_LFC_DATABASE_COMPARISON, dbVersionsModel.getMessageDigest(), lifecycleDigests); probativeChecks.add(databaseOfferFileDigestCheck); probativeChecks.add(databaseGotLfcFileDigestCheck); if (probativeChecks.size() != ChecksInformation.values().length) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion, probativeOperations, probativeChecks)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found ALL %s checks for GOT %s and with VERSION %s.", ChecksInformation.values().length, objectGroupId, usageVersion))); } ProbativeReportEntry probativeReportEntry = new ProbativeReportEntry(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion, probativeOperations, probativeChecks); transferReportEntryToWorkspace(handler, objectGroupId, probativeReportEntry); return buildItemStatus(HANDLER_ID, OK, EventDetails.of(String.format("Entry build for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } catch (StorageStrategyNotFoundException | ProcessingStatusException e) { LOGGER.error(e); tryTransferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, Collections.emptyList(), objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, FATAL, EventDetails.of(String.format("Error while using storage strategies for GOT %s.", objectGroupId))); } catch (Exception e) { LOGGER.error(e); tryTransferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, Collections.emptyList(), objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Error while building probative value for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } } @VisibleForTesting  ProbativeCreateReportEntry(MetaDataClientFactory metaDataClientFactory, LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory, StorageClientFactory storageClientFactory, LogbookOperationsClientFactory logbookOperationsClientFactory, TimeStampService timeStampService);  ProbativeCreateReportEntry(); }
ProbativeCreateReportEntry extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { String startEntryCreation = LocalDateUtil.getFormattedDateForMongo(LocalDateTime.now()); String objectGroupId = param.getObjectName(); String usageVersion = param.getObjectMetadata().get("usageVersion").asText(); try (MetaDataClient metaDataClient = metaDataClientFactory.getClient(); LogbookLifeCyclesClient logbookLifeCyclesClient = logbookLifeCyclesClientFactory.getClient(); StorageClient storageClient = storageClientFactory.getClient(); LogbookOperationsClient logbookOperationsClient = logbookOperationsClientFactory.getClient()) { List<String> unitIds = JsonHandler.getFromJsonNode(param.getObjectMetadata().get("unitIds"), LIST_STRING); RequestResponse<JsonNode> requestResponse = metaDataClient.getObjectGroupByIdRaw(objectGroupId); if (!requestResponse.isOk()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, FATAL, EventDetails.of(String.format("Cannot retrieve metadata for GOT %s.", objectGroupId))); } Optional<DbVersionsModel> versionOptional = getVersion(usageVersion, requestResponse); if (!versionOptional.isPresent()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found version for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<StorageStrategy> storageStrategies = loadStorageStrategies(handler); DbVersionsModel dbVersionsModel = versionOptional.get(); String strategyId = dbVersionsModel.getStorage().getStrategyId(); List<String> offerIds = StorageStrategyUtils.loadOfferIds(strategyId, storageStrategies); List<String> offerDigests = getOfferDigests(storageClient, dbVersionsModel.getId(), strategyId, offerIds); if (offerDigests.isEmpty() || offerIds.size() != offerDigests.size()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found storage offer digest for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } JsonNode rawLogbookObjectGroupLFC = logbookLifeCyclesClient.getRawObjectGroupLifeCycleById(objectGroupId); LogbookLifecycle logbookObjectGroupLFC = JsonHandler.getFromJsonNode(rawLogbookObjectGroupLFC, LogbookLifecycle.class); Set<String> lifecycleDigests = getLifeCycleDigests(logbookObjectGroupLFC, dbVersionsModel); if (lifecycleDigests.isEmpty()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found lifecycle offer digest for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } JsonNode logbookOperationVersionModelResult = logbookOperationsClient.selectOperationById(dbVersionsModel.getOpi()); RequestResponseOK<JsonNode> logbookOperationVersionModelResponseOK = RequestResponseOK.getFromJsonNode(logbookOperationVersionModelResult); LogbookOperation logbookOperationVersionModel = JsonHandler.getFromJsonNode(logbookOperationVersionModelResponseOK.getFirstResult(), LogbookOperation.class); String objectGroupLFCLastPersistedDate = getObjectGroupLFCLastPersistedDate(logbookObjectGroupLFC, dbVersionsModel); List<LogbookOperation> traceabilityOperations = getTraceabilityLogbookOperation(logbookOperationsClient, logbookOperationVersionModel.getLastPersistedDate(), objectGroupLFCLastPersistedDate); if (traceabilityOperations.isEmpty()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found traceability logbook operation id for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<OperationWithClosestPreviousOperation> operationsAndClosestPreviousOperations = traceabilityOperations.stream() .map(op -> getTraceabilityOperation(logbookOperationsClient, op)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); if (operationsAndClosestPreviousOperations.isEmpty()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found all traceability logbook operation ids for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<ProbativeOperation> probativeOperations = operationsAndClosestPreviousOperations.stream() .map(op -> logbookOperationTo(op.getOperation())) .collect(Collectors.toList()); ProbativeOperation probativeOperationIngest = logbookOperationTo(logbookOperationVersionModel); probativeOperations.add(probativeOperationIngest); Map<String, Optional<OperationTraceabilityFiles>> traceabilityFiles = operationsAndClosestPreviousOperations.stream() .collect(Collectors.toMap(op -> op.getOperation().getEvType(), op -> getTraceabilityFile(op.getOperation(), storageClient, handler, objectGroupId))); if (traceabilityFiles.size() != traceabilityOperations.size() || !traceabilityFiles.values().stream().allMatch(Optional::isPresent)) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion, probativeOperations)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found traceability logbook operation files for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<ProbativeCheck> probativeChecks = operationsAndClosestPreviousOperations.stream() .flatMap(operationWithClosestPreviousOperation -> doChecks(traceabilityFiles.get(operationWithClosestPreviousOperation.getOperation().getEvType()).get(), operationWithClosestPreviousOperation, dbVersionsModel, rawLogbookObjectGroupLFC, logbookOperationVersionModel, handler)) .collect(Collectors.toList()); ProbativeCheck databaseOfferFileDigestCheck = fileDigestComparison(FILE_DIGEST_OFFER_DATABASE_COMPARISON, dbVersionsModel.getMessageDigest(), new HashSet<>(offerDigests)); ProbativeCheck databaseGotLfcFileDigestCheck = fileDigestComparison(FILE_DIGEST_LFC_DATABASE_COMPARISON, dbVersionsModel.getMessageDigest(), lifecycleDigests); probativeChecks.add(databaseOfferFileDigestCheck); probativeChecks.add(databaseGotLfcFileDigestCheck); if (probativeChecks.size() != ChecksInformation.values().length) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion, probativeOperations, probativeChecks)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found ALL %s checks for GOT %s and with VERSION %s.", ChecksInformation.values().length, objectGroupId, usageVersion))); } ProbativeReportEntry probativeReportEntry = new ProbativeReportEntry(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion, probativeOperations, probativeChecks); transferReportEntryToWorkspace(handler, objectGroupId, probativeReportEntry); return buildItemStatus(HANDLER_ID, OK, EventDetails.of(String.format("Entry build for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } catch (StorageStrategyNotFoundException | ProcessingStatusException e) { LOGGER.error(e); tryTransferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, Collections.emptyList(), objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, FATAL, EventDetails.of(String.format("Error while using storage strategies for GOT %s.", objectGroupId))); } catch (Exception e) { LOGGER.error(e); tryTransferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, Collections.emptyList(), objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Error while building probative value for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } } @VisibleForTesting  ProbativeCreateReportEntry(MetaDataClientFactory metaDataClientFactory, LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory, StorageClientFactory storageClientFactory, LogbookOperationsClientFactory logbookOperationsClientFactory, TimeStampService timeStampService);  ProbativeCreateReportEntry(); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); static String traceabilityFilesDirectoryName(String objectGroupId, String evType); }
ProbativeCreateReportEntry extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { String startEntryCreation = LocalDateUtil.getFormattedDateForMongo(LocalDateTime.now()); String objectGroupId = param.getObjectName(); String usageVersion = param.getObjectMetadata().get("usageVersion").asText(); try (MetaDataClient metaDataClient = metaDataClientFactory.getClient(); LogbookLifeCyclesClient logbookLifeCyclesClient = logbookLifeCyclesClientFactory.getClient(); StorageClient storageClient = storageClientFactory.getClient(); LogbookOperationsClient logbookOperationsClient = logbookOperationsClientFactory.getClient()) { List<String> unitIds = JsonHandler.getFromJsonNode(param.getObjectMetadata().get("unitIds"), LIST_STRING); RequestResponse<JsonNode> requestResponse = metaDataClient.getObjectGroupByIdRaw(objectGroupId); if (!requestResponse.isOk()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, FATAL, EventDetails.of(String.format("Cannot retrieve metadata for GOT %s.", objectGroupId))); } Optional<DbVersionsModel> versionOptional = getVersion(usageVersion, requestResponse); if (!versionOptional.isPresent()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found version for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<StorageStrategy> storageStrategies = loadStorageStrategies(handler); DbVersionsModel dbVersionsModel = versionOptional.get(); String strategyId = dbVersionsModel.getStorage().getStrategyId(); List<String> offerIds = StorageStrategyUtils.loadOfferIds(strategyId, storageStrategies); List<String> offerDigests = getOfferDigests(storageClient, dbVersionsModel.getId(), strategyId, offerIds); if (offerDigests.isEmpty() || offerIds.size() != offerDigests.size()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found storage offer digest for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } JsonNode rawLogbookObjectGroupLFC = logbookLifeCyclesClient.getRawObjectGroupLifeCycleById(objectGroupId); LogbookLifecycle logbookObjectGroupLFC = JsonHandler.getFromJsonNode(rawLogbookObjectGroupLFC, LogbookLifecycle.class); Set<String> lifecycleDigests = getLifeCycleDigests(logbookObjectGroupLFC, dbVersionsModel); if (lifecycleDigests.isEmpty()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found lifecycle offer digest for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } JsonNode logbookOperationVersionModelResult = logbookOperationsClient.selectOperationById(dbVersionsModel.getOpi()); RequestResponseOK<JsonNode> logbookOperationVersionModelResponseOK = RequestResponseOK.getFromJsonNode(logbookOperationVersionModelResult); LogbookOperation logbookOperationVersionModel = JsonHandler.getFromJsonNode(logbookOperationVersionModelResponseOK.getFirstResult(), LogbookOperation.class); String objectGroupLFCLastPersistedDate = getObjectGroupLFCLastPersistedDate(logbookObjectGroupLFC, dbVersionsModel); List<LogbookOperation> traceabilityOperations = getTraceabilityLogbookOperation(logbookOperationsClient, logbookOperationVersionModel.getLastPersistedDate(), objectGroupLFCLastPersistedDate); if (traceabilityOperations.isEmpty()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found traceability logbook operation id for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<OperationWithClosestPreviousOperation> operationsAndClosestPreviousOperations = traceabilityOperations.stream() .map(op -> getTraceabilityOperation(logbookOperationsClient, op)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); if (operationsAndClosestPreviousOperations.isEmpty()) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found all traceability logbook operation ids for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<ProbativeOperation> probativeOperations = operationsAndClosestPreviousOperations.stream() .map(op -> logbookOperationTo(op.getOperation())) .collect(Collectors.toList()); ProbativeOperation probativeOperationIngest = logbookOperationTo(logbookOperationVersionModel); probativeOperations.add(probativeOperationIngest); Map<String, Optional<OperationTraceabilityFiles>> traceabilityFiles = operationsAndClosestPreviousOperations.stream() .collect(Collectors.toMap(op -> op.getOperation().getEvType(), op -> getTraceabilityFile(op.getOperation(), storageClient, handler, objectGroupId))); if (traceabilityFiles.size() != traceabilityOperations.size() || !traceabilityFiles.values().stream().allMatch(Optional::isPresent)) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion, probativeOperations)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found traceability logbook operation files for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } List<ProbativeCheck> probativeChecks = operationsAndClosestPreviousOperations.stream() .flatMap(operationWithClosestPreviousOperation -> doChecks(traceabilityFiles.get(operationWithClosestPreviousOperation.getOperation().getEvType()).get(), operationWithClosestPreviousOperation, dbVersionsModel, rawLogbookObjectGroupLFC, logbookOperationVersionModel, handler)) .collect(Collectors.toList()); ProbativeCheck databaseOfferFileDigestCheck = fileDigestComparison(FILE_DIGEST_OFFER_DATABASE_COMPARISON, dbVersionsModel.getMessageDigest(), new HashSet<>(offerDigests)); ProbativeCheck databaseGotLfcFileDigestCheck = fileDigestComparison(FILE_DIGEST_LFC_DATABASE_COMPARISON, dbVersionsModel.getMessageDigest(), lifecycleDigests); probativeChecks.add(databaseOfferFileDigestCheck); probativeChecks.add(databaseGotLfcFileDigestCheck); if (probativeChecks.size() != ChecksInformation.values().length) { transferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion, probativeOperations, probativeChecks)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Cannot found ALL %s checks for GOT %s and with VERSION %s.", ChecksInformation.values().length, objectGroupId, usageVersion))); } ProbativeReportEntry probativeReportEntry = new ProbativeReportEntry(startEntryCreation, unitIds, objectGroupId, dbVersionsModel.getId(), usageVersion, probativeOperations, probativeChecks); transferReportEntryToWorkspace(handler, objectGroupId, probativeReportEntry); return buildItemStatus(HANDLER_ID, OK, EventDetails.of(String.format("Entry build for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } catch (StorageStrategyNotFoundException | ProcessingStatusException e) { LOGGER.error(e); tryTransferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, Collections.emptyList(), objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, FATAL, EventDetails.of(String.format("Error while using storage strategies for GOT %s.", objectGroupId))); } catch (Exception e) { LOGGER.error(e); tryTransferReportEntryToWorkspace(handler, objectGroupId, ProbativeReportEntry.koFrom(startEntryCreation, Collections.emptyList(), objectGroupId, NO_BINARY_ID, usageVersion)); return buildItemStatus(HANDLER_ID, KO, EventDetails.of(String.format("Error while building probative value for GOT %s and with VERSION %s.", objectGroupId, usageVersion))); } } @VisibleForTesting  ProbativeCreateReportEntry(MetaDataClientFactory metaDataClientFactory, LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory, StorageClientFactory storageClientFactory, LogbookOperationsClientFactory logbookOperationsClientFactory, TimeStampService timeStampService);  ProbativeCreateReportEntry(); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); static String traceabilityFilesDirectoryName(String objectGroupId, String evType); static final String NO_BINARY_ID; }