@Test @RunWithCustomExecutor public void testNoImportInProgess() throws Exception { int tenantId = 2; VitamThreadUtils.getVitamSession().setTenantId(tenantId); when(logbookOperationsClient.selectOperation(any())).thenReturn(getJsonResult(STP_IMPORT_RULES, tenantId)); VitamThreadUtils.getVitamSession().setRequestId(GUIDFactory.newOperationLogbookGUID(tenantId)); rulesFileManager.importFile(new FileInputStream(PropertiesUtils.findFile(FILE_TO_TEST_OK)), FILE_TO_TEST_OK); VitamThreadUtils.getVitamSession().setTenantId(tenantId); when(logbookOperationsClient.selectOperation(any())).thenReturn(getEmptyJsonResponse()); VitamThreadUtils.getVitamSession().setRequestId(GUIDFactory.newOperationLogbookGUID(tenantId)); rulesFileManager.importFile(new FileInputStream(PropertiesUtils.findFile(FILE_TO_TEST_OK)), FILE_TO_TEST_OK); }
@Override public void importFile(InputStream rulesFileStream, String filename) throws IOException, InvalidParseOperationException, ReferentialException, StorageException, InvalidGuidOperationException { ParametersChecker.checkParameter(RULES_FILE_STREAMIS_A_MANDATORY_PARAMETER, rulesFileStream); File file = convertInputStreamToFile(rulesFileStream, CSV); Map<Integer, List<ErrorReport>> errors = new HashMap<>(); List<FileRulesModel> usedDeletedRulesForReport = new ArrayList<>(); List<FileRulesModel> usedUpdateRulesForReport = new ArrayList<>(); List<FileRulesModel> usedUpdateRulesForUpdateUnit = new ArrayList<>(); Set<String> notUsedDeletedRulesForReport = new HashSet<>(); Set<String> notUsedUpdateRulesForReport = new HashSet<>(); List<FileRulesModel> fileRulesModelToInsert = new ArrayList<>(); List<FileRulesModel> fileRulesModelToDelete = new ArrayList<>(); List<FileRulesModel> fileRulesModelToUpdate = new ArrayList<>(); List<FileRulesModel> fileRulesModelToUpdateThenUpdateUnit = new ArrayList<>(); List<FileRulesModel> fileRulesModelsToImport = new ArrayList<>(); ArrayNode validatedRules = JsonHandler.createArrayNode(); final GUID eip = GUIDReader.getGUID(VitamThreadUtils.getVitamSession().getRequestId()); final GUID eip1 = GUIDFactory.newEventGUID(eip); try { initStpImportRulesLogbookOperation(eip); if (!isImportOperationInProgress()) { validatedRules = checkFile(new FileInputStream(file), errors, usedDeletedRulesForReport, usedUpdateRulesForReport, usedUpdateRulesForUpdateUnit, fileRulesModelToInsert, notUsedDeletedRulesForReport, notUsedUpdateRulesForReport); if (validatedRules != null) { fileRulesModelToInsert.clear(); generateReportCommitAndSecureFileRules(file, eip, eip1, notUsedDeletedRulesForReport, fileRulesModelToInsert, fileRulesModelToDelete, fileRulesModelToUpdate, fileRulesModelToUpdateThenUpdateUnit, validatedRules, errors, filename); } } else { throw new FileRulesImportInProgressException(RULES_PROCESS_IMPORT_ALREADY_EXIST); } } catch (FileRulesDeleteException e) { generateReportWhenFileRulesDeletedExceptionAppend(file, errors, eip, eip1, usedDeletedRulesForReport, usedUpdateRulesForReport, notUsedDeletedRulesForReport, fileRulesModelToInsert, fileRulesModelToDelete, fileRulesModelToUpdate, fileRulesModelsToImport, validatedRules, filename); throw e; } catch (FileRulesUpdateException e) { generateReportWhenFileRulesUpdatedExceptionAppend(file, errors, eip, eip1, usedDeletedRulesForReport, usedUpdateRulesForReport, notUsedDeletedRulesForReport, fileRulesModelToInsert, fileRulesModelToDelete, fileRulesModelsToImport, usedUpdateRulesForUpdateUnit, validatedRules, filename); } catch (FileRulesCsvException e) { updateCheckFileRulesLogbookOperationWhenCheckBeforeImportIsKo(CHECK_RULES_INVALID_CSV, eip); generateReport(errors, eip, usedDeletedRulesForReport, usedUpdateRulesForReport); updateStpImportRulesLogbookOperation(eip, eip1, StatusCode.KO, filename); throw e; } catch (FileRulesDurationException e) { alertService.createAlert(RULE_DURATION_EXCEED); updateCheckFileRulesLogbookOperationWhenCheckBeforeImportIsKo(MAX_DURATION_EXCEEDS, eip); generateReport(errors, eip, usedDeletedRulesForReport, usedUpdateRulesForReport); updateStpImportRulesLogbookOperation(eip, eip1, StatusCode.KO, filename); throw e; } catch (IOException e) { handleIOException(filename, errors, usedDeletedRulesForReport, usedUpdateRulesForReport, eip, eip1, e); throw e; } catch (FileRulesImportInProgressException e) { updateCheckFileRulesLogbookOperationWhenCheckBeforeImportIsKo(CHECK_RULES_IMPORT_IN_PROCESS, eip); updateStpImportRulesLogbookOperation(eip, eip1, StatusCode.KO, filename); throw new FileRulesImportInProgressException(RULES_PROCESS_IMPORT_ALREADY_EXIST); } catch (LogbookClientException e) { throw new FileRulesException(e); } finally { Files.delete(file.toPath()); } }
RulesManagerFileImpl implements ReferentialFile<FileRules> { @Override public void importFile(InputStream rulesFileStream, String filename) throws IOException, InvalidParseOperationException, ReferentialException, StorageException, InvalidGuidOperationException { ParametersChecker.checkParameter(RULES_FILE_STREAMIS_A_MANDATORY_PARAMETER, rulesFileStream); File file = convertInputStreamToFile(rulesFileStream, CSV); Map<Integer, List<ErrorReport>> errors = new HashMap<>(); List<FileRulesModel> usedDeletedRulesForReport = new ArrayList<>(); List<FileRulesModel> usedUpdateRulesForReport = new ArrayList<>(); List<FileRulesModel> usedUpdateRulesForUpdateUnit = new ArrayList<>(); Set<String> notUsedDeletedRulesForReport = new HashSet<>(); Set<String> notUsedUpdateRulesForReport = new HashSet<>(); List<FileRulesModel> fileRulesModelToInsert = new ArrayList<>(); List<FileRulesModel> fileRulesModelToDelete = new ArrayList<>(); List<FileRulesModel> fileRulesModelToUpdate = new ArrayList<>(); List<FileRulesModel> fileRulesModelToUpdateThenUpdateUnit = new ArrayList<>(); List<FileRulesModel> fileRulesModelsToImport = new ArrayList<>(); ArrayNode validatedRules = JsonHandler.createArrayNode(); final GUID eip = GUIDReader.getGUID(VitamThreadUtils.getVitamSession().getRequestId()); final GUID eip1 = GUIDFactory.newEventGUID(eip); try { initStpImportRulesLogbookOperation(eip); if (!isImportOperationInProgress()) { validatedRules = checkFile(new FileInputStream(file), errors, usedDeletedRulesForReport, usedUpdateRulesForReport, usedUpdateRulesForUpdateUnit, fileRulesModelToInsert, notUsedDeletedRulesForReport, notUsedUpdateRulesForReport); if (validatedRules != null) { fileRulesModelToInsert.clear(); generateReportCommitAndSecureFileRules(file, eip, eip1, notUsedDeletedRulesForReport, fileRulesModelToInsert, fileRulesModelToDelete, fileRulesModelToUpdate, fileRulesModelToUpdateThenUpdateUnit, validatedRules, errors, filename); } } else { throw new FileRulesImportInProgressException(RULES_PROCESS_IMPORT_ALREADY_EXIST); } } catch (FileRulesDeleteException e) { generateReportWhenFileRulesDeletedExceptionAppend(file, errors, eip, eip1, usedDeletedRulesForReport, usedUpdateRulesForReport, notUsedDeletedRulesForReport, fileRulesModelToInsert, fileRulesModelToDelete, fileRulesModelToUpdate, fileRulesModelsToImport, validatedRules, filename); throw e; } catch (FileRulesUpdateException e) { generateReportWhenFileRulesUpdatedExceptionAppend(file, errors, eip, eip1, usedDeletedRulesForReport, usedUpdateRulesForReport, notUsedDeletedRulesForReport, fileRulesModelToInsert, fileRulesModelToDelete, fileRulesModelsToImport, usedUpdateRulesForUpdateUnit, validatedRules, filename); } catch (FileRulesCsvException e) { updateCheckFileRulesLogbookOperationWhenCheckBeforeImportIsKo(CHECK_RULES_INVALID_CSV, eip); generateReport(errors, eip, usedDeletedRulesForReport, usedUpdateRulesForReport); updateStpImportRulesLogbookOperation(eip, eip1, StatusCode.KO, filename); throw e; } catch (FileRulesDurationException e) { alertService.createAlert(RULE_DURATION_EXCEED); updateCheckFileRulesLogbookOperationWhenCheckBeforeImportIsKo(MAX_DURATION_EXCEEDS, eip); generateReport(errors, eip, usedDeletedRulesForReport, usedUpdateRulesForReport); updateStpImportRulesLogbookOperation(eip, eip1, StatusCode.KO, filename); throw e; } catch (IOException e) { handleIOException(filename, errors, usedDeletedRulesForReport, usedUpdateRulesForReport, eip, eip1, e); throw e; } catch (FileRulesImportInProgressException e) { updateCheckFileRulesLogbookOperationWhenCheckBeforeImportIsKo(CHECK_RULES_IMPORT_IN_PROCESS, eip); updateStpImportRulesLogbookOperation(eip, eip1, StatusCode.KO, filename); throw new FileRulesImportInProgressException(RULES_PROCESS_IMPORT_ALREADY_EXIST); } catch (LogbookClientException e) { throw new FileRulesException(e); } finally { Files.delete(file.toPath()); } } }
RulesManagerFileImpl implements ReferentialFile<FileRules> { @Override public void importFile(InputStream rulesFileStream, String filename) throws IOException, InvalidParseOperationException, ReferentialException, StorageException, InvalidGuidOperationException { ParametersChecker.checkParameter(RULES_FILE_STREAMIS_A_MANDATORY_PARAMETER, rulesFileStream); File file = convertInputStreamToFile(rulesFileStream, CSV); Map<Integer, List<ErrorReport>> errors = new HashMap<>(); List<FileRulesModel> usedDeletedRulesForReport = new ArrayList<>(); List<FileRulesModel> usedUpdateRulesForReport = new ArrayList<>(); List<FileRulesModel> usedUpdateRulesForUpdateUnit = new ArrayList<>(); Set<String> notUsedDeletedRulesForReport = new HashSet<>(); Set<String> notUsedUpdateRulesForReport = new HashSet<>(); List<FileRulesModel> fileRulesModelToInsert = new ArrayList<>(); List<FileRulesModel> fileRulesModelToDelete = new ArrayList<>(); List<FileRulesModel> fileRulesModelToUpdate = new ArrayList<>(); List<FileRulesModel> fileRulesModelToUpdateThenUpdateUnit = new ArrayList<>(); List<FileRulesModel> fileRulesModelsToImport = new ArrayList<>(); ArrayNode validatedRules = JsonHandler.createArrayNode(); final GUID eip = GUIDReader.getGUID(VitamThreadUtils.getVitamSession().getRequestId()); final GUID eip1 = GUIDFactory.newEventGUID(eip); try { initStpImportRulesLogbookOperation(eip); if (!isImportOperationInProgress()) { validatedRules = checkFile(new FileInputStream(file), errors, usedDeletedRulesForReport, usedUpdateRulesForReport, usedUpdateRulesForUpdateUnit, fileRulesModelToInsert, notUsedDeletedRulesForReport, notUsedUpdateRulesForReport); if (validatedRules != null) { fileRulesModelToInsert.clear(); generateReportCommitAndSecureFileRules(file, eip, eip1, notUsedDeletedRulesForReport, fileRulesModelToInsert, fileRulesModelToDelete, fileRulesModelToUpdate, fileRulesModelToUpdateThenUpdateUnit, validatedRules, errors, filename); } } else { throw new FileRulesImportInProgressException(RULES_PROCESS_IMPORT_ALREADY_EXIST); } } catch (FileRulesDeleteException e) { generateReportWhenFileRulesDeletedExceptionAppend(file, errors, eip, eip1, usedDeletedRulesForReport, usedUpdateRulesForReport, notUsedDeletedRulesForReport, fileRulesModelToInsert, fileRulesModelToDelete, fileRulesModelToUpdate, fileRulesModelsToImport, validatedRules, filename); throw e; } catch (FileRulesUpdateException e) { generateReportWhenFileRulesUpdatedExceptionAppend(file, errors, eip, eip1, usedDeletedRulesForReport, usedUpdateRulesForReport, notUsedDeletedRulesForReport, fileRulesModelToInsert, fileRulesModelToDelete, fileRulesModelsToImport, usedUpdateRulesForUpdateUnit, validatedRules, filename); } catch (FileRulesCsvException e) { updateCheckFileRulesLogbookOperationWhenCheckBeforeImportIsKo(CHECK_RULES_INVALID_CSV, eip); generateReport(errors, eip, usedDeletedRulesForReport, usedUpdateRulesForReport); updateStpImportRulesLogbookOperation(eip, eip1, StatusCode.KO, filename); throw e; } catch (FileRulesDurationException e) { alertService.createAlert(RULE_DURATION_EXCEED); updateCheckFileRulesLogbookOperationWhenCheckBeforeImportIsKo(MAX_DURATION_EXCEEDS, eip); generateReport(errors, eip, usedDeletedRulesForReport, usedUpdateRulesForReport); updateStpImportRulesLogbookOperation(eip, eip1, StatusCode.KO, filename); throw e; } catch (IOException e) { handleIOException(filename, errors, usedDeletedRulesForReport, usedUpdateRulesForReport, eip, eip1, e); throw e; } catch (FileRulesImportInProgressException e) { updateCheckFileRulesLogbookOperationWhenCheckBeforeImportIsKo(CHECK_RULES_IMPORT_IN_PROCESS, eip); updateStpImportRulesLogbookOperation(eip, eip1, StatusCode.KO, filename); throw new FileRulesImportInProgressException(RULES_PROCESS_IMPORT_ALREADY_EXIST); } catch (LogbookClientException e) { throw new FileRulesException(e); } finally { Files.delete(file.toPath()); } } RulesManagerFileImpl(MongoDbAccessAdminImpl dbConfiguration, VitamCounterService vitamCounterService,
        OntologyLoader ontologyLoader, VitamRuleService vitamRuleService); @VisibleForTesting  RulesManagerFileImpl(MongoDbAccessAdminImpl dbConfiguration,
        VitamCounterService vitamCounterService,
        FunctionalBackupService backupService, LogbookOperationsClientFactory logbookOperationsClientFactory,
        MetaDataClientFactory metaDataClientFactory,
        ProcessingManagementClientFactory processingManagementClientFactory,
        WorkspaceClientFactory workspaceClientFactory,
        OntologyLoader ontologyLoader,
        VitamRuleService vitamRuleService); }
