@Test @RunWithCustomExecutor public void givenInputstreamOKRulesFileWhenImportThenReturnOK() throws Exception { when(mock.post()).thenReturn(Response.status(Status.OK).build()); VitamThreadUtils.getVitamSession().setTenantId(TENANT_ID); try (AdminManagementClientRest client = (AdminManagementClientRest) vitamServerTestRunner .getClient()) { client.importRulesFile(new FakeInputStream(1), "jeu_donnees_KO_regles_CSV_StringToNumber.csv"); } }
@Override public Status importRulesFile(InputStream stream, String filename) throws ReferentialException, DatabaseConflictException { ParametersChecker.checkParameter("stream is a mandatory parameter", stream); VitamRequestBuilder request = post() .withPath(RULESMANAGER_IMPORT_URL) .withHeader(GlobalDataRest.X_FILENAME, filename) .withBody(stream) .withOctetContentType() .withJsonAccept(); try (Response response = make(request)) { checkWithSpecificException(response); return fromStatusCode(response.getStatus()); } catch (final VitamClientInternalException | AccessUnauthorizedException e) { throw new AdminManagementClientServerException(INTERNAL_SERVER_ERROR_MSG, e); } catch (BadRequestException e) { throw new FileRulesException(e); } catch (ForbiddenClientException e) { throw new FileRulesImportInProgressException(e); } catch (DatabaseConflictException e) { throw new DatabaseConflictException("Collection input conflic"); } }
AdminManagementClientRest extends DefaultClient implements AdminManagementClient { @Override public Status importRulesFile(InputStream stream, String filename) throws ReferentialException, DatabaseConflictException { ParametersChecker.checkParameter("stream is a mandatory parameter", stream); VitamRequestBuilder request = post() .withPath(RULESMANAGER_IMPORT_URL) .withHeader(GlobalDataRest.X_FILENAME, filename) .withBody(stream) .withOctetContentType() .withJsonAccept(); try (Response response = make(request)) { checkWithSpecificException(response); return fromStatusCode(response.getStatus()); } catch (final VitamClientInternalException | AccessUnauthorizedException e) { throw new AdminManagementClientServerException(INTERNAL_SERVER_ERROR_MSG, e); } catch (BadRequestException e) { throw new FileRulesException(e); } catch (ForbiddenClientException e) { throw new FileRulesImportInProgressException(e); } catch (DatabaseConflictException e) { throw new DatabaseConflictException("Collection input conflic"); } } }
AdminManagementClientRest extends DefaultClient implements AdminManagementClient { @Override public Status importRulesFile(InputStream stream, String filename) throws ReferentialException, DatabaseConflictException { ParametersChecker.checkParameter("stream is a mandatory parameter", stream); VitamRequestBuilder request = post() .withPath(RULESMANAGER_IMPORT_URL) .withHeader(GlobalDataRest.X_FILENAME, filename) .withBody(stream) .withOctetContentType() .withJsonAccept(); try (Response response = make(request)) { checkWithSpecificException(response); return fromStatusCode(response.getStatus()); } catch (final VitamClientInternalException | AccessUnauthorizedException e) { throw new AdminManagementClientServerException(INTERNAL_SERVER_ERROR_MSG, e); } catch (BadRequestException e) { throw new FileRulesException(e); } catch (ForbiddenClientException e) { throw new FileRulesImportInProgressException(e); } catch (DatabaseConflictException e) { throw new DatabaseConflictException("Collection input conflic"); } } AdminManagementClientRest(AdminManagementClientFactory factory); }
AdminManagementClientRest extends DefaultClient implements AdminManagementClient { @Override public Status importRulesFile(InputStream stream, String filename) throws ReferentialException, DatabaseConflictException { ParametersChecker.checkParameter("stream is a mandatory parameter", stream); VitamRequestBuilder request = post() .withPath(RULESMANAGER_IMPORT_URL) .withHeader(GlobalDataRest.X_FILENAME, filename) .withBody(stream) .withOctetContentType() .withJsonAccept(); try (Response response = make(request)) { checkWithSpecificException(response); return fromStatusCode(response.getStatus()); } catch (final VitamClientInternalException | AccessUnauthorizedException e) { throw new AdminManagementClientServerException(INTERNAL_SERVER_ERROR_MSG, e); } catch (BadRequestException e) { throw new FileRulesException(e); } catch (ForbiddenClientException e) { throw new FileRulesImportInProgressException(e); } catch (DatabaseConflictException e) { throw new DatabaseConflictException("Collection input conflic"); } } AdminManagementClientRest(AdminManagementClientFactory factory); @Override Response checkFormat(InputStream stream); @Override Status importFormat(InputStream stream, String filename); @Override JsonNode getFormatByID(String id); @Override RequestResponse<FileFormatModel> getFormats(JsonNode query); @Override Response checkRulesFile(InputStream stream); @Override Response checkAgenciesFile(InputStream stream); @Override Status importRulesFile(InputStream stream, String filename); @Override Status importAgenciesFile(InputStream stream, String filename); @Override JsonNode getAgencies(JsonNode query); @Override RequestResponse<AgenciesModel> getAgencyById(String id); @Override JsonNode getRuleByID(String id); @Override JsonNode getRules(JsonNode query); @Override RequestResponse createOrUpdateAccessionRegister(AccessionRegisterDetailModel register); @Override RequestResponse<AccessionRegisterSummaryModel> getAccessionRegister(JsonNode query); @Override RequestResponse<AccessionRegisterDetailModel> getAccessionRegisterDetail(String originatingAgency,
        JsonNode query); @Override RequestResponse<AccessionRegisterDetailModel> getAccessionRegisterDetail(JsonNode query); @Override Status importIngestContracts(List<IngestContractModel> ingestContractModelList); @Override Status importAccessContracts(List<AccessContractModel> accessContractModelList); @Override Status importManagementContracts(List<ManagementContractModel> managementContractModelList); @Override RequestResponse<AccessContractModel> findAccessContracts(JsonNode queryDsl); @Override RequestResponse<IngestContractModel> findIngestContracts(JsonNode queryDsl); @Override RequestResponse<ManagementContractModel> findManagementContracts(JsonNode queryDsl); @Override RequestResponse<AccessContractModel> findAccessContractsByID(String documentId); @Override RequestResponse<IngestContractModel> findIngestContractsByID(String documentId); @Override RequestResponse<ManagementContractModel> findManagementContractsByID(String documentId); @Override RequestResponse<AccessContractModel> updateAccessContract(String id, JsonNode queryDsl); @Override RequestResponse<IngestContractModel> updateIngestContract(String id, JsonNode queryDsl); @Override RequestResponse<ManagementContractModel> updateManagementContract(String id, JsonNode queryDsl); @Override RequestResponse createProfiles(List<ProfileModel> profileModelList); @Override RequestResponse importProfileFile(String profileMetadataId, InputStream stream); @Override Response downloadProfileFile(String profileMetadataId); @Override RequestResponse<ProfileModel> findProfiles(JsonNode queryDsl); @Override RequestResponse<ProfileModel> findProfilesByID(String documentId); @Override RequestResponse<ProfileModel> updateProfile(String id, JsonNode queryDsl); @Override RequestResponse createArchiveUnitProfiles(List<ArchiveUnitProfileModel> profileModelList); @Override RequestResponse<ArchiveUnitProfileModel> findArchiveUnitProfiles(JsonNode queryDsl); @Override RequestResponse<ArchiveUnitProfileModel> findArchiveUnitProfilesByID(String documentId); @Override RequestResponse<ArchiveUnitProfileModel> updateArchiveUnitProfile(String id, JsonNode queryDsl); @Override Status importContexts(List<ContextModel> contextModelList); @Override RequestResponse<ContextModel> updateContext(String id, JsonNode queryDsl); @Override RequestResponse<ContextModel> findContexts(JsonNode queryDsl); @Override RequestResponse<ContextModel> findContextById(String id); @Override RequestResponse<Boolean> securityProfileIsUsedInContexts(String securityProfileId); @Override RequestResponse<JsonNode> launchAuditWorkflow(AuditOptions options); @Override RequestResponse<JsonNode> launchRuleAudit(); @Override Status importSecurityProfiles(List<SecurityProfileModel> securityProfileModelList); @Override RequestResponse<SecurityProfileModel> findSecurityProfiles(JsonNode queryDsl); @Override RequestResponse<SecurityProfileModel> findSecurityProfileByIdentifier(String identifier); @Override RequestResponse updateSecurityProfile(String identifier, JsonNode queryDsl); @Override RequestResponse<IndexationResult> launchReindexation(JsonNode options); @Override RequestResponse<IndexationResult> switchIndexes(JsonNode options); @Override RequestResponse<JsonNode> evidenceAudit(JsonNode query); @Override RequestResponse<JsonNode> rectificationAudit(String operationId); @Override RequestResponse<JsonNode> exportProbativeValue(ProbativeValueRequest probativeValueRequest); @Override RequestResponse importOntologies(boolean forceUpdate, List<OntologyModel> ontologyModelList); @Override RequestResponse<OntologyModel> findOntologies(JsonNode query); @Override RequestResponse<OntologyModel> findOntologyByID(String documentId); @Override RequestResponse<ProcessPause> forcePause(ProcessPause info); @Override RequestResponse<ProcessPause> removeForcePause(ProcessPause info); @Override RequestResponse<AccessionRegisterSymbolic> createAccessionRegisterSymbolic(Integer tenant); @Override RequestResponse<List<AccessionRegisterSymbolicModel>> getAccessionRegisterSymbolic(Integer tenant,
        JsonNode queryDsl); @Override RequestResponse importGriffins(List<GriffinModel> griffinModelList); @Override RequestResponse importPreservationScenarios(List<PreservationScenarioModel> preservationScenarioModels); @Override RequestResponse<GriffinModel> findGriffin(JsonNode queryDsl); @Override RequestResponse<GriffinModel> findGriffinByID(String id); @Override RequestResponse<PreservationScenarioModel> findPreservationByID(String id); @Override RequestResponse<PreservationScenarioModel> findPreservation(JsonNode queryDsl); @Override Status createExternalOperation(LogbookOperationParameters logbookOperationparams); }
