From 9e39fdca7061662de94943419705f0ff46168e24 Mon Sep 17 00:00:00 2001 From: Norbert Truchsess Date: Thu, 8 Feb 2024 17:52:35 +0100 Subject: [PATCH] feat(errorhandling): add common controller returning all errormessages --- CHANGELOG.md | 2 +- src/Portal.Backend.sln | 15 ++++ .../Administration.Service.csproj | 1 + .../Controllers/CompanyDataController.cs | 5 +- .../Controllers/ConnectorsController.cs | 5 +- .../Controllers/DocumentsController.cs | 5 +- .../Controllers/IdentityProviderController.cs | 5 +- .../Controllers/InvitationController.cs | 5 +- .../Controllers/NetworkController.cs | 5 +- .../Controllers/PartnerNetworkController.cs | 3 +- .../Controllers/RegistrationController.cs | 5 +- .../RegistrationStatusController.cs | 5 +- .../Controllers/ServiceAccountController.cs | 5 +- .../Controllers/StaticDataController.cs | 3 +- .../SubscriptionConfigurationController.cs | 5 +- .../Controllers/UserController.cs | 5 +- .../Properties/launchSettings.json | 1 + .../Framework.Async/Directory.Build.props | 2 +- .../Framework.Cors/Directory.Build.props | 2 +- .../Framework.DBAccess/Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 2 +- .../Directory.Build.props | 25 +++++++ .../ErrorMessageController.cs | 43 +++++++++++ .../Framework.ErrorHandling.Controller.csproj | 72 +++++++++++++++++++ .../README.md | 21 ++++++ .../Directory.Build.props | 2 +- .../ErrorResponse.cs | 2 +- .../Directory.Build.props | 2 +- .../Service/ErrorMessageService.cs | 9 +++ .../Service/IErrorMessageService.cs | 3 + .../Directory.Build.props | 2 +- .../Framework.IO/Directory.Build.props | 2 +- .../Framework.Linq/Directory.Build.props | 2 +- .../Framework.Logging/Directory.Build.props | 2 +- .../Framework.Models/Directory.Build.props | 2 +- .../Framework.Seeding/Directory.Build.props | 2 +- .../Framework.Swagger/Directory.Build.props | 2 +- .../Framework.Token/Directory.Build.props | 2 +- .../Framework.Web/Directory.Build.props | 2 +- .../EnvironmentRouteAttribute.cs | 34 +++++++++ .../Apps.Service/Apps.Service.csproj | 1 + .../Controllers/AppChangeController.cs | 5 +- .../AppReleaseProcessController.cs | 5 +- .../Controllers/AppsController.cs | 5 +- .../Properties/launchSettings.json | 1 + .../Controllers/ServiceChangeController.cs | 5 +- .../Controllers/ServiceReleaseController.cs | 5 +- .../Controllers/ServicesController.cs | 5 +- .../Properties/launchSettings.json | 1 + .../Services.Service/Services.Service.csproj | 1 + .../Controllers/NotificationController.cs | 5 +- .../Notifications.Service.csproj | 1 + .../Properties/launchSettings.json | 1 + .../Controllers/NetworkController.cs | 5 +- .../Controllers/RegistrationController.cs | 5 +- .../Controllers/StaticDataController.cs | 3 +- .../Properties/launchSettings.json | 1 + .../Registration.Service.csproj | 1 + .../PublicUrlActiveParticipantTests.cs | 4 +- .../PublicUrlAppProviderTests.cs | 16 ++--- .../PublicUrlServiceProviderTests.cs | 16 ++--- .../Framework.Token.Tests.csproj | 2 +- .../TokenServiceTests.cs | 2 +- .../PublicUrlAppProviderTests.cs | 4 +- .../PublicUrlServiceProviderTests.cs | 2 +- .../IntegrationTests/EndpointSetup/Paths.cs | 4 +- .../IntegrationTestFactory.cs | 2 + 68 files changed, 343 insertions(+), 86 deletions(-) create mode 100644 src/framework/Framework.ErrorHandling.Controller/Directory.Build.props create mode 100644 src/framework/Framework.ErrorHandling.Controller/ErrorMessageController.cs create mode 100644 src/framework/Framework.ErrorHandling.Controller/Framework.ErrorHandling.Controller.csproj create mode 100644 src/framework/Framework.ErrorHandling.Controller/README.md rename src/framework/{Framework.ErrorHandling/Service => Framework.ErrorHandling.Web}/ErrorResponse.cs (98%) create mode 100644 src/framework/Framework.Web/EnvironmentRouteAttribute.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c50ca5b2c..7c44ee7dba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -440,7 +440,7 @@ ServiceChange service url is mismatched, now it is fixed * Services Service * Fix POST /api/services/servicerelease/consent/{serviceId}/agreementConsents to save consents and set the correct user id * Email Template Password email updated to ensure that password field includes no spaces generated by the template -* Notification endpoint PUT /api/Notification/{notificationId}/read logic fixed to update the read flag true/false +* Notification endpoint PUT /api/notification/{notificationId}/read logic fixed to update the read flag true/false * Change the Type field of the SD-Factory call from "legalperson" to "legalparticipant" ### Known Knowns diff --git a/src/Portal.Backend.sln b/src/Portal.Backend.sln index 0f1f6cfe6b..9003bd6aa7 100644 --- a/src/Portal.Backend.sln +++ b/src/Portal.Backend.sln @@ -246,6 +246,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Framework.Token.Tests", ".. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Framework.Web.Tests", "..\tests\framework\Framework.Web.Tests\Framework.Web.Tests.csproj", "{7A6C6A10-DC2E-4A16-8758-1115473F3D94}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Framework.ErrorHandling.Controller", "framework\Framework.ErrorHandling.Controller\Framework.ErrorHandling.Controller.csproj", "{AD0C9BAD-E68F-40CF-86B4-31AC61856658}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1564,6 +1566,18 @@ Global {7A6C6A10-DC2E-4A16-8758-1115473F3D94}.Release|x64.Build.0 = Release|Any CPU {7A6C6A10-DC2E-4A16-8758-1115473F3D94}.Release|x86.ActiveCfg = Release|Any CPU {7A6C6A10-DC2E-4A16-8758-1115473F3D94}.Release|x86.Build.0 = Release|Any CPU + {AD0C9BAD-E68F-40CF-86B4-31AC61856658}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AD0C9BAD-E68F-40CF-86B4-31AC61856658}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AD0C9BAD-E68F-40CF-86B4-31AC61856658}.Debug|x64.ActiveCfg = Debug|Any CPU + {AD0C9BAD-E68F-40CF-86B4-31AC61856658}.Debug|x64.Build.0 = Debug|Any CPU + {AD0C9BAD-E68F-40CF-86B4-31AC61856658}.Debug|x86.ActiveCfg = Debug|Any CPU + {AD0C9BAD-E68F-40CF-86B4-31AC61856658}.Debug|x86.Build.0 = Debug|Any CPU + {AD0C9BAD-E68F-40CF-86B4-31AC61856658}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AD0C9BAD-E68F-40CF-86B4-31AC61856658}.Release|Any CPU.Build.0 = Release|Any CPU + {AD0C9BAD-E68F-40CF-86B4-31AC61856658}.Release|x64.ActiveCfg = Release|Any CPU + {AD0C9BAD-E68F-40CF-86B4-31AC61856658}.Release|x64.Build.0 = Release|Any CPU + {AD0C9BAD-E68F-40CF-86B4-31AC61856658}.Release|x86.ActiveCfg = Release|Any CPU + {AD0C9BAD-E68F-40CF-86B4-31AC61856658}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1680,5 +1694,6 @@ Global {B733F449-AE22-4B00-9F33-816B2F809EF1} = {323C198D-A8C6-4EB0-8B79-72624275E35F} {562DF697-262E-44DB-B6B5-40395E00D87C} = {323C198D-A8C6-4EB0-8B79-72624275E35F} {7A6C6A10-DC2E-4A16-8758-1115473F3D94} = {323C198D-A8C6-4EB0-8B79-72624275E35F} + {AD0C9BAD-E68F-40CF-86B4-31AC61856658} = {B42CFF96-B8DB-48A6-A9CA-72BFB5F0117B} EndGlobalSection EndGlobal diff --git a/src/administration/Administration.Service/Administration.Service.csproj b/src/administration/Administration.Service/Administration.Service.csproj index 793b3a6284..caf0d3dd04 100644 --- a/src/administration/Administration.Service/Administration.Service.csproj +++ b/src/administration/Administration.Service/Administration.Service.csproj @@ -66,6 +66,7 @@ + diff --git a/src/administration/Administration.Service/Controllers/CompanyDataController.cs b/src/administration/Administration.Service/Controllers/CompanyDataController.cs index 5bea9c452b..d06699f141 100644 --- a/src/administration/Administration.Service/Controllers/CompanyDataController.cs +++ b/src/administration/Administration.Service/Controllers/CompanyDataController.cs @@ -22,8 +22,9 @@ using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; using Org.Eclipse.TractusX.Portal.Backend.Web.Identity; @@ -35,7 +36,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers /// Creates a new instance of /// [ApiController] -[Route("api/administration/companydata")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "companydata")] [Produces("application/json")] [Consumes("application/json")] public class CompanyDataController : ControllerBase diff --git a/src/administration/Administration.Service/Controllers/ConnectorsController.cs b/src/administration/Administration.Service/Controllers/ConnectorsController.cs index 4628aaddb8..a8a5a56827 100644 --- a/src/administration/Administration.Service/Controllers/ConnectorsController.cs +++ b/src/administration/Administration.Service/Controllers/ConnectorsController.cs @@ -22,8 +22,9 @@ using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.Models; @@ -35,7 +36,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers /// /// Controller providing actions for displaying, filtering and updating connectors for companies. /// -[Route("api/administration/[controller]")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "[controller]")] [ApiController] [Produces("application/json")] public class ConnectorsController : ControllerBase diff --git a/src/administration/Administration.Service/Controllers/DocumentsController.cs b/src/administration/Administration.Service/Controllers/DocumentsController.cs index 5d103088ef..d4e4797594 100644 --- a/src/administration/Administration.Service/Controllers/DocumentsController.cs +++ b/src/administration/Administration.Service/Controllers/DocumentsController.cs @@ -21,7 +21,8 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; using Org.Eclipse.TractusX.Portal.Backend.Web.Identity; @@ -32,7 +33,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers /// /// Controller providing actions for displaying, filtering and updating connectors for documents. /// -[Route("api/administration/[controller]")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "[controller]")] [ApiController] [Consumes("application/json")] public class DocumentsController : ControllerBase diff --git a/src/administration/Administration.Service/Controllers/IdentityProviderController.cs b/src/administration/Administration.Service/Controllers/IdentityProviderController.cs index 8b871ecadc..52f8f57000 100644 --- a/src/administration/Administration.Service/Controllers/IdentityProviderController.cs +++ b/src/administration/Administration.Service/Controllers/IdentityProviderController.cs @@ -22,7 +22,8 @@ using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Enums; using Org.Eclipse.TractusX.Portal.Backend.Web.Identity; @@ -32,7 +33,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers /// /// Controller providing actions for displaying, filtering and updating identityProviders for companies. /// -[Route("api/administration/identityprovider")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "identityprovider")] [ApiController] public class IdentityProviderController : ControllerBase { diff --git a/src/administration/Administration.Service/Controllers/InvitationController.cs b/src/administration/Administration.Service/Controllers/InvitationController.cs index fe5999eddc..c318ca7776 100644 --- a/src/administration/Administration.Service/Controllers/InvitationController.cs +++ b/src/administration/Administration.Service/Controllers/InvitationController.cs @@ -22,7 +22,8 @@ using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.Web.Identity; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers; @@ -31,7 +32,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers /// Controller providing actions execute invitation /// [ApiController] -[Route("api/administration/invitation")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "invitation")] [Produces("application/json")] [Consumes("application/json")] public class InvitationController : ControllerBase diff --git a/src/administration/Administration.Service/Controllers/NetworkController.cs b/src/administration/Administration.Service/Controllers/NetworkController.cs index b66b6afbba..d0e385cf3d 100644 --- a/src/administration/Administration.Service/Controllers/NetworkController.cs +++ b/src/administration/Administration.Service/Controllers/NetworkController.cs @@ -21,14 +21,15 @@ using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; using Org.Eclipse.TractusX.Portal.Backend.Web.Identity; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers; [ApiController] -[Route("api/administration/registration/[controller]")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "registration/[controller]")] [Produces("application/json")] [Consumes("application/json")] public class NetworkController : ControllerBase diff --git a/src/administration/Administration.Service/Controllers/PartnerNetworkController.cs b/src/administration/Administration.Service/Controllers/PartnerNetworkController.cs index c77174edc2..c13bdb39a3 100644 --- a/src/administration/Administration.Service/Controllers/PartnerNetworkController.cs +++ b/src/administration/Administration.Service/Controllers/PartnerNetworkController.cs @@ -21,6 +21,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; using Org.Eclipse.TractusX.Portal.Backend.Web.PublicInfos; @@ -30,7 +31,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers /// Creates a new instance of /// [ApiController] -[Route("api/administration/[controller]")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "[controller]")] [Produces("application/json")] [Consumes("application/json")] public class PartnerNetworkController : ControllerBase diff --git a/src/administration/Administration.Service/Controllers/RegistrationController.cs b/src/administration/Administration.Service/Controllers/RegistrationController.cs index 25eb699f7c..a2b2694557 100644 --- a/src/administration/Administration.Service/Controllers/RegistrationController.cs +++ b/src/administration/Administration.Service/Controllers/RegistrationController.cs @@ -23,8 +23,9 @@ using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; using Org.Eclipse.TractusX.Portal.Backend.Clearinghouse.Library.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.Models; @@ -33,7 +34,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers; [ApiController] -[Route("api/administration/registration")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "registration")] [Produces("application/json")] [Consumes("application/json")] public class RegistrationController : ControllerBase diff --git a/src/administration/Administration.Service/Controllers/RegistrationStatusController.cs b/src/administration/Administration.Service/Controllers/RegistrationStatusController.cs index 6df5092bcf..dd9e7508aa 100644 --- a/src/administration/Administration.Service/Controllers/RegistrationStatusController.cs +++ b/src/administration/Administration.Service/Controllers/RegistrationStatusController.cs @@ -21,14 +21,15 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.Web.Identity; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers; [ApiController] -[Route("api/administration/[controller]")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "[controller]")] [Produces("application/json")] [Consumes("application/json")] public class RegistrationStatusController : ControllerBase diff --git a/src/administration/Administration.Service/Controllers/ServiceAccountController.cs b/src/administration/Administration.Service/Controllers/ServiceAccountController.cs index a99e9aed0e..90aa534b11 100644 --- a/src/administration/Administration.Service/Controllers/ServiceAccountController.cs +++ b/src/administration/Administration.Service/Controllers/ServiceAccountController.cs @@ -22,8 +22,9 @@ using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Web.Identity; @@ -31,7 +32,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers; [ApiController] -[Route("api/administration/serviceaccount")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "serviceaccount")] [Produces("application/json")] [Consumes("application/json")] public class ServiceAccountController : ControllerBase diff --git a/src/administration/Administration.Service/Controllers/StaticDataController.cs b/src/administration/Administration.Service/Controllers/StaticDataController.cs index 90917a22c9..32fb366b1f 100644 --- a/src/administration/Administration.Service/Controllers/StaticDataController.cs +++ b/src/administration/Administration.Service/Controllers/StaticDataController.cs @@ -20,6 +20,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers; @@ -28,7 +29,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers /// Controller providing actions for displaying, filtering and updating static data for app. /// [ApiController] -[Route("api/administration/staticdata")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "staticdata")] [Produces("application/json")] [Consumes("application/json")] public class StaticDataController : ControllerBase diff --git a/src/administration/Administration.Service/Controllers/SubscriptionConfigurationController.cs b/src/administration/Administration.Service/Controllers/SubscriptionConfigurationController.cs index 0b98b7ec51..25a860e31f 100644 --- a/src/administration/Administration.Service/Controllers/SubscriptionConfigurationController.cs +++ b/src/administration/Administration.Service/Controllers/SubscriptionConfigurationController.cs @@ -21,7 +21,8 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; using Org.Eclipse.TractusX.Portal.Backend.Web.Identity; @@ -33,7 +34,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers /// Creates a new instance of /// [ApiController] -[Route("api/administration/[controller]")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "[controller]")] [Produces("application/json")] [Consumes("application/json")] public class SubscriptionConfigurationController : ControllerBase diff --git a/src/administration/Administration.Service/Controllers/UserController.cs b/src/administration/Administration.Service/Controllers/UserController.cs index e2c45c3996..e5335d751a 100644 --- a/src/administration/Administration.Service/Controllers/UserController.cs +++ b/src/administration/Administration.Service/Controllers/UserController.cs @@ -21,8 +21,9 @@ using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Web.Identity; @@ -30,7 +31,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Controllers; [ApiController] -[Route("api/administration/user")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "user")] [Produces("application/json")] [Consumes("application/json")] public class UserController : ControllerBase diff --git a/src/administration/Administration.Service/Properties/launchSettings.json b/src/administration/Administration.Service/Properties/launchSettings.json index 5b14692bd4..a217a314f2 100644 --- a/src/administration/Administration.Service/Properties/launchSettings.json +++ b/src/administration/Administration.Service/Properties/launchSettings.json @@ -24,6 +24,7 @@ "launchUrl": "api/administration/swagger", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", + "MVC_ROUTING_BASEPATH": "api/administration", "Cors__AllowedOrigins__0": "http://localhost:3000", "Cors__AllowedOrigins__1": "https://portal.example.org" }, diff --git a/src/framework/Framework.Async/Directory.Build.props b/src/framework/Framework.Async/Directory.Build.props index 3f35c3e9a7..ef267766b7 100644 --- a/src/framework/Framework.Async/Directory.Build.props +++ b/src/framework/Framework.Async/Directory.Build.props @@ -19,7 +19,7 @@ - 1.0.0 + 1.1.0 diff --git a/src/framework/Framework.Cors/Directory.Build.props b/src/framework/Framework.Cors/Directory.Build.props index 3f35c3e9a7..ef267766b7 100644 --- a/src/framework/Framework.Cors/Directory.Build.props +++ b/src/framework/Framework.Cors/Directory.Build.props @@ -19,7 +19,7 @@ - 1.0.0 + 1.1.0 diff --git a/src/framework/Framework.DBAccess/Directory.Build.props b/src/framework/Framework.DBAccess/Directory.Build.props index 3f35c3e9a7..ef267766b7 100644 --- a/src/framework/Framework.DBAccess/Directory.Build.props +++ b/src/framework/Framework.DBAccess/Directory.Build.props @@ -19,7 +19,7 @@ - 1.0.0 + 1.1.0 diff --git a/src/framework/Framework.DateTimeProvider/Directory.Build.props b/src/framework/Framework.DateTimeProvider/Directory.Build.props index 3f35c3e9a7..ef267766b7 100644 --- a/src/framework/Framework.DateTimeProvider/Directory.Build.props +++ b/src/framework/Framework.DateTimeProvider/Directory.Build.props @@ -19,7 +19,7 @@ - 1.0.0 + 1.1.0 diff --git a/src/framework/Framework.DependencyInjection/Directory.Build.props b/src/framework/Framework.DependencyInjection/Directory.Build.props index 3f35c3e9a7..ef267766b7 100644 --- a/src/framework/Framework.DependencyInjection/Directory.Build.props +++ b/src/framework/Framework.DependencyInjection/Directory.Build.props @@ -19,7 +19,7 @@ - 1.0.0 + 1.1.0 diff --git a/src/framework/Framework.ErrorHandling.Controller/Directory.Build.props b/src/framework/Framework.ErrorHandling.Controller/Directory.Build.props new file mode 100644 index 0000000000..ef267766b7 --- /dev/null +++ b/src/framework/Framework.ErrorHandling.Controller/Directory.Build.props @@ -0,0 +1,25 @@ + + + + + 1.1.0 + + + diff --git a/src/framework/Framework.ErrorHandling.Controller/ErrorMessageController.cs b/src/framework/Framework.ErrorHandling.Controller/ErrorMessageController.cs new file mode 100644 index 0000000000..8f83f99329 --- /dev/null +++ b/src/framework/Framework.ErrorHandling.Controller/ErrorMessageController.cs @@ -0,0 +1,43 @@ +/******************************************************************************** + * Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; + +namespace Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Controller; + +[ApiController] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "errormessage")] +[Produces("application/json")] +public class ErrorMessageController : ControllerBase +{ + private readonly IErrorMessageService _logic; + + public ErrorMessageController(IErrorMessageService logic) + { + _logic = logic; + } + + [HttpGet] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + public IEnumerable GetAllMessageTexts() + => _logic.GetAllMessageTexts(); +} diff --git a/src/framework/Framework.ErrorHandling.Controller/Framework.ErrorHandling.Controller.csproj b/src/framework/Framework.ErrorHandling.Controller/Framework.ErrorHandling.Controller.csproj new file mode 100644 index 0000000000..a31e93cd71 --- /dev/null +++ b/src/framework/Framework.ErrorHandling.Controller/Framework.ErrorHandling.Controller.csproj @@ -0,0 +1,72 @@ + + + + Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Controller + Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Controller + net7.0 + enable + enable + true + + + + + Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Controller + Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Controller + Eclipse Tractus-X + All content is the property of the respective authors or their employers. For more information regarding authorship of content, please consult the listed source code repository logs. + + The Catena-X Portal Backend Framework library is a versatile .NET library that provides a set of powerful tools and utilities for common development tasks. + This package simplifies various aspects of your application, including database interactions, asynchronous programming, file I/O, LINQ operations, logging, and database seeding. + + README.md + LICENSE + https://github.com/eclipse-tractusx/portal-backend + https://github.com/eclipse-tractusx/portal-backend + git + + true + + + true + + + true + snupkg + + + + + + + + + + + + + + + + + + + + diff --git a/src/framework/Framework.ErrorHandling.Controller/README.md b/src/framework/Framework.ErrorHandling.Controller/README.md new file mode 100644 index 0000000000..b21169cef1 --- /dev/null +++ b/src/framework/Framework.ErrorHandling.Controller/README.md @@ -0,0 +1,21 @@ +# Catena-X Portal Backend Framework ErrorHandling Controller + +The Catena-X Portal Backend Framework ErrorHandling Controller library provides a useful set of extensions and functionality to setup a asp net core application. + +This content is produced and maintained by the Eclipse Tractus-X project. + +* Project home: https://projects.eclipse.org/projects/automotive.tractusx + +## Installation + +dotnet add package Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Controller + +## Source Code + +The project maintains the following source code repositories in the GitHub organization https://github.com/eclipse-tractusx: + +- https://github.com/eclipse-tractusx/portal-backend + +## License + +Distributed under the Apache 2.0 License. diff --git a/src/framework/Framework.ErrorHandling.Web/Directory.Build.props b/src/framework/Framework.ErrorHandling.Web/Directory.Build.props index 3f35c3e9a7..ef267766b7 100644 --- a/src/framework/Framework.ErrorHandling.Web/Directory.Build.props +++ b/src/framework/Framework.ErrorHandling.Web/Directory.Build.props @@ -19,7 +19,7 @@ - 1.0.0 + 1.1.0 diff --git a/src/framework/Framework.ErrorHandling/Service/ErrorResponse.cs b/src/framework/Framework.ErrorHandling.Web/ErrorResponse.cs similarity index 98% rename from src/framework/Framework.ErrorHandling/Service/ErrorResponse.cs rename to src/framework/Framework.ErrorHandling.Web/ErrorResponse.cs index d01026605f..9075662dc0 100644 --- a/src/framework/Framework.ErrorHandling/Service/ErrorResponse.cs +++ b/src/framework/Framework.ErrorHandling.Web/ErrorResponse.cs @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -namespace Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +namespace Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; public record ErrorResponse( string Type, diff --git a/src/framework/Framework.ErrorHandling/Directory.Build.props b/src/framework/Framework.ErrorHandling/Directory.Build.props index 3f35c3e9a7..ef267766b7 100644 --- a/src/framework/Framework.ErrorHandling/Directory.Build.props +++ b/src/framework/Framework.ErrorHandling/Directory.Build.props @@ -19,7 +19,7 @@ - 1.0.0 + 1.1.0 diff --git a/src/framework/Framework.ErrorHandling/Service/ErrorMessageService.cs b/src/framework/Framework.ErrorHandling/Service/ErrorMessageService.cs index 6cffed3a2b..acce33685b 100644 --- a/src/framework/Framework.ErrorHandling/Service/ErrorMessageService.cs +++ b/src/framework/Framework.ErrorHandling/Service/ErrorMessageService.cs @@ -40,4 +40,13 @@ public string GetMessage(Type type, int code) return message; } + + public IEnumerable GetAllMessageTexts() => + _messageContainers.Select(container => + new IErrorMessageService.ErrorMessageType( + container.Key.Name, + container.Value.Select(message => + new IErrorMessageService.ErrorMessageCode( + Enum.GetName(container.Key, message.Key) ?? throw new UnexpectedConditionException($"{message.Key} is not a valid value for enum type {container.Key}"), + message.Value)))); } diff --git a/src/framework/Framework.ErrorHandling/Service/IErrorMessageService.cs b/src/framework/Framework.ErrorHandling/Service/IErrorMessageService.cs index 7077df263e..270a83d49f 100644 --- a/src/framework/Framework.ErrorHandling/Service/IErrorMessageService.cs +++ b/src/framework/Framework.ErrorHandling/Service/IErrorMessageService.cs @@ -22,4 +22,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; public interface IErrorMessageService { public string GetMessage(Type type, int code); + public IEnumerable GetAllMessageTexts(); + public record ErrorMessageType(string ErrorType, IEnumerable ErrorMessages); + public record ErrorMessageCode(string ErrorCode, string Message); } diff --git a/src/framework/Framework.HttpClientExtensions/Directory.Build.props b/src/framework/Framework.HttpClientExtensions/Directory.Build.props index 3f35c3e9a7..ef267766b7 100644 --- a/src/framework/Framework.HttpClientExtensions/Directory.Build.props +++ b/src/framework/Framework.HttpClientExtensions/Directory.Build.props @@ -19,7 +19,7 @@ - 1.0.0 + 1.1.0 diff --git a/src/framework/Framework.IO/Directory.Build.props b/src/framework/Framework.IO/Directory.Build.props index 3f35c3e9a7..ef267766b7 100644 --- a/src/framework/Framework.IO/Directory.Build.props +++ b/src/framework/Framework.IO/Directory.Build.props @@ -19,7 +19,7 @@ - 1.0.0 + 1.1.0 diff --git a/src/framework/Framework.Linq/Directory.Build.props b/src/framework/Framework.Linq/Directory.Build.props index 3f35c3e9a7..ef267766b7 100644 --- a/src/framework/Framework.Linq/Directory.Build.props +++ b/src/framework/Framework.Linq/Directory.Build.props @@ -19,7 +19,7 @@ - 1.0.0 + 1.1.0 diff --git a/src/framework/Framework.Logging/Directory.Build.props b/src/framework/Framework.Logging/Directory.Build.props index 3f35c3e9a7..ef267766b7 100644 --- a/src/framework/Framework.Logging/Directory.Build.props +++ b/src/framework/Framework.Logging/Directory.Build.props @@ -19,7 +19,7 @@ - 1.0.0 + 1.1.0 diff --git a/src/framework/Framework.Models/Directory.Build.props b/src/framework/Framework.Models/Directory.Build.props index 3f35c3e9a7..ef267766b7 100644 --- a/src/framework/Framework.Models/Directory.Build.props +++ b/src/framework/Framework.Models/Directory.Build.props @@ -19,7 +19,7 @@ - 1.0.0 + 1.1.0 diff --git a/src/framework/Framework.Seeding/Directory.Build.props b/src/framework/Framework.Seeding/Directory.Build.props index 3f35c3e9a7..ef267766b7 100644 --- a/src/framework/Framework.Seeding/Directory.Build.props +++ b/src/framework/Framework.Seeding/Directory.Build.props @@ -19,7 +19,7 @@ - 1.0.0 + 1.1.0 diff --git a/src/framework/Framework.Swagger/Directory.Build.props b/src/framework/Framework.Swagger/Directory.Build.props index 3f35c3e9a7..ef267766b7 100644 --- a/src/framework/Framework.Swagger/Directory.Build.props +++ b/src/framework/Framework.Swagger/Directory.Build.props @@ -19,7 +19,7 @@ - 1.0.0 + 1.1.0 diff --git a/src/framework/Framework.Token/Directory.Build.props b/src/framework/Framework.Token/Directory.Build.props index 3f35c3e9a7..ef267766b7 100644 --- a/src/framework/Framework.Token/Directory.Build.props +++ b/src/framework/Framework.Token/Directory.Build.props @@ -19,7 +19,7 @@ - 1.0.0 + 1.1.0 diff --git a/src/framework/Framework.Web/Directory.Build.props b/src/framework/Framework.Web/Directory.Build.props index 3f35c3e9a7..ef267766b7 100644 --- a/src/framework/Framework.Web/Directory.Build.props +++ b/src/framework/Framework.Web/Directory.Build.props @@ -19,7 +19,7 @@ - 1.0.0 + 1.1.0 diff --git a/src/framework/Framework.Web/EnvironmentRouteAttribute.cs b/src/framework/Framework.Web/EnvironmentRouteAttribute.cs new file mode 100644 index 0000000000..d1e25bd45b --- /dev/null +++ b/src/framework/Framework.Web/EnvironmentRouteAttribute.cs @@ -0,0 +1,34 @@ +/******************************************************************************** + * Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +using Microsoft.AspNetCore.Mvc; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; + +namespace Org.Eclipse.TractusX.Portal.Backend.Framework.Web; + +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] +public sealed class EnvironmentRouteAttribute : RouteAttribute +{ + public EnvironmentRouteAttribute(string environmentVar, string? template = null) + : base(template == null + ? $"{Environment.GetEnvironmentVariable(environmentVar) ?? throw new ConfigurationException($"Environment variable {environmentVar} must be defined")}" + : $"{Environment.GetEnvironmentVariable(environmentVar) ?? throw new ConfigurationException($"Environment variable {environmentVar} must be defined")}/{template}") + { + } +} diff --git a/src/marketplace/Apps.Service/Apps.Service.csproj b/src/marketplace/Apps.Service/Apps.Service.csproj index c120f46c8c..a9892e6e66 100644 --- a/src/marketplace/Apps.Service/Apps.Service.csproj +++ b/src/marketplace/Apps.Service/Apps.Service.csproj @@ -47,6 +47,7 @@ + diff --git a/src/marketplace/Apps.Service/Controllers/AppChangeController.cs b/src/marketplace/Apps.Service/Controllers/AppChangeController.cs index 34d6d0cbe3..4304822be1 100644 --- a/src/marketplace/Apps.Service/Controllers/AppChangeController.cs +++ b/src/marketplace/Apps.Service/Controllers/AppChangeController.cs @@ -22,7 +22,8 @@ using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.ViewModels; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; using Org.Eclipse.TractusX.Portal.Backend.Web.Identity; @@ -32,7 +33,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Apps.Service.Controllers; /// /// Controller providing actions for updating applications. /// -[Route("api/apps/[controller]")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "[controller]")] [ApiController] [Produces("application/json")] [Consumes("application/json")] diff --git a/src/marketplace/Apps.Service/Controllers/AppReleaseProcessController.cs b/src/marketplace/Apps.Service/Controllers/AppReleaseProcessController.cs index cdfcf899b2..df9237a858 100644 --- a/src/marketplace/Apps.Service/Controllers/AppReleaseProcessController.cs +++ b/src/marketplace/Apps.Service/Controllers/AppReleaseProcessController.cs @@ -22,8 +22,9 @@ using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.ViewModels; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; @@ -34,7 +35,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Apps.Service.Controllers; /// /// Controller providing actions for updating applications. /// -[Route("api/apps/[controller]")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "[controller]")] [ApiController] [Produces("application/json")] [Consumes("application/json")] diff --git a/src/marketplace/Apps.Service/Controllers/AppsController.cs b/src/marketplace/Apps.Service/Controllers/AppsController.cs index ce072056b1..0a5d5dbe45 100644 --- a/src/marketplace/Apps.Service/Controllers/AppsController.cs +++ b/src/marketplace/Apps.Service/Controllers/AppsController.cs @@ -22,8 +22,9 @@ using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.ViewModels; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; @@ -35,7 +36,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Apps.Service.Controllers; /// /// Controller providing actions for displaying, filtering and updating applications and user assigned favourites. /// -[Route("api/[controller]")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH")] [ApiController] [Produces("application/json")] [Consumes("application/json")] diff --git a/src/marketplace/Apps.Service/Properties/launchSettings.json b/src/marketplace/Apps.Service/Properties/launchSettings.json index 80708f0747..b95d83cc39 100644 --- a/src/marketplace/Apps.Service/Properties/launchSettings.json +++ b/src/marketplace/Apps.Service/Properties/launchSettings.json @@ -15,6 +15,7 @@ "launchUrl": "api/apps/swagger", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", + "MVC_ROUTING_BASEPATH": "api/apps", "Cors__AllowedOrigins__0": "http://localhost:3000" }, "applicationUrl": "https://localhost:5001;http://localhost:5000", diff --git a/src/marketplace/Services.Service/Controllers/ServiceChangeController.cs b/src/marketplace/Services.Service/Controllers/ServiceChangeController.cs index ed0052d7f1..21dc9152c3 100644 --- a/src/marketplace/Services.Service/Controllers/ServiceChangeController.cs +++ b/src/marketplace/Services.Service/Controllers/ServiceChangeController.cs @@ -20,7 +20,8 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.Services.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Web.Identity; @@ -30,7 +31,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Services.Service.Controllers; /// Controller providing actions for updating applications. /// -[Route("api/services/[controller]")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "[controller]")] [ApiController] [Produces("application/json")] [Consumes("application/json")] diff --git a/src/marketplace/Services.Service/Controllers/ServiceReleaseController.cs b/src/marketplace/Services.Service/Controllers/ServiceReleaseController.cs index 200e2f84b9..b5b4519cab 100644 --- a/src/marketplace/Services.Service/Controllers/ServiceReleaseController.cs +++ b/src/marketplace/Services.Service/Controllers/ServiceReleaseController.cs @@ -20,8 +20,9 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; @@ -34,7 +35,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Services.Service.Controllers; /// /// Controller providing actions for displaying, filtering and updating services. /// -[Route("api/services/[controller]")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "[controller]")] [ApiController] [Produces("application/json")] [Consumes("application/json")] diff --git a/src/marketplace/Services.Service/Controllers/ServicesController.cs b/src/marketplace/Services.Service/Controllers/ServicesController.cs index 8fdd47de31..544b844899 100644 --- a/src/marketplace/Services.Service/Controllers/ServicesController.cs +++ b/src/marketplace/Services.Service/Controllers/ServicesController.cs @@ -19,8 +19,9 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; @@ -34,7 +35,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Services.Service.Controllers; /// /// Controller providing actions for displaying, filtering and updating services. /// -[Route("api/[controller]")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH")] [ApiController] [Produces("application/json")] [Consumes("application/json")] diff --git a/src/marketplace/Services.Service/Properties/launchSettings.json b/src/marketplace/Services.Service/Properties/launchSettings.json index 3d598426ee..7dd7c24b92 100644 --- a/src/marketplace/Services.Service/Properties/launchSettings.json +++ b/src/marketplace/Services.Service/Properties/launchSettings.json @@ -22,6 +22,7 @@ "launchUrl": "api/services/swagger", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", + "MVC_ROUTING_BASEPATH": "api/services", "Cors__AllowedOrigins__0": "http://localhost:3000", "Cors__AllowedOrigins__1": "https://portal.example.org" }, diff --git a/src/marketplace/Services.Service/Services.Service.csproj b/src/marketplace/Services.Service/Services.Service.csproj index c99434c91d..6ff6b73aec 100644 --- a/src/marketplace/Services.Service/Services.Service.csproj +++ b/src/marketplace/Services.Service/Services.Service.csproj @@ -41,6 +41,7 @@ + diff --git a/src/notifications/Notifications.Service/Controllers/NotificationController.cs b/src/notifications/Notifications.Service/Controllers/NotificationController.cs index 52078db957..4c72ba81a1 100644 --- a/src/notifications/Notifications.Service/Controllers/NotificationController.cs +++ b/src/notifications/Notifications.Service/Controllers/NotificationController.cs @@ -20,8 +20,9 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.Notifications.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Notifications.Service.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; @@ -34,7 +35,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Notifications.Service.Controllers; /// Controller providing actions for creating, displaying and updating notifications. /// [ApiController] -[Route("api/[controller]")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH")] [Consumes("application/json")] [Produces("application/json")] public class NotificationController : ControllerBase diff --git a/src/notifications/Notifications.Service/Notifications.Service.csproj b/src/notifications/Notifications.Service/Notifications.Service.csproj index 85e24888e2..7d99ed491b 100644 --- a/src/notifications/Notifications.Service/Notifications.Service.csproj +++ b/src/notifications/Notifications.Service/Notifications.Service.csproj @@ -40,6 +40,7 @@ + diff --git a/src/notifications/Notifications.Service/Properties/launchSettings.json b/src/notifications/Notifications.Service/Properties/launchSettings.json index 18440f9b43..34b0ef7620 100644 --- a/src/notifications/Notifications.Service/Properties/launchSettings.json +++ b/src/notifications/Notifications.Service/Properties/launchSettings.json @@ -24,6 +24,7 @@ "launchUrl": "api/notification/swagger", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", + "MVC_ROUTING_BASEPATH": "api/notification", "Cors__AllowedOrigins__0": "http://localhost:3000", "Cors__AllowedOrigins__1": "https://portal.example.org" }, diff --git a/src/registration/Registration.Service/Controllers/NetworkController.cs b/src/registration/Registration.Service/Controllers/NetworkController.cs index 1cd3df32bc..e73158afd5 100644 --- a/src/registration/Registration.Service/Controllers/NetworkController.cs +++ b/src/registration/Registration.Service/Controllers/NetworkController.cs @@ -20,7 +20,8 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.Registration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Registration.Service.Model; using Org.Eclipse.TractusX.Portal.Backend.Web.Identity; @@ -28,7 +29,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Registration.Service.Controllers; [ApiController] -[Route("api/registration/[controller]")] +[EnvironmentRoute("MVC_ROUTING_BASEPATH", "[controller]")] [Produces("application/json")] [Consumes("application/json")] public class NetworkController : ControllerBase diff --git a/src/registration/Registration.Service/Controllers/RegistrationController.cs b/src/registration/Registration.Service/Controllers/RegistrationController.cs index b94c892071..9dd4c626e0 100644 --- a/src/registration/Registration.Service/Controllers/RegistrationController.cs +++ b/src/registration/Registration.Service/Controllers/RegistrationController.cs @@ -21,7 +21,8 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Org.Eclipse.TractusX.Portal.Backend.Bpdm.Library.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.Keycloak.Authentication; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; @@ -34,7 +35,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Registration.Service.Controllers { [ApiController] - [Route("api/registration")] + [EnvironmentRoute("MVC_ROUTING_BASEPATH")] [Produces("application/json")] [Consumes("application/json")] public class RegistrationController : ControllerBase diff --git a/src/registration/Registration.Service/Controllers/StaticDataController.cs b/src/registration/Registration.Service/Controllers/StaticDataController.cs index d39edcb161..7df375ff50 100644 --- a/src/registration/Registration.Service/Controllers/StaticDataController.cs +++ b/src/registration/Registration.Service/Controllers/StaticDataController.cs @@ -18,6 +18,7 @@ ********************************************************************************/ using Microsoft.AspNetCore.Mvc; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.Registration.Service.BusinessLogic; @@ -25,7 +26,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Registration.Service.Controllers { [ApiController] - [Route("api/registration/[controller]")] + [EnvironmentRoute("MVC_ROUTING_BASEPATH", "[controller]")] [Produces("application/json")] [Consumes("application/json")] public class StaticDataController : ControllerBase diff --git a/src/registration/Registration.Service/Properties/launchSettings.json b/src/registration/Registration.Service/Properties/launchSettings.json index 5c73838249..e46458fef6 100644 --- a/src/registration/Registration.Service/Properties/launchSettings.json +++ b/src/registration/Registration.Service/Properties/launchSettings.json @@ -24,6 +24,7 @@ "launchUrl": "api/registration/swagger", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", + "MVC_ROUTING_BASEPATH": "api/registration", "Cors__AllowedOrigins__0": "http://localhost:3000", "Cors__AllowedOrigins__1": "https://portal.example.org" }, diff --git a/src/registration/Registration.Service/Registration.Service.csproj b/src/registration/Registration.Service/Registration.Service.csproj index 287b395554..04fa74bb63 100644 --- a/src/registration/Registration.Service/Registration.Service.csproj +++ b/src/registration/Registration.Service/Registration.Service.csproj @@ -54,6 +54,7 @@ + diff --git a/tests/administration/Administration.Service.Tests/IntegrationTests/PublicUrlActiveParticipantTests.cs b/tests/administration/Administration.Service.Tests/IntegrationTests/PublicUrlActiveParticipantTests.cs index eb042d5b20..0e95995567 100644 --- a/tests/administration/Administration.Service.Tests/IntegrationTests/PublicUrlActiveParticipantTests.cs +++ b/tests/administration/Administration.Service.Tests/IntegrationTests/PublicUrlActiveParticipantTests.cs @@ -37,8 +37,8 @@ public PublicUrlActiveParticipantTests(IntegrationTestFactory x.HttpMethods == "POST" && x.Url == "api/administration/connectors/discovery", - x => x.HttpMethods == "GET" && x.Url == "api/administration/partnernetwork/membercompanies") + x => x.HttpMethods == "POST" && x.Url == "api/test/connectors/discovery", + x => x.HttpMethods == "GET" && x.Url == "api/test/partnernetwork/membercompanies") .ConfigureAwait(false); } } diff --git a/tests/administration/Administration.Service.Tests/IntegrationTests/PublicUrlAppProviderTests.cs b/tests/administration/Administration.Service.Tests/IntegrationTests/PublicUrlAppProviderTests.cs index 2c0302d5f1..2b83240375 100644 --- a/tests/administration/Administration.Service.Tests/IntegrationTests/PublicUrlAppProviderTests.cs +++ b/tests/administration/Administration.Service.Tests/IntegrationTests/PublicUrlAppProviderTests.cs @@ -36,14 +36,14 @@ public PublicUrlAppProviderTests(IntegrationTestFactory x.HttpMethods == "GET" && x.Url == "api/administration/connectors/managed", - x => x.HttpMethods == "POST" && x.Url == "api/administration/connectors/managed", - x => x.HttpMethods == "POST" && x.Url == "api/administration/connectors/discovery", - x => x.HttpMethods == "GET" && x.Url == "api/administration/documents/selfdescription/{documentid}", - x => x.HttpMethods == "GET" && x.Url == "api/administration/partnernetwork/membercompanies", - x => x.HttpMethods == "GET" && x.Url == "api/administration/subscriptionconfiguration/owncompany", - x => x.HttpMethods == "GET" && x.Url == "api/administration/subscriptionconfiguration/process/offer-subscription/{offersubscriptionid}", - x => x.HttpMethods == "POST" && x.Url == "api/administration/subscriptionconfiguration/process/offer-subscription/{offersubscriptionid}/retrigger-provider-callback") + x => x.HttpMethods == "GET" && x.Url == "api/test/connectors/managed", + x => x.HttpMethods == "POST" && x.Url == "api/test/connectors/managed", + x => x.HttpMethods == "POST" && x.Url == "api/test/connectors/discovery", + x => x.HttpMethods == "GET" && x.Url == "api/test/documents/selfdescription/{documentid}", + x => x.HttpMethods == "GET" && x.Url == "api/test/partnernetwork/membercompanies", + x => x.HttpMethods == "GET" && x.Url == "api/test/subscriptionconfiguration/owncompany", + x => x.HttpMethods == "GET" && x.Url == "api/test/subscriptionconfiguration/process/offer-subscription/{offersubscriptionid}", + x => x.HttpMethods == "POST" && x.Url == "api/test/subscriptionconfiguration/process/offer-subscription/{offersubscriptionid}/retrigger-provider-callback") .ConfigureAwait(false); } } diff --git a/tests/administration/Administration.Service.Tests/IntegrationTests/PublicUrlServiceProviderTests.cs b/tests/administration/Administration.Service.Tests/IntegrationTests/PublicUrlServiceProviderTests.cs index 955d0aba1f..e92fa6f7d4 100644 --- a/tests/administration/Administration.Service.Tests/IntegrationTests/PublicUrlServiceProviderTests.cs +++ b/tests/administration/Administration.Service.Tests/IntegrationTests/PublicUrlServiceProviderTests.cs @@ -36,14 +36,14 @@ public PublicUrlServiceProviderTests(IntegrationTestFactory x.HttpMethods == "GET" && x.Url == "api/administration/connectors/managed", - x => x.HttpMethods == "POST" && x.Url == "api/administration/connectors/managed", - x => x.HttpMethods == "POST" && x.Url == "api/administration/connectors/discovery", - x => x.HttpMethods == "GET" && x.Url == "api/administration/documents/selfdescription/{documentid}", - x => x.HttpMethods == "GET" && x.Url == "api/administration/partnernetwork/membercompanies", - x => x.HttpMethods == "GET" && x.Url == "api/administration/subscriptionconfiguration/owncompany", - x => x.HttpMethods == "GET" && x.Url == "api/administration/subscriptionconfiguration/process/offer-subscription/{offersubscriptionid}", - x => x.HttpMethods == "POST" && x.Url == "api/administration/subscriptionconfiguration/process/offer-subscription/{offersubscriptionid}/retrigger-provider-callback") + x => x.HttpMethods == "GET" && x.Url == "api/test/connectors/managed", + x => x.HttpMethods == "POST" && x.Url == "api/test/connectors/managed", + x => x.HttpMethods == "POST" && x.Url == "api/test/connectors/discovery", + x => x.HttpMethods == "GET" && x.Url == "api/test/documents/selfdescription/{documentid}", + x => x.HttpMethods == "GET" && x.Url == "api/test/partnernetwork/membercompanies", + x => x.HttpMethods == "GET" && x.Url == "api/test/subscriptionconfiguration/owncompany", + x => x.HttpMethods == "GET" && x.Url == "api/test/subscriptionconfiguration/process/offer-subscription/{offersubscriptionid}", + x => x.HttpMethods == "POST" && x.Url == "api/test/subscriptionconfiguration/process/offer-subscription/{offersubscriptionid}/retrigger-provider-callback") .ConfigureAwait(false); } } diff --git a/tests/framework/Framework.Token.Tests/Framework.Token.Tests.csproj b/tests/framework/Framework.Token.Tests/Framework.Token.Tests.csproj index c273feb0eb..91ddeaf022 100644 --- a/tests/framework/Framework.Token.Tests/Framework.Token.Tests.csproj +++ b/tests/framework/Framework.Token.Tests/Framework.Token.Tests.csproj @@ -43,6 +43,6 @@ - + diff --git a/tests/framework/Framework.Token.Tests/TokenServiceTests.cs b/tests/framework/Framework.Token.Tests/TokenServiceTests.cs index f6e4c847ea..139c915146 100644 --- a/tests/framework/Framework.Token.Tests/TokenServiceTests.cs +++ b/tests/framework/Framework.Token.Tests/TokenServiceTests.cs @@ -19,7 +19,7 @@ ********************************************************************************/ using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Service; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; using Org.Eclipse.TractusX.Portal.Backend.Framework.Tests.Shared; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; using System.Net; diff --git a/tests/marketplace/Apps.Service.Tests/IntegrationTests/PublicUrlAppProviderTests.cs b/tests/marketplace/Apps.Service.Tests/IntegrationTests/PublicUrlAppProviderTests.cs index 4239e70150..319047c280 100644 --- a/tests/marketplace/Apps.Service.Tests/IntegrationTests/PublicUrlAppProviderTests.cs +++ b/tests/marketplace/Apps.Service.Tests/IntegrationTests/PublicUrlAppProviderTests.cs @@ -37,8 +37,8 @@ public PublicUrlAppProviderTests(IntegrationTestFactory x.HttpMethods == "POST" && x.Url == "api/apps/start-autosetup", - x => x.HttpMethods == "GET" && x.Url == "api/apps/{appid}/subscription/{subscriptionid}/provider") + x => x.HttpMethods == "POST" && x.Url == "api/test/start-autosetup", + x => x.HttpMethods == "GET" && x.Url == "api/test/{appid}/subscription/{subscriptionid}/provider") .ConfigureAwait(false); } } diff --git a/tests/marketplace/Services.Service.Tests/IntegrationTests/PublicUrlServiceProviderTests.cs b/tests/marketplace/Services.Service.Tests/IntegrationTests/PublicUrlServiceProviderTests.cs index e37f90f796..eae8e4e1d7 100644 --- a/tests/marketplace/Services.Service.Tests/IntegrationTests/PublicUrlServiceProviderTests.cs +++ b/tests/marketplace/Services.Service.Tests/IntegrationTests/PublicUrlServiceProviderTests.cs @@ -37,7 +37,7 @@ public PublicUrlServiceProviderTests(IntegrationTestFactory x.HttpMethods == "GET" && x.Url == "api/services/{serviceid}/subscription/{subscriptionid}/provider") + x => x.HttpMethods == "GET" && x.Url == "api/test/{serviceid}/subscription/{subscriptionid}/provider") .ConfigureAwait(false); } } diff --git a/tests/shared/Tests.Shared/IntegrationTests/EndpointSetup/Paths.cs b/tests/shared/Tests.Shared/IntegrationTests/EndpointSetup/Paths.cs index 4786514b8d..f31b006e7a 100644 --- a/tests/shared/Tests.Shared/IntegrationTests/EndpointSetup/Paths.cs +++ b/tests/shared/Tests.Shared/IntegrationTests/EndpointSetup/Paths.cs @@ -23,6 +23,6 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.IntegrationTests.Endp public static class Paths { public static readonly string Base = "/api/"; - public static readonly string Notification = $"{Base}notification"; - public static readonly string Connectors = $"{Base}administration/connectors"; + public static readonly string Notification = $"{Base}test"; + public static readonly string Connectors = $"{Base}test/connectors"; } diff --git a/tests/shared/Tests.Shared/IntegrationTests/IntegrationTestFactory.cs b/tests/shared/Tests.Shared/IntegrationTests/IntegrationTestFactory.cs index 3bab7d76c4..990ffa100c 100644 --- a/tests/shared/Tests.Shared/IntegrationTests/IntegrationTestFactory.cs +++ b/tests/shared/Tests.Shared/IntegrationTests/IntegrationTestFactory.cs @@ -55,6 +55,8 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) var projectDir = Directory.GetCurrentDirectory(); var configPath = Path.Combine(projectDir, "appsettings.IntegrationTests.json"); + Environment.SetEnvironmentVariable("MVC_ROUTING_BASEPATH", "/api/test"); + builder.ConfigureAppConfiguration((_, conf) => { conf.AddJsonFile(configPath, true);