@Test @RunWithCustomExecutor public void when_update_should_return_error_given_strategy_missing_default_offer() throws VitamException, InvalidCreateOperationException, FileNotFoundException { final SetAction updateStorageUnit = UpdateActionHelper.set("Storage.UnitStrategy", "fake-invalid-md"); final SetAction updateStorageObjectGroup = UpdateActionHelper.set("Storage.ObjectGroupStrategy", "fake-invalid-md"); final Update update = new Update(); update.setQuery(QueryHelper.eq("Identifier", "IdentifierMC1")); update.addActions(updateStorageUnit, updateStorageObjectGroup); DbRequestResult findResultMock = mock(DbRequestResult.class); when(findResultMock.getCount()).thenReturn(1l); when(findResultMock.getDocuments(ManagementContract.class, ManagementContractModel.class)) .thenReturn(Arrays.asList(getManagementContract("IdentifierMC1"))); when(mongoAccess.findDocuments(any(), eq(FunctionalAdminCollections.MANAGEMENT_CONTRACT))) .thenReturn(findResultMock); when(storageClient.getStorageStrategies()).thenReturn(loadStorageStrategies()); RequestResponse<ManagementContractModel> response = managementContractService.updateContract("IdentifierMC1", update.getFinalUpdate()); assertThat(response.isOk()).isFalse(); assertThat(((VitamError) response).getErrors()).isNotNull(); assertThat(((VitamError) response).getErrors().size()).isEqualTo(2); assertThat(((VitamError) response).getErrors().get(0).getMessage()) .isEqualTo("STP_UPDATE_MANAGEMENT_CONTRACT.STRATEGY_VALIDATION_ERROR.KO"); assertThat(((VitamError) response).getErrors().get(0).getDescription()).isEqualTo( "Storage Strategy (fake-invalid-md) does not contains one and only one 'referent' offer for the field Storage.UnitStrategy"); assertThat(((VitamError) response).getErrors().get(1).getMessage()) .isEqualTo("STP_UPDATE_MANAGEMENT_CONTRACT.STRATEGY_VALIDATION_ERROR.KO"); assertThat(((VitamError) response).getErrors().get(1).getDescription()).isEqualTo( "Storage Strategy (fake-invalid-md) does not contains one and only one 'referent' offer for the field Storage.ObjectGroupStrategy"); assertThat(((VitamError) response).getState()).isEqualTo("KO"); assertThat(((VitamError) response).getHttpCode()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode()); verify(logbookOperationsClient, times(1)).create(logbookOperationParametersCaptor.capture()); verify(logbookOperationsClient, times(1)).update(logbookOperationParametersCaptor.capture()); List<LogbookOperationParameters> allLogbookOperationParameters = logbookOperationParametersCaptor .getAllValues(); assertThat(allLogbookOperationParameters.size()).isEqualTo(2); assertThat(allLogbookOperationParameters.get(0).getStatus()).isEqualTo(StatusCode.STARTED); assertThat(allLogbookOperationParameters.get(0).getParameterValue(LogbookParameterName.eventType)) .isEqualTo("STP_UPDATE_MANAGEMENT_CONTRACT"); assertThat(allLogbookOperationParameters.get(1).getStatus()).isEqualTo(StatusCode.KO); assertThat(allLogbookOperationParameters.get(1).getParameterValue(LogbookParameterName.eventType)) .isEqualTo("STP_UPDATE_MANAGEMENT_CONTRACT"); assertThat(allLogbookOperationParameters.get(1).getParameterValue(LogbookParameterName.outcomeDetail)) .isEqualTo("STP_UPDATE_MANAGEMENT_CONTRACT.STRATEGY_VALIDATION_ERROR.KO"); }
@Override public RequestResponse<ManagementContractModel> updateContract(String identifier, JsonNode queryDsl) throws VitamException { VitamError error = getVitamError(VitamCode.CONTRACT_VALIDATION_ERROR.getItem(), "Management contract update error", StatusCode.KO) .setHttpCode(Response.Status.BAD_REQUEST.getStatusCode()); if (queryDsl == null || !queryDsl.isObject()) { return error; } final ManagementContractModel managementContractModel = findByIdentifier(identifier); if (managementContractModel == null) { error.setHttpCode(Response.Status.NOT_FOUND.getStatusCode()); return error.addToErrors(getVitamError(VitamCode.CONTRACT_VALIDATION_ERROR.getItem(), MANAGEMENT_CONTRACT_NOT_FOUND + identifier, StatusCode.KO).setMessage(UPDATE_CONTRACT_NOT_FOUND)); } String operationId = VitamThreadUtils.getVitamSession().getRequestId(); GUID eip = GUIDReader.getGUID(operationId); RequestResponseOK response = new RequestResponseOK<>(); ManagementContractValidationService validationService = new ManagementContractValidationService(storageClient, mongoAccess); ContractLogbookService logbookService = new ContractLogbookService(logbookClient,eip, CONTRACTS_IMPORT_EVENT, CONTRACT_UPDATE_EVENT, CONTRACT_KEY, CONTRACT_CHECK_KEY); logbookService.logUpdateStarted(managementContractModel.getId()); final JsonNode actionNode = queryDsl.get(BuilderToken.GLOBAL.ACTION.exactToken()); for (final JsonNode fieldToSet : actionNode) { final JsonNode fieldName = fieldToSet.get(BuilderToken.UPDATEACTION.SET.exactToken()); if (fieldName != null) { final Iterator<String> it = fieldName.fieldNames(); while (it.hasNext()) { final String field = it.next(); final JsonNode value = fieldName.findValue(field); validateUpdateAction(validationService, managementContractModel.getName(), error, field, value); } ((ObjectNode) fieldName).remove(AbstractContractModel.TAG_CREATION_DATE); ((ObjectNode) fieldName).put(AbstractContractModel.TAG_LAST_UPDATE, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); } } Map<String, List<String>> updateDiffs; try { if (error.getErrors() != null && !error.getErrors().isEmpty()) { final String errorsDetails = error.getErrors().stream().map(VitamError::getDescription) .collect(Collectors.joining(",")); logbookService.logValidationError(errorsDetails, CONTRACT_UPDATE_EVENT, error.getErrors().get(0).getMessage()); return error; } DbRequestResult result = mongoAccess.updateData(queryDsl, FunctionalAdminCollections.MANAGEMENT_CONTRACT); updateDiffs = result.getDiffs(); response.addResult(new DbRequestResult(result)).setTotal(result.getTotal()).setQuery(queryDsl) .setHttpCode(Response.Status.OK.getStatusCode()); result.close(); functionalBackupService.saveCollectionAndSequence(eip, CONTRACT_BACKUP_EVENT, FunctionalAdminCollections.MANAGEMENT_CONTRACT, managementContractModel.getId()); logbookService.logUpdateSuccess(managementContractModel.getId(), identifier, updateDiffs.get(managementContractModel.getId())); return response; } catch (SchemaValidationException | BadRequestException exp) { LOGGER.error(exp); final String err = new StringBuilder("Update management contract error > ").append(exp.getMessage()) .toString(); logbookService.logValidationError(err, CONTRACT_UPDATE_EVENT, UPDATE_CONTRACT_BAD_REQUEST); return getVitamError(VitamCode.CONTRACT_VALIDATION_ERROR.getItem(), exp.getMessage(), StatusCode.KO) .setDescription(err).setHttpCode(Response.Status.BAD_REQUEST.getStatusCode()); } catch (Exception e) { LOGGER.error(e); final String err = new StringBuilder("Update management contract error > ").append(e.getMessage()) .toString(); logbookService.logFatalError(err, CONTRACT_UPDATE_EVENT); error.setCode(VitamCode.GLOBAL_INTERNAL_SERVER_ERROR.getItem()).setDescription(err) .setHttpCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); return error; } }
ManagementContractImpl implements ContractService<ManagementContractModel> { @Override public RequestResponse<ManagementContractModel> updateContract(String identifier, JsonNode queryDsl) throws VitamException { VitamError error = getVitamError(VitamCode.CONTRACT_VALIDATION_ERROR.getItem(), "Management contract update error", StatusCode.KO) .setHttpCode(Response.Status.BAD_REQUEST.getStatusCode()); if (queryDsl == null || !queryDsl.isObject()) { return error; } final ManagementContractModel managementContractModel = findByIdentifier(identifier); if (managementContractModel == null) { error.setHttpCode(Response.Status.NOT_FOUND.getStatusCode()); return error.addToErrors(getVitamError(VitamCode.CONTRACT_VALIDATION_ERROR.getItem(), MANAGEMENT_CONTRACT_NOT_FOUND + identifier, StatusCode.KO).setMessage(UPDATE_CONTRACT_NOT_FOUND)); } String operationId = VitamThreadUtils.getVitamSession().getRequestId(); GUID eip = GUIDReader.getGUID(operationId); RequestResponseOK response = new RequestResponseOK<>(); ManagementContractValidationService validationService = new ManagementContractValidationService(storageClient, mongoAccess); ContractLogbookService logbookService = new ContractLogbookService(logbookClient,eip, CONTRACTS_IMPORT_EVENT, CONTRACT_UPDATE_EVENT, CONTRACT_KEY, CONTRACT_CHECK_KEY); logbookService.logUpdateStarted(managementContractModel.getId()); final JsonNode actionNode = queryDsl.get(BuilderToken.GLOBAL.ACTION.exactToken()); for (final JsonNode fieldToSet : actionNode) { final JsonNode fieldName = fieldToSet.get(BuilderToken.UPDATEACTION.SET.exactToken()); if (fieldName != null) { final Iterator<String> it = fieldName.fieldNames(); while (it.hasNext()) { final String field = it.next(); final JsonNode value = fieldName.findValue(field); validateUpdateAction(validationService, managementContractModel.getName(), error, field, value); } ((ObjectNode) fieldName).remove(AbstractContractModel.TAG_CREATION_DATE); ((ObjectNode) fieldName).put(AbstractContractModel.TAG_LAST_UPDATE, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); } } Map<String, List<String>> updateDiffs; try { if (error.getErrors() != null && !error.getErrors().isEmpty()) { final String errorsDetails = error.getErrors().stream().map(VitamError::getDescription) .collect(Collectors.joining(",")); logbookService.logValidationError(errorsDetails, CONTRACT_UPDATE_EVENT, error.getErrors().get(0).getMessage()); return error; } DbRequestResult result = mongoAccess.updateData(queryDsl, FunctionalAdminCollections.MANAGEMENT_CONTRACT); updateDiffs = result.getDiffs(); response.addResult(new DbRequestResult(result)).setTotal(result.getTotal()).setQuery(queryDsl) .setHttpCode(Response.Status.OK.getStatusCode()); result.close(); functionalBackupService.saveCollectionAndSequence(eip, CONTRACT_BACKUP_EVENT, FunctionalAdminCollections.MANAGEMENT_CONTRACT, managementContractModel.getId()); logbookService.logUpdateSuccess(managementContractModel.getId(), identifier, updateDiffs.get(managementContractModel.getId())); return response; } catch (SchemaValidationException | BadRequestException exp) { LOGGER.error(exp); final String err = new StringBuilder("Update management contract error > ").append(exp.getMessage()) .toString(); logbookService.logValidationError(err, CONTRACT_UPDATE_EVENT, UPDATE_CONTRACT_BAD_REQUEST); return getVitamError(VitamCode.CONTRACT_VALIDATION_ERROR.getItem(), exp.getMessage(), StatusCode.KO) .setDescription(err).setHttpCode(Response.Status.BAD_REQUEST.getStatusCode()); } catch (Exception e) { LOGGER.error(e); final String err = new StringBuilder("Update management contract error > ").append(e.getMessage()) .toString(); logbookService.logFatalError(err, CONTRACT_UPDATE_EVENT); error.setCode(VitamCode.GLOBAL_INTERNAL_SERVER_ERROR.getItem()).setDescription(err) .setHttpCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); return error; } } }
ManagementContractImpl implements ContractService<ManagementContractModel> { @Override public RequestResponse<ManagementContractModel> updateContract(String identifier, JsonNode queryDsl) throws VitamException { VitamError error = getVitamError(VitamCode.CONTRACT_VALIDATION_ERROR.getItem(), "Management contract update error", StatusCode.KO) .setHttpCode(Response.Status.BAD_REQUEST.getStatusCode()); if (queryDsl == null || !queryDsl.isObject()) { return error; } final ManagementContractModel managementContractModel = findByIdentifier(identifier); if (managementContractModel == null) { error.setHttpCode(Response.Status.NOT_FOUND.getStatusCode()); return error.addToErrors(getVitamError(VitamCode.CONTRACT_VALIDATION_ERROR.getItem(), MANAGEMENT_CONTRACT_NOT_FOUND + identifier, StatusCode.KO).setMessage(UPDATE_CONTRACT_NOT_FOUND)); } String operationId = VitamThreadUtils.getVitamSession().getRequestId(); GUID eip = GUIDReader.getGUID(operationId); RequestResponseOK response = new RequestResponseOK<>(); ManagementContractValidationService validationService = new ManagementContractValidationService(storageClient, mongoAccess); ContractLogbookService logbookService = new ContractLogbookService(logbookClient,eip, CONTRACTS_IMPORT_EVENT, CONTRACT_UPDATE_EVENT, CONTRACT_KEY, CONTRACT_CHECK_KEY); logbookService.logUpdateStarted(managementContractModel.getId()); final JsonNode actionNode = queryDsl.get(BuilderToken.GLOBAL.ACTION.exactToken()); for (final JsonNode fieldToSet : actionNode) { final JsonNode fieldName = fieldToSet.get(BuilderToken.UPDATEACTION.SET.exactToken()); if (fieldName != null) { final Iterator<String> it = fieldName.fieldNames(); while (it.hasNext()) { final String field = it.next(); final JsonNode value = fieldName.findValue(field); validateUpdateAction(validationService, managementContractModel.getName(), error, field, value); } ((ObjectNode) fieldName).remove(AbstractContractModel.TAG_CREATION_DATE); ((ObjectNode) fieldName).put(AbstractContractModel.TAG_LAST_UPDATE, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); } } Map<String, List<String>> updateDiffs; try { if (error.getErrors() != null && !error.getErrors().isEmpty()) { final String errorsDetails = error.getErrors().stream().map(VitamError::getDescription) .collect(Collectors.joining(",")); logbookService.logValidationError(errorsDetails, CONTRACT_UPDATE_EVENT, error.getErrors().get(0).getMessage()); return error; } DbRequestResult result = mongoAccess.updateData(queryDsl, FunctionalAdminCollections.MANAGEMENT_CONTRACT); updateDiffs = result.getDiffs(); response.addResult(new DbRequestResult(result)).setTotal(result.getTotal()).setQuery(queryDsl) .setHttpCode(Response.Status.OK.getStatusCode()); result.close(); functionalBackupService.saveCollectionAndSequence(eip, CONTRACT_BACKUP_EVENT, FunctionalAdminCollections.MANAGEMENT_CONTRACT, managementContractModel.getId()); logbookService.logUpdateSuccess(managementContractModel.getId(), identifier, updateDiffs.get(managementContractModel.getId())); return response; } catch (SchemaValidationException | BadRequestException exp) { LOGGER.error(exp); final String err = new StringBuilder("Update management contract error > ").append(exp.getMessage()) .toString(); logbookService.logValidationError(err, CONTRACT_UPDATE_EVENT, UPDATE_CONTRACT_BAD_REQUEST); return getVitamError(VitamCode.CONTRACT_VALIDATION_ERROR.getItem(), exp.getMessage(), StatusCode.KO) .setDescription(err).setHttpCode(Response.Status.BAD_REQUEST.getStatusCode()); } catch (Exception e) { LOGGER.error(e); final String err = new StringBuilder("Update management contract error > ").append(e.getMessage()) .toString(); logbookService.logFatalError(err, CONTRACT_UPDATE_EVENT); error.setCode(VitamCode.GLOBAL_INTERNAL_SERVER_ERROR.getItem()).setDescription(err) .setHttpCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); return error; } } ManagementContractImpl(MongoDbAccessAdminImpl mongoAccess, VitamCounterService vitamCounterService);  ManagementContractImpl(MongoDbAccessAdminImpl mongoAccess, VitamCounterService vitamCounterService,
            StorageClient storageClient, LogbookOperationsClient logbookOperationsClient,
            FunctionalBackupService functionalBackupService); }