AdminManagementClientRest extends DefaultClient implements AdminManagementClient { @Override public Status importRulesFile(InputStream stream, String filename) throws ReferentialException, DatabaseConflictException { ParametersChecker.checkParameter("stream is a mandatory parameter", stream); VitamRequestBuilder request = post() .withPath(RULESMANAGER_IMPORT_URL) .withHeader(GlobalDataRest.X_FILENAME, filename) .withBody(stream) .withOctetContentType() .withJsonAccept(); try (Response response = make(request)) { checkWithSpecificException(response); return fromStatusCode(response.getStatus()); } catch (final VitamClientInternalException | AccessUnauthorizedException e) { throw new AdminManagementClientServerException(INTERNAL_SERVER_ERROR_MSG, e); } catch (BadRequestException e) { throw new FileRulesException(e); } catch (ForbiddenClientException e) { throw new FileRulesImportInProgressException(e); } catch (DatabaseConflictException e) { throw new DatabaseConflictException("Collection input conflic"); } } AdminManagementClientRest(AdminManagementClientFactory factory); @Override Response checkFormat(InputStream stream); @Override Status importFormat(InputStream stream, String filename); @Override JsonNode getFormatByID(String id); @Override RequestResponse<FileFormatModel> getFormats(JsonNode query); @Override Response checkRulesFile(InputStream stream); @Override Response checkAgenciesFile(InputStream stream); @Override Status importRulesFile(InputStream stream, String filename); @Override Status importAgenciesFile(InputStream stream, String filename); @Override JsonNode getAgencies(JsonNode query); @Override RequestResponse<AgenciesModel> getAgencyById(String id); @Override JsonNode getRuleByID(String id); @Override JsonNode getRules(JsonNode query); @Override RequestResponse createOrUpdateAccessionRegister(AccessionRegisterDetailModel register); @Override RequestResponse<AccessionRegisterSummaryModel> getAccessionRegister(JsonNode query); @Override RequestResponse<AccessionRegisterDetailModel> getAccessionRegisterDetail(String originatingAgency,
        JsonNode query); @Override RequestResponse<AccessionRegisterDetailModel> getAccessionRegisterDetail(JsonNode query); @Override Status importIngestContracts(List<IngestContractModel> ingestContractModelList); @Override Status importAccessContracts(List<AccessContractModel> accessContractModelList); @Override Status importManagementContracts(List<ManagementContractModel> managementContractModelList); @Override RequestResponse<AccessContractModel> findAccessContracts(JsonNode queryDsl); @Override RequestResponse<IngestContractModel> findIngestContracts(JsonNode queryDsl); @Override RequestResponse<ManagementContractModel> findManagementContracts(JsonNode queryDsl); @Override RequestResponse<AccessContractModel> findAccessContractsByID(String documentId); @Override RequestResponse<IngestContractModel> findIngestContractsByID(String documentId); @Override RequestResponse<ManagementContractModel> findManagementContractsByID(String documentId); @Override RequestResponse<AccessContractModel> updateAccessContract(String id, JsonNode queryDsl); @Override RequestResponse<IngestContractModel> updateIngestContract(String id, JsonNode queryDsl); @Override RequestResponse<ManagementContractModel> updateManagementContract(String id, JsonNode queryDsl); @Override RequestResponse createProfiles(List<ProfileModel> profileModelList); @Override RequestResponse importProfileFile(String profileMetadataId, InputStream stream); @Override Response downloadProfileFile(String profileMetadataId); @Override RequestResponse<ProfileModel> findProfiles(JsonNode queryDsl); @Override RequestResponse<ProfileModel> findProfilesByID(String documentId); @Override RequestResponse<ProfileModel> updateProfile(String id, JsonNode queryDsl); @Override RequestResponse createArchiveUnitProfiles(List<ArchiveUnitProfileModel> profileModelList); @Override RequestResponse<ArchiveUnitProfileModel> findArchiveUnitProfiles(JsonNode queryDsl); @Override RequestResponse<ArchiveUnitProfileModel> findArchiveUnitProfilesByID(String documentId); @Override RequestResponse<ArchiveUnitProfileModel> updateArchiveUnitProfile(String id, JsonNode queryDsl); @Override Status importContexts(List<ContextModel> contextModelList); @Override RequestResponse<ContextModel> updateContext(String id, JsonNode queryDsl); @Override RequestResponse<ContextModel> findContexts(JsonNode queryDsl); @Override RequestResponse<ContextModel> findContextById(String id); @Override RequestResponse<Boolean> securityProfileIsUsedInContexts(String securityProfileId); @Override RequestResponse<JsonNode> launchAuditWorkflow(AuditOptions options); @Override RequestResponse<JsonNode> launchRuleAudit(); @Override Status importSecurityProfiles(List<SecurityProfileModel> securityProfileModelList); @Override RequestResponse<SecurityProfileModel> findSecurityProfiles(JsonNode queryDsl); @Override RequestResponse<SecurityProfileModel> findSecurityProfileByIdentifier(String identifier); @Override RequestResponse updateSecurityProfile(String identifier, JsonNode queryDsl); @Override RequestResponse<IndexationResult> launchReindexation(JsonNode options); @Override RequestResponse<IndexationResult> switchIndexes(JsonNode options); @Override RequestResponse<JsonNode> evidenceAudit(JsonNode query); @Override RequestResponse<JsonNode> rectificationAudit(String operationId); @Override RequestResponse<JsonNode> exportProbativeValue(ProbativeValueRequest probativeValueRequest); @Override RequestResponse importOntologies(boolean forceUpdate, List<OntologyModel> ontologyModelList); @Override RequestResponse<OntologyModel> findOntologies(JsonNode query); @Override RequestResponse<OntologyModel> findOntologyByID(String documentId); @Override RequestResponse<ProcessPause> forcePause(ProcessPause info); @Override RequestResponse<ProcessPause> removeForcePause(ProcessPause info); @Override RequestResponse<AccessionRegisterSymbolic> createAccessionRegisterSymbolic(Integer tenant); @Override RequestResponse<List<AccessionRegisterSymbolicModel>> getAccessionRegisterSymbolic(Integer tenant,
        JsonNode queryDsl); @Override RequestResponse importGriffins(List<GriffinModel> griffinModelList); @Override RequestResponse importPreservationScenarios(List<PreservationScenarioModel> preservationScenarioModels); @Override RequestResponse<GriffinModel> findGriffin(JsonNode queryDsl); @Override RequestResponse<GriffinModel> findGriffinByID(String id); @Override RequestResponse<PreservationScenarioModel> findPreservationByID(String id); @Override RequestResponse<PreservationScenarioModel> findPreservation(JsonNode queryDsl); @Override Status createExternalOperation(LogbookOperationParameters logbookOperationparams);  }