From b0dfe5306c56984760489e6090fc29bbab7693dc Mon Sep 17 00:00:00 2001 From: Phil Schneider Date: Wed, 14 Aug 2024 11:51:03 +0200 Subject: [PATCH] feat: adjust usage of httpClientFactory Refs: #901 --- .../BusinessLogic/CompanyDataBusinessLogic.cs | 2 +- .../BusinessLogic/InvitationBusinessLogic.cs | 2 +- .../BusinessLogic/NetworkBusinessLogic.cs | 2 +- .../BusinessLogic/RegistrationBusinessLogic.cs | 8 ++++---- src/externalsystems/Bpdm.Library/BpnAccess.cs | 6 +++--- .../Apps.Service/BusinessLogic/AppReleaseBusinessLogic.cs | 4 ++-- .../Apps.Service/BusinessLogic/AppsBusinessLogic.cs | 2 +- .../BusinessLogic/ServiceBusinessLogic.cs | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/administration/Administration.Service/BusinessLogic/CompanyDataBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/CompanyDataBusinessLogic.cs index 0cf42b585b..e2d41cff73 100644 --- a/src/administration/Administration.Service/BusinessLogic/CompanyDataBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/CompanyDataBusinessLogic.cs @@ -268,7 +268,7 @@ public async Task CreateCompanyCertificate(CompanyCertificateCreationData data, if (data.Issuer != null && !data.Issuer.IsValidCompanyName()) { - throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new("name", nameof(data.Issuer))]); + throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new ErrorParameter("name", nameof(data.Issuer))]); } var documentContentType = data.Document.ContentType.ParseMediaTypeId(); diff --git a/src/administration/Administration.Service/BusinessLogic/InvitationBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/InvitationBusinessLogic.cs index 49bb0bca7d..99b20360ba 100644 --- a/src/administration/Administration.Service/BusinessLogic/InvitationBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/InvitationBusinessLogic.cs @@ -50,7 +50,7 @@ public Task ExecuteInvitation(CompanyInvitationData invitationData) if (invitationData.OrganisationName == null || !invitationData.OrganisationName.IsValidCompanyName()) { - throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new("name", nameof(invitationData.OrganisationName))]); + throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new ErrorParameter("name", nameof(invitationData.OrganisationName))]); } return ExecuteInvitationInternalAsync(invitationData); diff --git a/src/administration/Administration.Service/BusinessLogic/NetworkBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/NetworkBusinessLogic.cs index 7550d8803d..2ba3be6374 100644 --- a/src/administration/Administration.Service/BusinessLogic/NetworkBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/NetworkBusinessLogic.cs @@ -54,7 +54,7 @@ public async Task HandlePartnerRegistration(PartnerRegistrationData data) { if (!data.Name.IsValidCompanyName()) { - throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new("name", "OrganisationName")]); + throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new ErrorParameter("name", "OrganisationName")]); } var ownerCompanyId = _identityData.CompanyId; diff --git a/src/administration/Administration.Service/BusinessLogic/RegistrationBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/RegistrationBusinessLogic.cs index 9b1b59e811..fe89b94d14 100644 --- a/src/administration/Administration.Service/BusinessLogic/RegistrationBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/RegistrationBusinessLogic.cs @@ -86,7 +86,7 @@ private async Task GetCompanyWithAddressAsyncInternal(Gu } if (!companyWithAddress.Name.IsValidCompanyName()) { - throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new("name", "OrganisationName")]); + throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new ErrorParameter("name", "OrganisationName")]); } return new CompanyWithAddressData( @@ -125,7 +125,7 @@ private async Task GetCompanyWithAddressAsyncInternal(Gu { if (companyName != null && !companyName.IsValidCompanyName()) { - throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new("name", "CompanyName")]); + throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new ErrorParameter("name", "CompanyName")]); } var applications = portalRepositories.GetInstance() .GetCompanyApplicationsFilteredQuery( @@ -165,7 +165,7 @@ private async Task GetCompanyWithAddressAsyncInternal(Gu { if (companyName != null && !companyName.IsValidCompanyName()) { - throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new("name", "CompanyName")]); + throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new ErrorParameter("name", "CompanyName")]); } var applications = portalRepositories.GetInstance() .GetExternalCompanyApplicationsFilteredQuery(_identityData.CompanyId, @@ -200,7 +200,7 @@ private async Task GetCompanyWithAddressAsyncInternal(Gu { if (companyName != null && !companyName.IsValidCompanyName()) { - throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new("name", "CompanyName")]); + throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new ErrorParameter("name", "CompanyName")]); } var applications = portalRepositories.GetInstance().GetAllCompanyApplicationsDetailsQuery(companyName); diff --git a/src/externalsystems/Bpdm.Library/BpnAccess.cs b/src/externalsystems/Bpdm.Library/BpnAccess.cs index 59e4dd2f1a..d667bca13c 100644 --- a/src/externalsystems/Bpdm.Library/BpnAccess.cs +++ b/src/externalsystems/Bpdm.Library/BpnAccess.cs @@ -28,13 +28,13 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Bpdm.Library; public class BpnAccess(IHttpClientFactory httpFactory) : IBpnAccess { - private readonly HttpClient _httpClient = httpFactory.CreateClient(nameof(BpnAccess)); private static readonly JsonSerializerOptions Options = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; public async Task FetchLegalEntityByBpn(string businessPartnerNumber, string token, CancellationToken cancellationToken) { - _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); - var result = await _httpClient.GetAsync($"legal-entities/{businessPartnerNumber}?idType=BPN", cancellationToken) + var httpClient = httpFactory.CreateClient(nameof(BpnAccess)); + httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); + var result = await httpClient.GetAsync($"legal-entities/{Uri.EscapeDataString(businessPartnerNumber)}?idType=BPN", cancellationToken) .CatchingIntoServiceExceptionFor("bpn-fetch-legal-entity") .ConfigureAwait(false); try diff --git a/src/marketplace/Apps.Service/BusinessLogic/AppReleaseBusinessLogic.cs b/src/marketplace/Apps.Service/BusinessLogic/AppReleaseBusinessLogic.cs index 9c6ee51664..25b9e59cfc 100644 --- a/src/marketplace/Apps.Service/BusinessLogic/AppReleaseBusinessLogic.cs +++ b/src/marketplace/Apps.Service/BusinessLogic/AppReleaseBusinessLogic.cs @@ -189,7 +189,7 @@ public Task AddAppAsync(AppRequestModel appRequestModel) if (appRequestModel.Provider != null && !appRequestModel.Provider.IsValidCompanyName()) { - throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new("name", nameof(appRequestModel.Provider))]); + throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new ErrorParameter("name", nameof(appRequestModel.Provider))]); } return CreateAppAsync(appRequestModel); @@ -269,7 +269,7 @@ public async Task UpdateAppReleaseAsync(Guid appId, AppRequestModel appRequestMo if (appRequestModel.Provider != null && !appRequestModel.Provider.IsValidCompanyName()) { - throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new("name", nameof(appRequestModel.Provider))]); + throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new ErrorParameter("name", nameof(appRequestModel.Provider))]); } if (appRequestModel.SalesManagerId.HasValue) diff --git a/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs b/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs index 4bbe253efc..2dda67cef6 100644 --- a/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs +++ b/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs @@ -158,7 +158,7 @@ public async Task AddFavouriteAppForUserAsync(Guid appId) { if (companyName != null && !companyName.IsValidCompanyName()) { - throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new("name", "CompanyName")]); + throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new ErrorParameter("name", "CompanyName")]); } async Task?> GetCompanyProvidedAppSubscriptionStatusData(int skip, int take) diff --git a/src/marketplace/Services.Service/BusinessLogic/ServiceBusinessLogic.cs b/src/marketplace/Services.Service/BusinessLogic/ServiceBusinessLogic.cs index 366cc59eea..5fc793eb3b 100644 --- a/src/marketplace/Services.Service/BusinessLogic/ServiceBusinessLogic.cs +++ b/src/marketplace/Services.Service/BusinessLogic/ServiceBusinessLogic.cs @@ -135,7 +135,7 @@ public Task AutoSetupServiceAsync(OfferAutoSetupData { if (companyName != null && !companyName.IsValidCompanyName()) { - throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new("name", "CompanyName")]); + throw ControllerArgumentException.Create(ValidationExpressionErrors.INCORRECT_COMPANY_NAME, [new ErrorParameter("name", "CompanyName")]); } async Task?> GetCompanyProvidedAppSubscriptionStatusData(int skip, int take) {