ManagementContractImpl implements ContractService<ManagementContractModel> { @Override public RequestResponse<ManagementContractModel> updateContract(String identifier, JsonNode queryDsl) throws VitamException { VitamError error = getVitamError(VitamCode.CONTRACT_VALIDATION_ERROR.getItem(), "Management contract update error", StatusCode.KO) .setHttpCode(Response.Status.BAD_REQUEST.getStatusCode()); if (queryDsl == null || !queryDsl.isObject()) { return error; } final ManagementContractModel managementContractModel = findByIdentifier(identifier); if (managementContractModel == null) { error.setHttpCode(Response.Status.NOT_FOUND.getStatusCode()); return error.addToErrors(getVitamError(VitamCode.CONTRACT_VALIDATION_ERROR.getItem(), MANAGEMENT_CONTRACT_NOT_FOUND + identifier, StatusCode.KO).setMessage(UPDATE_CONTRACT_NOT_FOUND)); } String operationId = VitamThreadUtils.getVitamSession().getRequestId(); GUID eip = GUIDReader.getGUID(operationId); RequestResponseOK response = new RequestResponseOK<>(); ManagementContractValidationService validationService = new ManagementContractValidationService(storageClient, mongoAccess); ContractLogbookService logbookService = new ContractLogbookService(logbookClient,eip, CONTRACTS_IMPORT_EVENT, CONTRACT_UPDATE_EVENT, CONTRACT_KEY, CONTRACT_CHECK_KEY); logbookService.logUpdateStarted(managementContractModel.getId()); final JsonNode actionNode = queryDsl.get(BuilderToken.GLOBAL.ACTION.exactToken()); for (final JsonNode fieldToSet : actionNode) { final JsonNode fieldName = fieldToSet.get(BuilderToken.UPDATEACTION.SET.exactToken()); if (fieldName != null) { final Iterator<String> it = fieldName.fieldNames(); while (it.hasNext()) { final String field = it.next(); final JsonNode value = fieldName.findValue(field); validateUpdateAction(validationService, managementContractModel.getName(), error, field, value); } ((ObjectNode) fieldName).remove(AbstractContractModel.TAG_CREATION_DATE); ((ObjectNode) fieldName).put(AbstractContractModel.TAG_LAST_UPDATE, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); } } Map<String, List<String>> updateDiffs; try { if (error.getErrors() != null && !error.getErrors().isEmpty()) { final String errorsDetails = error.getErrors().stream().map(VitamError::getDescription) .collect(Collectors.joining(",")); logbookService.logValidationError(errorsDetails, CONTRACT_UPDATE_EVENT, error.getErrors().get(0).getMessage()); return error; } DbRequestResult result = mongoAccess.updateData(queryDsl, FunctionalAdminCollections.MANAGEMENT_CONTRACT); updateDiffs = result.getDiffs(); response.addResult(new DbRequestResult(result)).setTotal(result.getTotal()).setQuery(queryDsl) .setHttpCode(Response.Status.OK.getStatusCode()); result.close(); functionalBackupService.saveCollectionAndSequence(eip, CONTRACT_BACKUP_EVENT, FunctionalAdminCollections.MANAGEMENT_CONTRACT, managementContractModel.getId()); logbookService.logUpdateSuccess(managementContractModel.getId(), identifier, updateDiffs.get(managementContractModel.getId())); return response; } catch (SchemaValidationException | BadRequestException exp) { LOGGER.error(exp); final String err = new StringBuilder("Update management contract error > ").append(exp.getMessage()) .toString(); logbookService.logValidationError(err, CONTRACT_UPDATE_EVENT, UPDATE_CONTRACT_BAD_REQUEST); return getVitamError(VitamCode.CONTRACT_VALIDATION_ERROR.getItem(), exp.getMessage(), StatusCode.KO) .setDescription(err).setHttpCode(Response.Status.BAD_REQUEST.getStatusCode()); } catch (Exception e) { LOGGER.error(e); final String err = new StringBuilder("Update management contract error > ").append(e.getMessage()) .toString(); logbookService.logFatalError(err, CONTRACT_UPDATE_EVENT); error.setCode(VitamCode.GLOBAL_INTERNAL_SERVER_ERROR.getItem()).setDescription(err) .setHttpCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); return error; } } ManagementContractImpl(MongoDbAccessAdminImpl mongoAccess, VitamCounterService vitamCounterService);  ManagementContractImpl(MongoDbAccessAdminImpl mongoAccess, VitamCounterService vitamCounterService,
            StorageClient storageClient, LogbookOperationsClient logbookOperationsClient,
            FunctionalBackupService functionalBackupService); @Override RequestResponse<ManagementContractModel> createContracts(List<ManagementContractModel> contractModelList); @Override RequestResponse<ManagementContractModel> updateContract(String identifier, JsonNode queryDsl); @Override ManagementContractModel findByIdentifier(String identifier); @Override RequestResponseOK<ManagementContractModel> findContracts(JsonNode queryDsl); @Override void close(); }