RulesManagerFileImpl implements ReferentialFile<FileRules> { @Override public void importFile(InputStream rulesFileStream, String filename) throws IOException, InvalidParseOperationException, ReferentialException, StorageException, InvalidGuidOperationException { ParametersChecker.checkParameter(RULES_FILE_STREAMIS_A_MANDATORY_PARAMETER, rulesFileStream); File file = convertInputStreamToFile(rulesFileStream, CSV); Map<Integer, List<ErrorReport>> errors = new HashMap<>(); List<FileRulesModel> usedDeletedRulesForReport = new ArrayList<>(); List<FileRulesModel> usedUpdateRulesForReport = new ArrayList<>(); List<FileRulesModel> usedUpdateRulesForUpdateUnit = new ArrayList<>(); Set<String> notUsedDeletedRulesForReport = new HashSet<>(); Set<String> notUsedUpdateRulesForReport = new HashSet<>(); List<FileRulesModel> fileRulesModelToInsert = new ArrayList<>(); List<FileRulesModel> fileRulesModelToDelete = new ArrayList<>(); List<FileRulesModel> fileRulesModelToUpdate = new ArrayList<>(); List<FileRulesModel> fileRulesModelToUpdateThenUpdateUnit = new ArrayList<>(); List<FileRulesModel> fileRulesModelsToImport = new ArrayList<>(); ArrayNode validatedRules = JsonHandler.createArrayNode(); final GUID eip = GUIDReader.getGUID(VitamThreadUtils.getVitamSession().getRequestId()); final GUID eip1 = GUIDFactory.newEventGUID(eip); try { initStpImportRulesLogbookOperation(eip); if (!isImportOperationInProgress()) { validatedRules = checkFile(new FileInputStream(file), errors, usedDeletedRulesForReport, usedUpdateRulesForReport, usedUpdateRulesForUpdateUnit, fileRulesModelToInsert, notUsedDeletedRulesForReport, notUsedUpdateRulesForReport); if (validatedRules != null) { fileRulesModelToInsert.clear(); generateReportCommitAndSecureFileRules(file, eip, eip1, notUsedDeletedRulesForReport, fileRulesModelToInsert, fileRulesModelToDelete, fileRulesModelToUpdate, fileRulesModelToUpdateThenUpdateUnit, validatedRules, errors, filename); } } else { throw new FileRulesImportInProgressException(RULES_PROCESS_IMPORT_ALREADY_EXIST); } } catch (FileRulesDeleteException e) { generateReportWhenFileRulesDeletedExceptionAppend(file, errors, eip, eip1, usedDeletedRulesForReport, usedUpdateRulesForReport, notUsedDeletedRulesForReport, fileRulesModelToInsert, fileRulesModelToDelete, fileRulesModelToUpdate, fileRulesModelsToImport, validatedRules, filename); throw e; } catch (FileRulesUpdateException e) { generateReportWhenFileRulesUpdatedExceptionAppend(file, errors, eip, eip1, usedDeletedRulesForReport, usedUpdateRulesForReport, notUsedDeletedRulesForReport, fileRulesModelToInsert, fileRulesModelToDelete, fileRulesModelsToImport, usedUpdateRulesForUpdateUnit, validatedRules, filename); } catch (FileRulesCsvException e) { updateCheckFileRulesLogbookOperationWhenCheckBeforeImportIsKo(CHECK_RULES_INVALID_CSV, eip); generateReport(errors, eip, usedDeletedRulesForReport, usedUpdateRulesForReport); updateStpImportRulesLogbookOperation(eip, eip1, StatusCode.KO, filename); throw e; } catch (FileRulesDurationException e) { alertService.createAlert(RULE_DURATION_EXCEED); updateCheckFileRulesLogbookOperationWhenCheckBeforeImportIsKo(MAX_DURATION_EXCEEDS, eip); generateReport(errors, eip, usedDeletedRulesForReport, usedUpdateRulesForReport); updateStpImportRulesLogbookOperation(eip, eip1, StatusCode.KO, filename); throw e; } catch (IOException e) { handleIOException(filename, errors, usedDeletedRulesForReport, usedUpdateRulesForReport, eip, eip1, e); throw e; } catch (FileRulesImportInProgressException e) { updateCheckFileRulesLogbookOperationWhenCheckBeforeImportIsKo(CHECK_RULES_IMPORT_IN_PROCESS, eip); updateStpImportRulesLogbookOperation(eip, eip1, StatusCode.KO, filename); throw new FileRulesImportInProgressException(RULES_PROCESS_IMPORT_ALREADY_EXIST); } catch (LogbookClientException e) { throw new FileRulesException(e); } finally { Files.delete(file.toPath()); } } RulesManagerFileImpl(MongoDbAccessAdminImpl dbConfiguration, VitamCounterService vitamCounterService,
        OntologyLoader ontologyLoader, VitamRuleService vitamRuleService); @VisibleForTesting  RulesManagerFileImpl(MongoDbAccessAdminImpl dbConfiguration,
        VitamCounterService vitamCounterService,
        FunctionalBackupService backupService, LogbookOperationsClientFactory logbookOperationsClientFactory,
        MetaDataClientFactory metaDataClientFactory,
        ProcessingManagementClientFactory processingManagementClientFactory,
        WorkspaceClientFactory workspaceClientFactory,
        OntologyLoader ontologyLoader,
        VitamRuleService vitamRuleService); @Override void importFile(InputStream rulesFileStream, String filename); ArrayNode checkFile(InputStream rulesFileStream, Map<Integer, List<ErrorReport>> errorsMap,
        List<FileRulesModel> usedDeletedRules, List<FileRulesModel> usedUpdatedRules,
        List<FileRulesModel> usedUpdateRulesForUpdateUnit, List<FileRulesModel> insertRules,
        Set<String> notUsedDeletedRules, Set<String> notUsedUpdatedRules); @Override FileRules findDocumentById(String id); @Override RequestResponseOK<FileRules> findDocuments(JsonNode select); InputStream generateErrorReport(Map<Integer, List<ErrorReport>> errors,
        List<FileRulesModel> usedDeletedRules, List<FileRulesModel> usedUpdatedRules,
        StatusCode status, GUID eipMaster); ArrayNode getRuleFromCollection(int tenant); ArrayNode getRuleFromOffer(int tenant); boolean checkRuleConformity(ArrayNode array1, ArrayNode array2, int tenant); }
RulesManagerFileImpl implements ReferentialFile<FileRules> { @Override public void importFile(InputStream rulesFileStream, String filename) throws IOException, InvalidParseOperationException, ReferentialException, StorageException, InvalidGuidOperationException { ParametersChecker.checkParameter(RULES_FILE_STREAMIS_A_MANDATORY_PARAMETER, rulesFileStream); File file = convertInputStreamToFile(rulesFileStream, CSV); Map<Integer, List<ErrorReport>> errors = new HashMap<>(); List<FileRulesModel> usedDeletedRulesForReport = new ArrayList<>(); List<FileRulesModel> usedUpdateRulesForReport = new ArrayList<>(); List<FileRulesModel> usedUpdateRulesForUpdateUnit = new ArrayList<>(); Set<String> notUsedDeletedRulesForReport = new HashSet<>(); Set<String> notUsedUpdateRulesForReport = new HashSet<>(); List<FileRulesModel> fileRulesModelToInsert = new ArrayList<>(); List<FileRulesModel> fileRulesModelToDelete = new ArrayList<>(); List<FileRulesModel> fileRulesModelToUpdate = new ArrayList<>(); List<FileRulesModel> fileRulesModelToUpdateThenUpdateUnit = new ArrayList<>(); List<FileRulesModel> fileRulesModelsToImport = new ArrayList<>(); ArrayNode validatedRules = JsonHandler.createArrayNode(); final GUID eip = GUIDReader.getGUID(VitamThreadUtils.getVitamSession().getRequestId()); final GUID eip1 = GUIDFactory.newEventGUID(eip); try { initStpImportRulesLogbookOperation(eip); if (!isImportOperationInProgress()) { validatedRules = checkFile(new FileInputStream(file), errors, usedDeletedRulesForReport, usedUpdateRulesForReport, usedUpdateRulesForUpdateUnit, fileRulesModelToInsert, notUsedDeletedRulesForReport, notUsedUpdateRulesForReport); if (validatedRules != null) { fileRulesModelToInsert.clear(); generateReportCommitAndSecureFileRules(file, eip, eip1, notUsedDeletedRulesForReport, fileRulesModelToInsert, fileRulesModelToDelete, fileRulesModelToUpdate, fileRulesModelToUpdateThenUpdateUnit, validatedRules, errors, filename); } } else { throw new FileRulesImportInProgressException(RULES_PROCESS_IMPORT_ALREADY_EXIST); } } catch (FileRulesDeleteException e) { generateReportWhenFileRulesDeletedExceptionAppend(file, errors, eip, eip1, usedDeletedRulesForReport, usedUpdateRulesForReport, notUsedDeletedRulesForReport, fileRulesModelToInsert, fileRulesModelToDelete, fileRulesModelToUpdate, fileRulesModelsToImport, validatedRules, filename); throw e; } catch (FileRulesUpdateException e) { generateReportWhenFileRulesUpdatedExceptionAppend(file, errors, eip, eip1, usedDeletedRulesForReport, usedUpdateRulesForReport, notUsedDeletedRulesForReport, fileRulesModelToInsert, fileRulesModelToDelete, fileRulesModelsToImport, usedUpdateRulesForUpdateUnit, validatedRules, filename); } catch (FileRulesCsvException e) { updateCheckFileRulesLogbookOperationWhenCheckBeforeImportIsKo(CHECK_RULES_INVALID_CSV, eip); generateReport(errors, eip, usedDeletedRulesForReport, usedUpdateRulesForReport); updateStpImportRulesLogbookOperation(eip, eip1, StatusCode.KO, filename); throw e; } catch (FileRulesDurationException e) { alertService.createAlert(RULE_DURATION_EXCEED); updateCheckFileRulesLogbookOperationWhenCheckBeforeImportIsKo(MAX_DURATION_EXCEEDS, eip); generateReport(errors, eip, usedDeletedRulesForReport, usedUpdateRulesForReport); updateStpImportRulesLogbookOperation(eip, eip1, StatusCode.KO, filename); throw e; } catch (IOException e) { handleIOException(filename, errors, usedDeletedRulesForReport, usedUpdateRulesForReport, eip, eip1, e); throw e; } catch (FileRulesImportInProgressException e) { updateCheckFileRulesLogbookOperationWhenCheckBeforeImportIsKo(CHECK_RULES_IMPORT_IN_PROCESS, eip); updateStpImportRulesLogbookOperation(eip, eip1, StatusCode.KO, filename); throw new FileRulesImportInProgressException(RULES_PROCESS_IMPORT_ALREADY_EXIST); } catch (LogbookClientException e) { throw new FileRulesException(e); } finally { Files.delete(file.toPath()); } } RulesManagerFileImpl(MongoDbAccessAdminImpl dbConfiguration, VitamCounterService vitamCounterService,
        OntologyLoader ontologyLoader, VitamRuleService vitamRuleService); @VisibleForTesting  RulesManagerFileImpl(MongoDbAccessAdminImpl dbConfiguration,
        VitamCounterService vitamCounterService,
        FunctionalBackupService backupService, LogbookOperationsClientFactory logbookOperationsClientFactory,
        MetaDataClientFactory metaDataClientFactory,
        ProcessingManagementClientFactory processingManagementClientFactory,
        WorkspaceClientFactory workspaceClientFactory,
        OntologyLoader ontologyLoader,
        VitamRuleService vitamRuleService); @Override void importFile(InputStream rulesFileStream, String filename); ArrayNode checkFile(InputStream rulesFileStream, Map<Integer, List<ErrorReport>> errorsMap,
        List<FileRulesModel> usedDeletedRules, List<FileRulesModel> usedUpdatedRules,
        List<FileRulesModel> usedUpdateRulesForUpdateUnit, List<FileRulesModel> insertRules,
        Set<String> notUsedDeletedRules, Set<String> notUsedUpdatedRules); @Override FileRules findDocumentById(String id); @Override RequestResponseOK<FileRules> findDocuments(JsonNode select); InputStream generateErrorReport(Map<Integer, List<ErrorReport>> errors,
        List<FileRulesModel> usedDeletedRules, List<FileRulesModel> usedUpdatedRules,
        StatusCode status, GUID eipMaster); ArrayNode getRuleFromCollection(int tenant); ArrayNode getRuleFromOffer(int tenant); boolean checkRuleConformity(ArrayNode array1, ArrayNode array2, int tenant);  }