ManagementContractImpl implements ContractService<ManagementContractModel> { @Override public RequestResponse<ManagementContractModel> updateContract(String identifier, JsonNode queryDsl) throws VitamException { VitamError error = getVitamError(VitamCode.CONTRACT_VALIDATION_ERROR.getItem(), "Management contract update error", StatusCode.KO) .setHttpCode(Response.Status.BAD_REQUEST.getStatusCode()); if (queryDsl == null || !queryDsl.isObject()) { return error; } final ManagementContractModel managementContractModel = findByIdentifier(identifier); if (managementContractModel == null) { error.setHttpCode(Response.Status.NOT_FOUND.getStatusCode()); return error.addToErrors(getVitamError(VitamCode.CONTRACT_VALIDATION_ERROR.getItem(), MANAGEMENT_CONTRACT_NOT_FOUND + identifier, StatusCode.KO).setMessage(UPDATE_CONTRACT_NOT_FOUND)); } String operationId = VitamThreadUtils.getVitamSession().getRequestId(); GUID eip = GUIDReader.getGUID(operationId); RequestResponseOK response = new RequestResponseOK<>(); ManagementContractValidationService validationService = new ManagementContractValidationService(storageClient, mongoAccess); ContractLogbookService logbookService = new ContractLogbookService(logbookClient,eip, CONTRACTS_IMPORT_EVENT, CONTRACT_UPDATE_EVENT, CONTRACT_KEY, CONTRACT_CHECK_KEY); logbookService.logUpdateStarted(managementContractModel.getId()); final JsonNode actionNode = queryDsl.get(BuilderToken.GLOBAL.ACTION.exactToken()); for (final JsonNode fieldToSet : actionNode) { final JsonNode fieldName = fieldToSet.get(BuilderToken.UPDATEACTION.SET.exactToken()); if (fieldName != null) { final Iterator<String> it = fieldName.fieldNames(); while (it.hasNext()) { final String field = it.next(); final JsonNode value = fieldName.findValue(field); validateUpdateAction(validationService, managementContractModel.getName(), error, field, value); } ((ObjectNode) fieldName).remove(AbstractContractModel.TAG_CREATION_DATE); ((ObjectNode) fieldName).put(AbstractContractModel.TAG_LAST_UPDATE, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); } } Map<String, List<String>> updateDiffs; try { if (error.getErrors() != null && !error.getErrors().isEmpty()) { final String errorsDetails = error.getErrors().stream().map(VitamError::getDescription) .collect(Collectors.joining(",")); logbookService.logValidationError(errorsDetails, CONTRACT_UPDATE_EVENT, error.getErrors().get(0).getMessage()); return error; } DbRequestResult result = mongoAccess.updateData(queryDsl, FunctionalAdminCollections.MANAGEMENT_CONTRACT); updateDiffs = result.getDiffs(); response.addResult(new DbRequestResult(result)).setTotal(result.getTotal()).setQuery(queryDsl) .setHttpCode(Response.Status.OK.getStatusCode()); result.close(); functionalBackupService.saveCollectionAndSequence(eip, CONTRACT_BACKUP_EVENT, FunctionalAdminCollections.MANAGEMENT_CONTRACT, managementContractModel.getId()); logbookService.logUpdateSuccess(managementContractModel.getId(), identifier, updateDiffs.get(managementContractModel.getId())); return response; } catch (SchemaValidationException | BadRequestException exp) { LOGGER.error(exp); final String err = new StringBuilder("Update management contract error > ").append(exp.getMessage()) .toString(); logbookService.logValidationError(err, CONTRACT_UPDATE_EVENT, UPDATE_CONTRACT_BAD_REQUEST); return getVitamError(VitamCode.CONTRACT_VALIDATION_ERROR.getItem(), exp.getMessage(), StatusCode.KO) .setDescription(err).setHttpCode(Response.Status.BAD_REQUEST.getStatusCode()); } catch (Exception e) { LOGGER.error(e); final String err = new StringBuilder("Update management contract error > ").append(e.getMessage()) .toString(); logbookService.logFatalError(err, CONTRACT_UPDATE_EVENT); error.setCode(VitamCode.GLOBAL_INTERNAL_SERVER_ERROR.getItem()).setDescription(err) .setHttpCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); return error; } } ManagementContractImpl(MongoDbAccessAdminImpl mongoAccess, VitamCounterService vitamCounterService);  ManagementContractImpl(MongoDbAccessAdminImpl mongoAccess, VitamCounterService vitamCounterService,
            StorageClient storageClient, LogbookOperationsClient logbookOperationsClient,
            FunctionalBackupService functionalBackupService); @Override RequestResponse<ManagementContractModel> createContracts(List<ManagementContractModel> contractModelList); @Override RequestResponse<ManagementContractModel> updateContract(String identifier, JsonNode queryDsl); @Override ManagementContractModel findByIdentifier(String identifier); @Override RequestResponseOK<ManagementContractModel> findContracts(JsonNode queryDsl); @Override void close(); static final String CONTRACT_BACKUP_EVENT; }