From 0292b26c4db9aa5248052aff6b35ec44b5eaf085 Mon Sep 17 00:00:00 2001 From: Arne Dumarey Date: Fri, 7 Jun 2024 20:20:51 +0200 Subject: [PATCH] feat: remove api legacy --- .github/workflows/release.yml | 45 --- ParcelRegistry.sln | 7 - .../Convertors/ParcelStatus.cs | 25 -- src/ParcelRegistry.Api.Legacy/Dockerfile | 30 -- .../AtomFeedConfigurationBuilder.cs | 37 --- .../AddNoCacheHeadersMiddleware.cs | 23 -- .../Infrastructure/EmptyController.cs | 20 -- .../Infrastructure/Modules/ApiModule.cs | 40 --- .../Infrastructure/Modules/MediatRModule.cs | 27 -- .../Infrastructure/Options/ResponseOptions.cs | 10 - .../Infrastructure/PaginationInfoExtension.cs | 18 -- .../Infrastructure/Program.cs | 30 -- .../Infrastructure/Startup.cs | 158 ----------- .../Parcel/Count/ParcelCountRequest.cs | 14 - .../Parcel/Count/ParcelCountV2Handler.cs | 38 --- .../Parcel/Count/TotalCountResponseExample.cs | 16 -- .../Parcel/Detail/ParcelDetailRequest.cs | 6 - .../Parcel/Detail/ParcelDetailResponse.cs | 122 -------- .../Detail/ParcelDetailResponseWithEtag.cs | 14 - .../Parcel/Detail/ParcelDetailV2Handler.cs | 62 ---- .../Parcel/List/ParcelListRequest.cs | 12 - .../Parcel/List/ParcelListResponse.cs | 110 ------- .../Parcel/List/ParcelListV2Handler.cs | 50 ---- .../Parcel/List/ParcelListV2Query.cs | 92 ------ .../Parcel/List/ParcelListV2QueryItem.cs | 18 -- .../Parcel/ParcelController.cs | 137 --------- .../Parcel/Sync/ParcelSyndicationQuery.cs | 254 ----------------- .../Parcel/Sync/ParcelSyndicationResponse.cs | 268 ------------------ .../Parcel/Sync/SyncHandler.cs | 105 ------- .../Parcel/Sync/SyncRequest.cs | 7 - .../ParcelRegistry.Api.Legacy.csproj | 39 --- .../Properties/AssemblyInfo.cs | 10 - .../Properties/launchSettings.json | 26 -- .../appsettings.json | 53 ---- src/ParcelRegistry.Api.Legacy/init.sh | 7 - .../paket.references | 12 - src/ParcelRegistry.Api.Legacy/paket.template | 31 -- .../ParcelRegistry.Tests.csproj | 2 +- 38 files changed, 1 insertion(+), 1974 deletions(-) delete mode 100755 src/ParcelRegistry.Api.Legacy/Convertors/ParcelStatus.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Dockerfile delete mode 100644 src/ParcelRegistry.Api.Legacy/Infrastructure/AtomFeedConfigurationBuilder.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Infrastructure/Configuration/AddNoCacheHeadersMiddleware.cs delete mode 100755 src/ParcelRegistry.Api.Legacy/Infrastructure/EmptyController.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Infrastructure/Modules/ApiModule.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Infrastructure/Modules/MediatRModule.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Infrastructure/Options/ResponseOptions.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Infrastructure/PaginationInfoExtension.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Infrastructure/Program.cs delete mode 100755 src/ParcelRegistry.Api.Legacy/Infrastructure/Startup.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Parcel/Count/ParcelCountRequest.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Parcel/Count/ParcelCountV2Handler.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Parcel/Count/TotalCountResponseExample.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Parcel/Detail/ParcelDetailRequest.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Parcel/Detail/ParcelDetailResponse.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Parcel/Detail/ParcelDetailResponseWithEtag.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Parcel/Detail/ParcelDetailV2Handler.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListRequest.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListResponse.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListV2Handler.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListV2Query.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListV2QueryItem.cs delete mode 100755 src/ParcelRegistry.Api.Legacy/Parcel/ParcelController.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Parcel/Sync/ParcelSyndicationQuery.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Parcel/Sync/ParcelSyndicationResponse.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Parcel/Sync/SyncHandler.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Parcel/Sync/SyncRequest.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/ParcelRegistry.Api.Legacy.csproj delete mode 100644 src/ParcelRegistry.Api.Legacy/Properties/AssemblyInfo.cs delete mode 100644 src/ParcelRegistry.Api.Legacy/Properties/launchSettings.json delete mode 100755 src/ParcelRegistry.Api.Legacy/appsettings.json delete mode 100755 src/ParcelRegistry.Api.Legacy/init.sh delete mode 100644 src/ParcelRegistry.Api.Legacy/paket.references delete mode 100644 src/ParcelRegistry.Api.Legacy/paket.template diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 028a8d61..a0ca835e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,21 +70,6 @@ jobs: dotnet-version: ${{ vars.VBR_DOTNET_VERSION_8 }} secrets: inherit - build-api-legacy: - name: Build Api Legacy - uses: Informatievlaanderen/build-pipeline/.github/workflows/build-image.yml@main - needs: [ set-release-version ] - if: ${{ (github.repository_owner == 'Informatievlaanderen') && (needs.set-release-version.outputs.version != 'none') }} - with: - registry: ${{ vars.VBR_DEVOPS_DOCKER_REGISTRY }}/parcel-registry - image-file: pr-api-legacy-image.tar - image-name: api-legacy - test-project: ParcelRegistry.Tests - build-project: ParcelRegistry.Api.Legacy - semver: ${{ needs.set-release-version.outputs.version }} - dotnet-version: ${{ vars.VBR_DOTNET_VERSION_8 }} - secrets: inherit - build-api-oslo: name: Build Api Oslo uses: Informatievlaanderen/build-pipeline/.github/workflows/build-image.yml@main @@ -262,19 +247,6 @@ jobs: dotnet-version: ${{ vars.VBR_DOTNET_VERSION_8 }} secrets: inherit - pack-api-legacy: - name: Pack Api Legacy - uses: Informatievlaanderen/build-pipeline/.github/workflows/pack.yml@main - needs: [ set-release-version ] - if: ${{ (github.repository_owner == 'Informatievlaanderen') && (needs.set-release-version.outputs.version != 'none') }} - with: - pack-file: Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.Legacy - test-project: ParcelRegistry.Tests - build-project: ParcelRegistry.Api.Legacy - semver: ${{ needs.set-release-version.outputs.version }} - dotnet-version: ${{ vars.VBR_DOTNET_VERSION_8 }} - secrets: inherit - pack-api-oslo: name: Pack Api Oslo uses: Informatievlaanderen/build-pipeline/.github/workflows/pack.yml@main @@ -321,11 +293,9 @@ jobs: needs: [ set-release-version, #pack-api-backoffice, pack-api-backoffice-abstractions, - pack-api-legacy, pack-api-oslo, pack-api-extract, build-api-backoffice, - build-api-legacy, build-api-oslo, build-api-extract, build-projector, @@ -406,13 +376,6 @@ jobs: name: nuget-Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.BackOffice.Abstractions-${{ needs.set-release-version.outputs.version }} path: dist/nuget/ - - name: Download NuGet Api Legacy - uses: actions/download-artifact@v4 - continue-on-error: false - with: - name: nuget-Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.Legacy-${{ needs.set-release-version.outputs.version }} - path: dist/nuget/ - - name: Download NuGet Api Oslo uses: actions/download-artifact@v4 continue-on-error: false @@ -560,12 +523,6 @@ jobs: name: nuget-Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.BackOffice.Abstractions-${{ needs.release.outputs.version }} path: ~/ - - name: Download NuGet package api-legacy - uses: actions/download-artifact@v4 - with: - name: nuget-Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.Legacy-${{ needs.release.outputs.version }} - path: ~/ - - name: Download NuGet package api-oslo uses: actions/download-artifact@v4 with: @@ -583,7 +540,6 @@ jobs: # dotnet nuget push ~/Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.BackOffice.$SEMVER.nupkg --source nuget.org --api-key $NUGET_API_KEY run: | dotnet nuget push ~/Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.BackOffice.Abstractions.$SEMVER.nupkg --source nuget.org --api-key $NUGET_API_KEY - dotnet nuget push ~/Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.Legacy.$SEMVER.nupkg --source nuget.org --api-key $NUGET_API_KEY dotnet nuget push ~/Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.Oslo.$SEMVER.nupkg --source nuget.org --api-key $NUGET_API_KEY dotnet nuget push ~/Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.Extract.$SEMVER.nupkg --source nuget.org --api-key $NUGET_API_KEY env: @@ -661,7 +617,6 @@ jobs: matrix: image: [ 'api-backoffice', - 'api-legacy', 'api-oslo', 'api-extract', 'projector', diff --git a/ParcelRegistry.sln b/ParcelRegistry.sln index b520ac99..e2ee14b7 100644 --- a/ParcelRegistry.sln +++ b/ParcelRegistry.sln @@ -23,8 +23,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{A1CB15D5-7 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ParcelRegistry", "src\ParcelRegistry\ParcelRegistry.csproj", "{8FE01FF7-515C-448A-A549-EE56080BE1BA}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ParcelRegistry.Api.Legacy", "src\ParcelRegistry.Api.Legacy\ParcelRegistry.Api.Legacy.csproj", "{2343237C-031B-4896-9958-57519E455DE1}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ParcelRegistry.Infrastructure", "src\ParcelRegistry.Infrastructure\ParcelRegistry.Infrastructure.csproj", "{1F7349F4-ACAB-4DAC-8476-71736E65FE41}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ParcelRegistry.Projections.Legacy", "src\ParcelRegistry.Projections.Legacy\ParcelRegistry.Projections.Legacy.csproj", "{713526B9-1FE5-409E-8754-11B8B50E3BC1}" @@ -85,10 +83,6 @@ Global {8FE01FF7-515C-448A-A549-EE56080BE1BA}.Debug|Any CPU.Build.0 = Debug|Any CPU {8FE01FF7-515C-448A-A549-EE56080BE1BA}.Release|Any CPU.ActiveCfg = Release|Any CPU {8FE01FF7-515C-448A-A549-EE56080BE1BA}.Release|Any CPU.Build.0 = Release|Any CPU - {2343237C-031B-4896-9958-57519E455DE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2343237C-031B-4896-9958-57519E455DE1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2343237C-031B-4896-9958-57519E455DE1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2343237C-031B-4896-9958-57519E455DE1}.Release|Any CPU.Build.0 = Release|Any CPU {1F7349F4-ACAB-4DAC-8476-71736E65FE41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1F7349F4-ACAB-4DAC-8476-71736E65FE41}.Debug|Any CPU.Build.0 = Debug|Any CPU {1F7349F4-ACAB-4DAC-8476-71736E65FE41}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -183,7 +177,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {8FE01FF7-515C-448A-A549-EE56080BE1BA} = {B483712F-241C-411F-8CC7-D46B3530DF65} - {2343237C-031B-4896-9958-57519E455DE1} = {B483712F-241C-411F-8CC7-D46B3530DF65} {1F7349F4-ACAB-4DAC-8476-71736E65FE41} = {B483712F-241C-411F-8CC7-D46B3530DF65} {713526B9-1FE5-409E-8754-11B8B50E3BC1} = {B483712F-241C-411F-8CC7-D46B3530DF65} {951C912B-E9B2-4941-BE18-C5125FC0D9E6} = {DF5FFD7D-3020-4F80-87EF-BE2D2CACD27E} diff --git a/src/ParcelRegistry.Api.Legacy/Convertors/ParcelStatus.cs b/src/ParcelRegistry.Api.Legacy/Convertors/ParcelStatus.cs deleted file mode 100755 index feabe183..00000000 --- a/src/ParcelRegistry.Api.Legacy/Convertors/ParcelStatus.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Convertors -{ - using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Perceel; - using ParcelRegistry.Legacy; - - public static class ParcelStatusExtensions - { - public static PerceelStatus? MapToPerceelStatusSyndication(this ParcelStatus? status) - => status.HasValue ? MapToPerceelStatus(status.Value) : (PerceelStatus?)null; - - public static PerceelStatus MapToPerceelStatus(this ParcelStatus parcelStatus) - => parcelStatus == ParcelStatus.Retired - ? PerceelStatus.Gehistoreerd - : PerceelStatus.Gerealiseerd; - public static ParcelStatus MapToParcelStatus(this PerceelStatus perceelStatus) - => perceelStatus == PerceelStatus.Gehistoreerd - ? ParcelStatus.Retired - : ParcelStatus.Realized; - - public static PerceelStatus MapToPerceelStatus(this ParcelRegistry.Parcel.ParcelStatus parcelStatus) - => parcelStatus == ParcelStatus.Retired - ? PerceelStatus.Gehistoreerd - : PerceelStatus.Gerealiseerd; - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Dockerfile b/src/ParcelRegistry.Api.Legacy/Dockerfile deleted file mode 100644 index 1e3e8fe5..00000000 --- a/src/ParcelRegistry.Api.Legacy/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -FROM mcr.microsoft.com/dotnet/runtime-deps:8.0.2-bookworm-slim-amd64 - -# create work dir and set permissions as WORKDIR sets permissions as root -RUN mkdir /app && chown -R app:app /app -WORKDIR /app - -LABEL maintainer="Digitaal Vlaanderen " -LABEL registry="parcel-registry" - -COPY / /app -WORKDIR /app - -RUN apt-get update && \ - apt-get install curl jq -y && \ - chmod +x ./init.sh - -EXPOSE 7002/tcp -ENV ASPNETCORE_URLS http://*:7002 -ENV CORECLR_ENABLE_PROFILING=1 -ENV CORECLR_PROFILER={846F5F1C-F9AE-4B07-969E-05C26BC060D8} -ENV CORECLR_PROFILER_PATH=/app/datadog/linux-x64/Datadog.Trace.ClrProfiler.Native.so -ENV DD_DOTNET_TRACER_HOME=/app/datadog - -# Run the createLogPath script on Linux to ensure the automatic instrumentation logs are generated without permission issues -RUN /app/datadog/createLogPath.sh - -# switch to created user -USER app - -ENTRYPOINT ["./init.sh"] diff --git a/src/ParcelRegistry.Api.Legacy/Infrastructure/AtomFeedConfigurationBuilder.cs b/src/ParcelRegistry.Api.Legacy/Infrastructure/AtomFeedConfigurationBuilder.cs deleted file mode 100644 index fb306013..00000000 --- a/src/ParcelRegistry.Api.Legacy/Infrastructure/AtomFeedConfigurationBuilder.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Infrastructure -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Reflection; - using Be.Vlaanderen.Basisregisters.Api.Syndication; - using Microsoft.Extensions.Configuration; - using Microsoft.SyndicationFeed; - using Microsoft.SyndicationFeed.Atom; - - public static class AtomFeedConfigurationBuilder - { - public static AtomFeedConfiguration CreateFrom(IConfigurationSection configuration, DateTimeOffset lastUpdated) - { - return new AtomFeedConfiguration( - configuration["Id"], - configuration["Title"], - configuration["Subtitle"], - configuration["GeneratorTitle"], - configuration["GeneratorUri"], - Assembly.GetEntryAssembly()?.GetName().Version?.ToString(), - configuration["Rights"], - lastUpdated, - new SyndicationPerson(configuration["AuthorName"], configuration["AuthorEmail"], AtomContributorTypes.Author), - new SyndicationLink(new Uri(configuration["Self"]), AtomLinkTypes.Self), - new List(), - configuration - .GetSection("Related") - .GetChildren() - .Select(c => - new SyndicationLink(new Uri(c.Value), AtomLinkTypes.Related)) - .ToList() - ); - } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Infrastructure/Configuration/AddNoCacheHeadersMiddleware.cs b/src/ParcelRegistry.Api.Legacy/Infrastructure/Configuration/AddNoCacheHeadersMiddleware.cs deleted file mode 100644 index aeb02cea..00000000 --- a/src/ParcelRegistry.Api.Legacy/Infrastructure/Configuration/AddNoCacheHeadersMiddleware.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Infrastructure.Configuration -{ - using System.Threading.Tasks; - using Microsoft.AspNetCore.Http; - - /// - /// Add headers to the response to prevent any caching. - /// - public class AddNoCacheHeadersMiddleware - { - private readonly RequestDelegate _next; - - public AddNoCacheHeadersMiddleware(RequestDelegate next) => _next = next; - - public Task Invoke(HttpContext context) - { - context.Response.Headers.Add("cache-control", "no-store, no-cache, must-revalidate"); - context.Response.Headers.Add("pragma", "no-cache"); - - return _next(context); - } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Infrastructure/EmptyController.cs b/src/ParcelRegistry.Api.Legacy/Infrastructure/EmptyController.cs deleted file mode 100755 index e75b88ff..00000000 --- a/src/ParcelRegistry.Api.Legacy/Infrastructure/EmptyController.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Infrastructure -{ - using System.Reflection; - using Asp.Versioning; - using Microsoft.AspNetCore.Mvc; - using Microsoft.Net.Http.Headers; - using Be.Vlaanderen.Basisregisters.Api; - - [ApiVersionNeutral] - [Route("")] - public class EmptyController : ApiController - { - [HttpGet] - [ApiExplorerSettings(IgnoreApi = true)] - public IActionResult Get() - => Request.Headers[HeaderNames.Accept].ToString().Contains("text/html") - ? (IActionResult)new RedirectResult("/docs") - : new OkObjectResult($"Welcome to the Basisregisters Vlaanderen Parcel Legacy Api {Assembly.GetEntryAssembly().GetVersionText()}."); - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Infrastructure/Modules/ApiModule.cs b/src/ParcelRegistry.Api.Legacy/Infrastructure/Modules/ApiModule.cs deleted file mode 100644 index bbbacdc1..00000000 --- a/src/ParcelRegistry.Api.Legacy/Infrastructure/Modules/ApiModule.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Infrastructure.Modules -{ - using Autofac; - using Autofac.Extensions.DependencyInjection; - using Be.Vlaanderen.Basisregisters.Api.Exceptions; - using Microsoft.Extensions.Configuration; - using Microsoft.Extensions.DependencyInjection; - using Microsoft.Extensions.Logging; - using Projections.Legacy; - - public class ApiModule : Module - { - private readonly IConfiguration _configuration; - private readonly IServiceCollection _services; - private readonly ILoggerFactory _loggerFactory; - - public ApiModule( - IConfiguration configuration, - IServiceCollection services, - ILoggerFactory loggerFactory) - { - _configuration = configuration; - _services = services; - _loggerFactory = loggerFactory; - } - - protected override void Load(ContainerBuilder builder) - { - builder - .RegisterModule(new MediatRModule()) - .RegisterModule(new LegacyModule(_configuration, _services, _loggerFactory)); - - builder - .RegisterType() - .AsSelf(); - - builder.Populate(_services); - } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Infrastructure/Modules/MediatRModule.cs b/src/ParcelRegistry.Api.Legacy/Infrastructure/Modules/MediatRModule.cs deleted file mode 100644 index 53629b9a..00000000 --- a/src/ParcelRegistry.Api.Legacy/Infrastructure/Modules/MediatRModule.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Infrastructure.Modules -{ - using Autofac; - using MediatR; - using Parcel.Count; - using Parcel.List; - using Parcel.Sync; - using ParcelRegistry.Api.Legacy.Parcel.Detail; - using Module = Autofac.Module; - - public class MediatRModule : Module - { - protected override void Load(ContainerBuilder builder) - { - builder - .RegisterType() - .As() - .InstancePerLifetimeScope(); - - builder.RegisterType().AsImplementedInterfaces(); - - builder.RegisterType().AsImplementedInterfaces(); - builder.RegisterType().AsImplementedInterfaces(); - builder.RegisterType().AsImplementedInterfaces(); - } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Infrastructure/Options/ResponseOptions.cs b/src/ParcelRegistry.Api.Legacy/Infrastructure/Options/ResponseOptions.cs deleted file mode 100644 index 220f5aaf..00000000 --- a/src/ParcelRegistry.Api.Legacy/Infrastructure/Options/ResponseOptions.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Infrastructure.Options -{ - public class ResponseOptions - { - public string Naamruimte { get; set; } - public string VolgendeUrl { get; set; } - public string DetailUrl { get; set; } - public string AdresDetailUrl { get; set; } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Infrastructure/PaginationInfoExtension.cs b/src/ParcelRegistry.Api.Legacy/Infrastructure/PaginationInfoExtension.cs deleted file mode 100644 index 3d12c165..00000000 --- a/src/ParcelRegistry.Api.Legacy/Infrastructure/PaginationInfoExtension.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Infrastructure -{ - using System; - using Be.Vlaanderen.Basisregisters.Api.Search.Pagination; - - public static class PaginationInfoExtension - { - public static Uri? BuildVolgendeUri(this PaginationInfo paginationInfo, int itemsInCollection, string nextUrlBase) - { - var offset = paginationInfo.Offset; - var limit = paginationInfo.Limit; - - return paginationInfo.HasNextPage(itemsInCollection) - ? new Uri(string.Format(nextUrlBase, offset + limit, limit)) - : null; - } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Infrastructure/Program.cs b/src/ParcelRegistry.Api.Legacy/Infrastructure/Program.cs deleted file mode 100644 index df5fdefb..00000000 --- a/src/ParcelRegistry.Api.Legacy/Infrastructure/Program.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Infrastructure -{ - using Be.Vlaanderen.Basisregisters.Api; - using Microsoft.AspNetCore.Hosting; - - public static class Program - { - public static void Main(string[] args) => CreateWebHostBuilder(args).Build().Run(); - - public static IWebHostBuilder CreateWebHostBuilder(string[] args) - => new WebHostBuilder() - .UseDefaultForApi( - new ProgramOptions - { - Hosting = - { - HttpPort = 7002 - }, - Logging = - { - WriteTextToConsole = false, - WriteJsonToConsole = false - }, - Runtime = - { - CommandLineArgs = args - } - }); - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Infrastructure/Startup.cs b/src/ParcelRegistry.Api.Legacy/Infrastructure/Startup.cs deleted file mode 100755 index eb84fe75..00000000 --- a/src/ParcelRegistry.Api.Legacy/Infrastructure/Startup.cs +++ /dev/null @@ -1,158 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Infrastructure -{ - using System; - using System.Linq; - using System.Reflection; - using Asp.Versioning.ApiExplorer; - using Autofac; - using Autofac.Extensions.DependencyInjection; - using Be.Vlaanderen.Basisregisters.Api; - using Configuration; - using Microsoft.AspNetCore.Builder; - using Microsoft.AspNetCore.Hosting; - using Microsoft.Extensions.Configuration; - using Microsoft.Extensions.DependencyInjection; - using Microsoft.Extensions.Diagnostics.HealthChecks; - using Microsoft.Extensions.Hosting; - using Microsoft.Extensions.Logging; - using Microsoft.OpenApi.Models; - using Modules; - using Options; - - /// Represents the startup process for the application. - public class Startup - { - private const string DatabaseTag = "db"; - - private IContainer _applicationContainer; - - private readonly IConfiguration _configuration; - private readonly ILoggerFactory _loggerFactory; - - public Startup( - IConfiguration configuration, - ILoggerFactory loggerFactory) - { - _configuration = configuration; - _loggerFactory = loggerFactory; - } - - /// Configures services for the application. - /// The collection of services to configure the application with. - public IServiceProvider ConfigureServices(IServiceCollection services) - { - var baseUrl = _configuration.GetValue("BaseUrl"); - var baseUrlForExceptions = baseUrl.EndsWith("/") - ? baseUrl.Substring(0, baseUrl.Length - 1) - : baseUrl; - - services - .ConfigureDefaultForApi(new StartupConfigureOptions - { - Cors = - { - Origins = _configuration - .GetSection("Cors") - .GetChildren() - .Select(c => c.Value) - .ToArray() - }, - Server = - { - BaseUrl = baseUrlForExceptions - }, - Swagger = - { - ApiInfo = (provider, description) => new OpenApiInfo - { - Version = description.ApiVersion.ToString(), - Title = "Basisregisters Vlaanderen Parcel Registry API", - Description = GetApiLeadingText(description), - Contact = new OpenApiContact - { - Name = "Digitaal Vlaanderen", - Email = "digitaal.vlaanderen@vlaanderen.be", - Url = new Uri("https://legacy.basisregisters.vlaanderen") - } - }, - XmlCommentPaths = new[] {typeof(Startup).GetTypeInfo().Assembly.GetName().Name} - }, - MiddlewareHooks = - { - FluentValidation = fv => fv.RegisterValidatorsFromAssemblyContaining(), - - AfterHealthChecks = health => - { - var connectionStrings = _configuration - .GetSection("ConnectionStrings") - .GetChildren(); - - foreach (var connectionString in connectionStrings) - health.AddSqlServer( - connectionString.Value, - name: $"sqlserver-{connectionString.Key.ToLowerInvariant()}", - tags: new[] { DatabaseTag, "sql", "sqlserver" }); - } - } - }) - .Configure(_configuration); - - var containerBuilder = new ContainerBuilder(); - containerBuilder.RegisterModule(new ApiModule(_configuration, services, _loggerFactory)); - _applicationContainer = containerBuilder.Build(); - - return new AutofacServiceProvider(_applicationContainer); - } - - public void Configure( - IServiceProvider serviceProvider, - IApplicationBuilder app, - IWebHostEnvironment env, - IHostApplicationLifetime appLifetime, - ILoggerFactory loggerFactory, - IApiVersionDescriptionProvider apiVersionProvider, - HealthCheckService healthCheckService) - { - StartupHelpers.CheckDatabases(healthCheckService, DatabaseTag, loggerFactory).GetAwaiter().GetResult(); - - app - .UseDefaultForApi(new StartupUseOptions - { - Common = - { - ApplicationContainer = _applicationContainer, - ServiceProvider = serviceProvider, - HostingEnvironment = env, - ApplicationLifetime = appLifetime, - LoggerFactory = loggerFactory, - }, - Api = - { - VersionProvider = apiVersionProvider, - Info = groupName => $"Basisregisters Vlaanderen - Parcel Registry API {groupName}", - CSharpClientOptions = - { - ClassName = "ParcelRegistry", - Namespace = "Be.Vlaanderen.Basisregisters" - }, - TypeScriptClientOptions = - { - ClassName = "ParcelRegistry" - } - }, - Server = - { - PoweredByName = "Vlaamse overheid - Basisregisters Vlaanderen", - ServerName = "Digitaal Vlaanderen" - }, - MiddlewareHooks = - { - AfterMiddleware = x => x.UseMiddleware(), - } - }); - } - - private static string GetApiLeadingText(ApiVersionDescription description) - => $"Momenteel leest u de documentatie voor versie {description.ApiVersion} van de Basisregisters Vlaanderen Parcel Registry API{string.Format(description.IsDeprecated ? ", **deze API versie is niet meer ondersteund * *." : ".")}"; - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/Count/ParcelCountRequest.cs b/src/ParcelRegistry.Api.Legacy/Parcel/Count/ParcelCountRequest.cs deleted file mode 100644 index 798e3cac..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/Count/ParcelCountRequest.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Parcel.Count -{ - using Be.Vlaanderen.Basisregisters.Api.Search.Filtering; - using Be.Vlaanderen.Basisregisters.Api.Search.Pagination; - using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - using List; - using MediatR; - - public record ParcelCountRequest( - FilteringHeader Filtering, - SortingHeader Sorting, - IPaginationRequest Pagination) : IRequest; -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/Count/ParcelCountV2Handler.cs b/src/ParcelRegistry.Api.Legacy/Parcel/Count/ParcelCountV2Handler.cs deleted file mode 100644 index 6f15f809..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/Count/ParcelCountV2Handler.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Parcel.Count -{ - using System; - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - using List; - using MediatR; - using Microsoft.EntityFrameworkCore; - using ParcelRegistry.Projections.Legacy; - - public class ParcelCountV2Handler : IRequestHandler - { - private readonly LegacyContext _context; - - public ParcelCountV2Handler(LegacyContext context) - { - _context = context; - } - - public async Task Handle(ParcelCountRequest request, CancellationToken cancellationToken) - { - return new TotaalAantalResponse - { - Aantal = request.Filtering.ShouldFilter - ? await new ParcelListV2Query(_context) - .Fetch(request.Filtering, request.Sorting, request.Pagination) - .Items - .CountAsync(cancellationToken) - : Convert.ToInt32(_context - .ParcelDetailV2ListViewCount - .First() - .Count) - }; - } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/Count/TotalCountResponseExample.cs b/src/ParcelRegistry.Api.Legacy/Parcel/Count/TotalCountResponseExample.cs deleted file mode 100644 index 1cf14b94..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/Count/TotalCountResponseExample.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Parcel.Count -{ - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - using Swashbuckle.AspNetCore.Filters; - - public class TotalCountResponseExample : IExamplesProvider - { - public TotaalAantalResponse GetExamples() - { - return new TotaalAantalResponse - { - Aantal = 574512 - }; - } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/Detail/ParcelDetailRequest.cs b/src/ParcelRegistry.Api.Legacy/Parcel/Detail/ParcelDetailRequest.cs deleted file mode 100644 index a9cde6b7..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/Detail/ParcelDetailRequest.cs +++ /dev/null @@ -1,6 +0,0 @@ -using MediatR; - -namespace ParcelRegistry.Api.Legacy.Parcel.Detail -{ - public record ParcelDetailRequest(string CaPaKey) : IRequest; -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/Detail/ParcelDetailResponse.cs b/src/ParcelRegistry.Api.Legacy/Parcel/Detail/ParcelDetailResponse.cs deleted file mode 100644 index c9dbd215..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/Detail/ParcelDetailResponse.cs +++ /dev/null @@ -1,122 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Parcel.Detail -{ - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Perceel; - using Infrastructure.Options; - using Microsoft.AspNetCore.Http; - using Microsoft.Extensions.Options; - using Swashbuckle.AspNetCore.Filters; - using System; - using System.Collections.Generic; - using System.Linq; - using System.Runtime.Serialization; - using Be.Vlaanderen.Basisregisters.Api.Exceptions; - using Be.Vlaanderen.Basisregisters.GrAr.Common; - using Newtonsoft.Json; - using ProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ProblemDetails; - - [DataContract(Name = "PerceelDetail", Namespace = "")] - public class ParcelDetailResponse - { - /// - /// De identificator van het perceel. - /// - [DataMember(Name = "Identificator", Order = 1)] - [JsonProperty(Required = Required.DisallowNull)] - public PerceelIdentificator Identificator { get; set; } - - /// - /// De status van het perceel - /// - [DataMember(Name = "PerceelStatus", Order = 2)] - [JsonProperty(Required = Required.DisallowNull)] - public PerceelStatus PerceelStatus { get; set; } - - /// - /// De aan het perceel gekoppelde adressen. - /// - [DataMember(Name = "Adressen", Order = 3)] - [JsonProperty(Required = Required.DisallowNull)] - public List Adressen { get; set; } - - public ParcelDetailResponse( - string naamruimte, - PerceelStatus status, - string caPaKey, - DateTimeOffset version, - List addressPersistentLocalIds, - string adresDetailUrl) - { - Identificator = new PerceelIdentificator(naamruimte, caPaKey, version); - PerceelStatus = status; - - Adressen = addressPersistentLocalIds - .Where(x => !string.IsNullOrWhiteSpace(x)) - .Select(x => PerceelDetailAdres.Create(x, new Uri(string.Format(adresDetailUrl, x)))) - .ToList(); - } - } - - public class ParcelResponseExamples : IExamplesProvider - { - private readonly ResponseOptions _responseOptions; - - public ParcelResponseExamples(IOptions responseOptionsProvider) - => _responseOptions = responseOptionsProvider.Value; - - public ParcelDetailResponse GetExamples() - => new ParcelDetailResponse( - _responseOptions.Naamruimte, - PerceelStatus.Gerealiseerd, - "11001B0001-00S000", - DateTimeOffset.Now.ToExampleOffset(), - new List { "200001" }, - _responseOptions.AdresDetailUrl); - } - - public class ParcelNotFoundResponseExamples : IExamplesProvider - { - private readonly IHttpContextAccessor _httpContextAccessor; - private readonly ProblemDetailsHelper _problemDetailsHelper; - - public ParcelNotFoundResponseExamples( - IHttpContextAccessor httpContextAccessor, - ProblemDetailsHelper problemDetailsHelper) - { - _httpContextAccessor = httpContextAccessor; - _problemDetailsHelper = problemDetailsHelper; - } - - public ProblemDetails GetExamples() => new ProblemDetails - { - ProblemTypeUri = "urn:be.vlaanderen.basisregisters.api:parcel:not-found", - HttpStatus = StatusCodes.Status404NotFound, - Title = ProblemDetails.DefaultTitle, - Detail = "Onbestaand perceel.", - ProblemInstanceUri = _problemDetailsHelper.GetInstanceUri(_httpContextAccessor.HttpContext, "v1") - }; - } - - public class ParcelGoneResponseExamples : IExamplesProvider - { - private readonly IHttpContextAccessor _httpContextAccessor; - private readonly ProblemDetailsHelper _problemDetailsHelper; - - public ParcelGoneResponseExamples( - IHttpContextAccessor httpContextAccessor, - ProblemDetailsHelper problemDetailsHelper) - { - _httpContextAccessor = httpContextAccessor; - _problemDetailsHelper = problemDetailsHelper; - } - - public ProblemDetails GetExamples() => new ProblemDetails - { - ProblemTypeUri = "urn:be.vlaanderen.basisregisters.api:parcel:gone", - HttpStatus = StatusCodes.Status410Gone, - Title = ProblemDetails.DefaultTitle, - Detail = "Verwijderd perceel.", - ProblemInstanceUri = _problemDetailsHelper.GetInstanceUri(_httpContextAccessor.HttpContext, "v1") - }; - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/Detail/ParcelDetailResponseWithEtag.cs b/src/ParcelRegistry.Api.Legacy/Parcel/Detail/ParcelDetailResponseWithEtag.cs deleted file mode 100644 index bcb8af44..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/Detail/ParcelDetailResponseWithEtag.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Parcel.Detail -{ - public class ParcelResponseWithEtag - { - public ParcelDetailResponse ParcelResponse { get; } - public string? LastEventHash { get; } - - public ParcelResponseWithEtag(ParcelDetailResponse parcelResponse, string? lastEventHash = null) - { - ParcelResponse = parcelResponse; - LastEventHash = lastEventHash; - } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/Detail/ParcelDetailV2Handler.cs b/src/ParcelRegistry.Api.Legacy/Parcel/Detail/ParcelDetailV2Handler.cs deleted file mode 100644 index ca9d2e03..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/Detail/ParcelDetailV2Handler.cs +++ /dev/null @@ -1,62 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Parcel.Detail -{ - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - using Be.Vlaanderen.Basisregisters.Api.Exceptions; - using Be.Vlaanderen.Basisregisters.GrAr.Common; - using Convertors; - using Infrastructure.Options; - using MediatR; - using Microsoft.AspNetCore.Http; - using Microsoft.EntityFrameworkCore; - using Microsoft.Extensions.Options; - using Projections.Legacy; - - public class ParcelDetailV2Handler : IRequestHandler - { - private readonly LegacyContext _context; - private readonly IOptions _responseOptions; - - public ParcelDetailV2Handler( - LegacyContext context, - IOptions responseOptions) - { - _context = context; - _responseOptions = responseOptions; - } - - public async Task Handle(ParcelDetailRequest request, CancellationToken cancellationToken) - { - var parcel = - await _context - .ParcelDetailWithCountV2 - .Include(x => x.Addresses) - .AsNoTracking() - .SingleOrDefaultAsync(item => item.CaPaKey == request.CaPaKey, cancellationToken); - - if (parcel is null) - { - throw new ApiException("Onbestaand perceel.", StatusCodes.Status404NotFound); - } - - if (parcel is { Removed: true }) - { - throw new ApiException("Perceel werd verwijderd.", StatusCodes.Status410Gone); - } - - var response = new ParcelDetailResponse( - _responseOptions.Value.Naamruimte, - parcel.Status.MapToPerceelStatus(), - parcel.CaPaKey, - parcel.VersionTimestamp.ToBelgianDateTimeOffset(), - parcel.Addresses - .Select(x => x.AddressPersistentLocalId.ToString()) - .OrderBy(x => x) - .ToList(), - _responseOptions.Value.AdresDetailUrl); - - return new ParcelResponseWithEtag(response, parcel.LastEventHash); - } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListRequest.cs b/src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListRequest.cs deleted file mode 100644 index e49ae060..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListRequest.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Parcel.List -{ - using Be.Vlaanderen.Basisregisters.Api.Search.Filtering; - using Be.Vlaanderen.Basisregisters.Api.Search.Pagination; - using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; - using MediatR; - - public record ParcelListRequest( - FilteringHeader Filtering, - SortingHeader Sorting, - IPaginationRequest Pagination) : IRequest; -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListResponse.cs b/src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListResponse.cs deleted file mode 100644 index 58ce744b..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListResponse.cs +++ /dev/null @@ -1,110 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Parcel.List -{ - using System; - using System.Collections.Generic; - using System.Runtime.Serialization; - using Be.Vlaanderen.Basisregisters.Api.Search.Pagination; - using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; - using Be.Vlaanderen.Basisregisters.GrAr.Common; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Perceel; - using Microsoft.Extensions.Options; - using Newtonsoft.Json; - using ParcelRegistry.Api.Legacy.Infrastructure.Options; - using Swashbuckle.AspNetCore.Filters; - - [DataContract(Name = "PerceelCollectie", Namespace = "")] - public class ParcelListResponse - { - /// - /// De verzameling van percelen. - /// - [DataMember(Name = "Percelen", Order = 0)] - [JsonProperty(Required = Required.DisallowNull)] - public List Percelen { get; set; } - - /// - /// Het totaal aantal percelen die overeenkomen met de vraag. - /// - //[DataMember(Name = "TotaalAantal", Order = 1)] - //[JsonProperty(Required = Required.DisallowNull)] - //public long TotaalAantal { get; set; } - - /// - /// De URL voor het ophalen van de volgende verzameling. - /// - [DataMember(Name = "Volgende", Order = 2, EmitDefaultValue = false)] - [JsonProperty(Required = Required.Default, DefaultValueHandling = DefaultValueHandling.Ignore)] - public Uri Volgende { get; set; } - - [JsonIgnore] - [IgnoreDataMember] - public SortingHeader Sorting { get; set; } - - [JsonIgnore] - [IgnoreDataMember] - public PaginationInfo Pagination { get; set; } - } - - [DataContract(Name = "PerceelCollectieItem", Namespace = "")] - public class ParcelListItemResponse - { - /// - /// De identificator van het perceel. - /// - [DataMember(Name = "Identificator", Order = 1)] - [JsonProperty(Required = Required.DisallowNull)] - public PerceelIdentificator Identificator { get; set; } - - /// - /// De URL die de details van de meest recente versie van het perceel weergeeft. - /// - [DataMember(Name = "Detail", Order = 2)] - [JsonProperty(Required = Required.DisallowNull)] - public Uri Detail { get; set; } - - /// - /// De status van het perceel - /// - [DataMember(Name = "PerceelStatus", Order = 3)] - [JsonProperty(Required = Required.DisallowNull)] - public PerceelStatus PerceelStatus { get; set; } - - public ParcelListItemResponse( - string id, - string naamruimte, - string detail, - PerceelStatus status, - DateTimeOffset version) - { - Identificator = new PerceelIdentificator(naamruimte, id, version); - Detail = new Uri(string.Format(detail, id)); - PerceelStatus = status; - } - } - - public class ParcelListResponseExamples : IExamplesProvider - { - private readonly ResponseOptions _responseOptions; - - public ParcelListResponseExamples(IOptions responseOptionsProvider) - { - _responseOptions = responseOptionsProvider.Value; - } - - public ParcelListResponse GetExamples() - { - var samples = new List - { - new ParcelListItemResponse("11001B0001-00S000", _responseOptions.Naamruimte, _responseOptions.DetailUrl, PerceelStatus.Gerealiseerd, DateTimeOffset.Now.ToExampleOffset()), - new ParcelListItemResponse("11001B0009-00G004", _responseOptions.Naamruimte, _responseOptions.DetailUrl, PerceelStatus.Gerealiseerd, DateTimeOffset.Now.AddHours(-40).ToExampleOffset()) - }; - - return new ParcelListResponse - { - Percelen = samples, - Volgende = new Uri(string.Format(_responseOptions.VolgendeUrl, 2, 10)) - }; - } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListV2Handler.cs b/src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListV2Handler.cs deleted file mode 100644 index 72a7dfa8..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListV2Handler.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Parcel.List -{ - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - using Be.Vlaanderen.Basisregisters.GrAr.Common; - using MediatR; - using Microsoft.EntityFrameworkCore; - using Microsoft.Extensions.Options; - using Convertors; - using Infrastructure; - using Infrastructure.Options; - using ParcelRegistry.Projections.Legacy; - - public class ParcelListV2Handler : IRequestHandler - { - private readonly LegacyContext _context; - private readonly IOptions _responseOptions; - - public ParcelListV2Handler( - LegacyContext context, - IOptions responseOptions) - { - _context = context; - _responseOptions = responseOptions; - } - public async Task Handle(ParcelListRequest request, CancellationToken cancellationToken) - { - var pagedParcels = new ParcelListV2Query(_context) - .Fetch(request.Filtering, request.Sorting, request.Pagination); - - var parcelListItemResponses = await pagedParcels.Items - .Select(m => new ParcelListItemResponse( - m.CaPaKey, - _responseOptions.Value.Naamruimte, - _responseOptions.Value.DetailUrl, - m.Status.MapToPerceelStatus(), - m.VersionTimestamp.ToBelgianDateTimeOffset())) - .ToListAsync(cancellationToken); - - return new ParcelListResponse - { - Percelen = parcelListItemResponses, - Volgende = pagedParcels.PaginationInfo.BuildVolgendeUri(parcelListItemResponses.Count, _responseOptions.Value.VolgendeUrl), - Sorting = pagedParcels.Sorting, - Pagination = pagedParcels.PaginationInfo - }; - } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListV2Query.cs b/src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListV2Query.cs deleted file mode 100644 index dea4df14..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListV2Query.cs +++ /dev/null @@ -1,92 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Parcel.List -{ - using System; - using System.Collections.Generic; - using System.Linq; - using Be.Vlaanderen.Basisregisters.Api.Search; - using Be.Vlaanderen.Basisregisters.Api.Search.Filtering; - using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Perceel; - using Convertors; - using Microsoft.EntityFrameworkCore; - using ParcelRegistry.Projections.Legacy; - using Projections.Legacy.ParcelDetail; - - public class ParcelListV2Query : Query - { - private readonly LegacyContext _context; - - protected override ISorting Sorting => new ParcelSortingV2(); - - public ParcelListV2Query(LegacyContext context) => _context = context; - - protected override IQueryable Filter(FilteringHeader filtering) - { - var parcels = _context - .ParcelDetailWithCountV2 - .AsNoTracking() - .OrderBy(x => x.CaPaKey) - .Where(x => !x.Removed); - - if (!filtering.ShouldFilter) - { - return parcels - .Select(x => new ParcelListV2QueryItem - { - CaPaKey = x.CaPaKey, - StatusAsString = x.StatusAsString, - VersionTimestampAsDateTimeOffset = x.VersionTimestampAsDateTimeOffset - }); - } - - if (!string.IsNullOrEmpty(filtering.Filter.AddressId)) - { - if (int.TryParse(filtering.Filter.AddressId, out var addressId)) - { - parcels = parcels.Where(x => x.Addresses.Any(parcelDetailAddress => parcelDetailAddress.AddressPersistentLocalId == addressId)); - } - else - { - return new List().AsQueryable(); - } - } - - if (!string.IsNullOrEmpty(filtering.Filter.Status)) - { - if (Enum.TryParse(typeof(PerceelStatus), filtering.Filter.Status, true, out var status)) - { - var parcelStatus = ((PerceelStatus)status).MapToParcelStatus(); - parcels = parcels.Where(m => m.StatusAsString == parcelStatus.Status); - } - else - { - return new List().AsQueryable(); - } - } - - return parcels - .Select(x => new ParcelListV2QueryItem - { - CaPaKey = x.CaPaKey, - StatusAsString = x.StatusAsString, - VersionTimestampAsDateTimeOffset = x.VersionTimestampAsDateTimeOffset - });; - } - } - - public class ParcelFilter - { - public string Status { get; set; } - public string AddressId { get; set; } - } - - public class ParcelSortingV2 : ISorting - { - public IEnumerable SortableFields { get; } = new[] - { - nameof(ParcelDetail.CaPaKey), - }; - - public SortingHeader DefaultSortingHeader { get; } = new SortingHeader(nameof(ParcelDetail.CaPaKey), SortOrder.Ascending); - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListV2QueryItem.cs b/src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListV2QueryItem.cs deleted file mode 100644 index 222d2e40..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/List/ParcelListV2QueryItem.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Parcel.List -{ - using System; - using NodaTime; - using ParcelRegistry.Parcel; - - public sealed class ParcelListV2QueryItem - { - public string CaPaKey { get; init; } - public ParcelStatus Status => ParcelStatus.Parse(StatusAsString); - - public string StatusAsString { get; init; } - - public DateTimeOffset VersionTimestampAsDateTimeOffset { get; init; } - - public Instant VersionTimestamp => Instant.FromDateTimeOffset(VersionTimestampAsDateTimeOffset); - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/ParcelController.cs b/src/ParcelRegistry.Api.Legacy/Parcel/ParcelController.cs deleted file mode 100755 index 1b689cd9..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/ParcelController.cs +++ /dev/null @@ -1,137 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Parcel -{ - using System.Net.Mime; - using System.Threading; - using System.Threading.Tasks; - using Asp.Versioning; - using Be.Vlaanderen.Basisregisters.Api; - using Be.Vlaanderen.Basisregisters.Api.ETag; - using Be.Vlaanderen.Basisregisters.Api.Exceptions; - using Be.Vlaanderen.Basisregisters.Api.Search.Filtering; - using Be.Vlaanderen.Basisregisters.Api.Search.Pagination; - using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - using Count; - using List; - using MediatR; - using Microsoft.AspNetCore.Http; - using Microsoft.AspNetCore.Mvc; - using Detail; - using Swashbuckle.AspNetCore.Filters; - using Sync; - using ProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ProblemDetails; - - [ApiVersion("1.0")] - [AdvertiseApiVersions("1.0")] - [ApiRoute("percelen")] - [ApiExplorerSettings(GroupName = "Percelen")] - public class ParcelController : ApiController - { - private readonly IMediator _mediator; - - public ParcelController(IMediator mediator) - { - _mediator = mediator; - } - - /// - /// Vraag een perceel op. - /// - /// Identificator van het perceel. - /// - /// Als het perceel gevonden is. - /// Als het perceel niet gevonden kan worden. - /// Als het perceel verwijderd is. - /// Als er een interne fout is opgetreden. - [HttpGet("{caPaKey}")] - [ProducesResponseType(typeof(ParcelDetailResponse), StatusCodes.Status200OK)] - [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] - [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status410Gone)] - [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] - [SwaggerResponseExample(StatusCodes.Status200OK, typeof(ParcelResponseExamples))] - [SwaggerResponseExample(StatusCodes.Status404NotFound, typeof(ParcelNotFoundResponseExamples))] - [SwaggerResponseExample(StatusCodes.Status410Gone, typeof(ParcelGoneResponseExamples))] - [SwaggerResponseExample(StatusCodes.Status500InternalServerError, typeof(InternalServerErrorResponseExamples))] - public async Task Get( - [FromRoute] string caPaKey, - CancellationToken cancellationToken = default) - { - var response = await _mediator.Send(new ParcelDetailRequest(caPaKey), cancellationToken); - - return string.IsNullOrWhiteSpace(response.LastEventHash) - ? Ok(response.ParcelResponse) - : new OkWithLastObservedPositionAsETagResult(response.ParcelResponse, response.LastEventHash); - } - - /// - /// Vraag een lijst met actieve percelen op. - /// - /// - /// Als de opvraging van een lijst met percelen gelukt is. - /// Als er een interne fout is opgetreden. - [HttpGet] - [ProducesResponseType(typeof(ParcelListResponse), StatusCodes.Status200OK)] - [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] - [SwaggerResponseExample(StatusCodes.Status200OK, typeof(ParcelListResponseExamples))] - [SwaggerResponseExample(StatusCodes.Status500InternalServerError, typeof(InternalServerErrorResponseExamples))] - public async Task List( - CancellationToken cancellationToken = default) - { - var filtering = Request.ExtractFilteringRequest(); - var sorting = Request.ExtractSortingRequest(); - var pagination = Request.ExtractPaginationRequest(); - - var result = await _mediator.Send(new ParcelListRequest(filtering, sorting, pagination), cancellationToken); - - Response.AddPaginationResponse(result.Pagination); - Response.AddSortingResponse(result.Sorting); - - return Ok(result); - } - - /// - /// Vraag het totaal aantal actieve percelen op. - /// - /// - /// Als de opvraging van het totaal aantal gelukt is. - /// Als er een interne fout is opgetreden. - [HttpGet("totaal-aantal")] - [ProducesResponseType(typeof(TotaalAantalResponse), StatusCodes.Status200OK)] - [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] - [SwaggerResponseExample(StatusCodes.Status200OK, typeof(TotalCountResponseExample))] - [SwaggerResponseExample(StatusCodes.Status500InternalServerError, typeof(InternalServerErrorResponseExamples))] - public async Task Count(CancellationToken cancellationToken = default) - { - var filtering = Request.ExtractFilteringRequest(); - var sorting = Request.ExtractSortingRequest(); - var pagination = new NoPaginationRequest(); - - var result = await _mediator.Send(new ParcelCountRequest(filtering, sorting, pagination), cancellationToken); - - return Ok(result); - } - - /// - /// Vraag een lijst met wijzigingen van percelen op. - /// - /// - /// - [HttpGet("sync")] - [Produces("text/xml")] - [ProducesResponseType(typeof(string), StatusCodes.Status200OK)] - [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)] - [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] - [SwaggerResponseExample(StatusCodes.Status200OK, typeof(ParcelSyndicationResponseExamples))] - [SwaggerResponseExample(StatusCodes.Status400BadRequest, typeof(BadRequestResponseExamples))] - [SwaggerResponseExample(StatusCodes.Status500InternalServerError, typeof(InternalServerErrorResponseExamples))] - public async Task Sync(CancellationToken cancellationToken = default) - { - return new ContentResult - { - Content = await _mediator.Send(new SyncRequest(Request), cancellationToken), - ContentType = MediaTypeNames.Text.Xml, - StatusCode = StatusCodes.Status200OK - }; - } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/Sync/ParcelSyndicationQuery.cs b/src/ParcelRegistry.Api.Legacy/Parcel/Sync/ParcelSyndicationQuery.cs deleted file mode 100644 index 4a9af6c1..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/Sync/ParcelSyndicationQuery.cs +++ /dev/null @@ -1,254 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Parcel.Sync -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Linq.Expressions; - using Be.Vlaanderen.Basisregisters.Api.Search; - using Be.Vlaanderen.Basisregisters.Api.Search.Filtering; - using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; - using Microsoft.EntityFrameworkCore; - using NodaTime; - using ParcelRegistry.Parcel; - using ParcelRegistry.Projections.Legacy; - using ParcelRegistry.Projections.Legacy.ParcelSyndication; - using ParcelStatus = ParcelRegistry.Legacy.ParcelStatus; - - public class ParcelSyndicationQueryResult - { - public bool ContainsEvent { get; } - public bool ContainsObject { get; } - - public Guid ParcelId { get; } - public long Position { get; } - public string CaPaKey { get; } - public string ChangeType { get; } - public Instant RecordCreatedAt { get; } - public Instant LastChangedOn { get; } - public ParcelStatus? Status { get; } - public IEnumerable AddressIds { get; } = new List(); - public byte[]? ExtendedWkbGeometry { get; } - public Organisation? Organisation { get; } - public string Reason { get; } - public string EventDataAsXml { get; } - - public ParcelSyndicationQueryResult( - Guid parcelId, - long position, - string caPaKey, - string changeType, - Instant recordCreateAt, - Instant lastChangedOn, - Organisation? organisation, - string reason) - { - ContainsObject = false; - ContainsEvent = false; - - ParcelId = parcelId; - Position = position; - CaPaKey = caPaKey; - ChangeType = changeType; - RecordCreatedAt = recordCreateAt; - LastChangedOn = lastChangedOn; - Organisation = organisation; - Reason = reason; - } - - public ParcelSyndicationQueryResult( - Guid parcelId, - long position, - string caPaKey, - string changeType, - Instant recordCreateAt, - Instant lastChangedOn, - Organisation? organisation, - string reason, - string eventDataAsXml) - : this( - parcelId, - position, - caPaKey, - changeType, - recordCreateAt, - lastChangedOn, - organisation, - reason) - { - ContainsEvent = true; - - EventDataAsXml = eventDataAsXml; - } - - public ParcelSyndicationQueryResult( - Guid parcelId, - long position, - string caPaKey, - string changeType, - Instant recordCreateAt, - Instant lastChangedOn, - ParcelStatus? status, - IEnumerable addressIds, - IEnumerable addressPersistentLocalIds, - Organisation? organisation, - byte[]? extendedWkbGeometry, - string reason) - : this( - parcelId, - position, - caPaKey, - changeType, - recordCreateAt, - lastChangedOn, - organisation, - reason) - { - ContainsObject = true; - - Status = status; - AddressIds = addressIds.Select(y => y.ToString()).Concat(addressPersistentLocalIds.Select(y => y.ToString())).ToList(); - ExtendedWkbGeometry = extendedWkbGeometry; - } - - public ParcelSyndicationQueryResult( - Guid parcelId, - long position, - string caPaKey, - string changeType, - Instant recordCreateAt, - Instant lastChangedOn, - ParcelStatus? status, - IEnumerable addressIds, - IEnumerable addressPersistentLocalIds, - Organisation? organisation, - byte[]? extendedWkbGeometry, - string reason, - string eventDataAsXml) - : this( - parcelId, - position, - caPaKey, - changeType, - recordCreateAt, - lastChangedOn, - status, - addressIds, - addressPersistentLocalIds, - organisation, - extendedWkbGeometry, - reason) - { - ContainsEvent = true; - - EventDataAsXml = eventDataAsXml; - } - } - - public class ParcelSyndicationQuery : Query - { - private readonly LegacyContext _context; - private readonly bool _embedEvent; - private readonly bool _embedObject; - - public ParcelSyndicationQuery(LegacyContext context, SyncEmbedValue embed) - { - _context = context; - _embedEvent = embed?.Event ?? false; - _embedObject = embed?.Object ?? false; - } - - protected override ISorting Sorting => new ParcelSyndicationSorting(); - - protected override Expression> Transformation - { - get - { - if (_embedObject && _embedEvent) - return x => new ParcelSyndicationQueryResult( - x.ParcelId.Value, - x.Position, - x.CaPaKey, - x.ChangeType, - x.RecordCreatedAt, - x.LastChangedOn, - x.Status, - x.AddressIds, - x.AddressPersistentLocalIds, - x.Organisation, - x.ExtendedWkbGeometry, - x.Reason, - x.EventDataAsXml); - - if (_embedEvent) - return x => new ParcelSyndicationQueryResult( - x.ParcelId.Value, - x.Position, - x.CaPaKey, - x.ChangeType, - x.RecordCreatedAt, - x.LastChangedOn, - x.Organisation, - x.Reason, - x.EventDataAsXml); - - if (_embedObject) - return x => new ParcelSyndicationQueryResult( - x.ParcelId.Value, - x.Position, - x.CaPaKey, - x.ChangeType, - x.RecordCreatedAt, - x.LastChangedOn, - x.Status, - x.AddressIds, - x.AddressPersistentLocalIds, - x.Organisation, - x.ExtendedWkbGeometry, - x.Reason); - - return x => new ParcelSyndicationQueryResult( - x.ParcelId.Value, - x.Position, - x.CaPaKey, - x.ChangeType, - x.RecordCreatedAt, - x.LastChangedOn, - x.Organisation, - x.Reason); - } - } - - protected override IQueryable Filter(FilteringHeader filtering) - { - var parcels = _context - .ParcelSyndication - .OrderBy(x => x.Position) - .AsNoTracking(); - - if (!filtering.ShouldFilter) - return parcels; - - if (filtering.Filter.Position.HasValue) - parcels = parcels.Where(m => m.Position >= filtering.Filter.Position); - - return parcels; - } - } - - public class ParcelSyndicationSorting : ISorting - { - public IEnumerable SortableFields { get; } = new[] - { - nameof(ParcelSyndicationItem.Position) - }; - - public SortingHeader DefaultSortingHeader { get; } = new SortingHeader(nameof(ParcelSyndicationItem.Position), SortOrder.Ascending); - } - - public class ParcelSyndicationFilter - { - public long? Position { get; set; } - public SyncEmbedValue Embed { get; set; } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/Sync/ParcelSyndicationResponse.cs b/src/ParcelRegistry.Api.Legacy/Parcel/Sync/ParcelSyndicationResponse.cs deleted file mode 100644 index 1991e837..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/Sync/ParcelSyndicationResponse.cs +++ /dev/null @@ -1,268 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Parcel.Sync -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Linq; - using System.Runtime.Serialization; - using System.Threading.Tasks; - using System.Xml; - using Be.Vlaanderen.Basisregisters.GrAr.Common; - using Be.Vlaanderen.Basisregisters.GrAr.Common.Syndication; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy.Perceel; - using Be.Vlaanderen.Basisregisters.GrAr.Legacy.SpatialTools; - using Be.Vlaanderen.Basisregisters.GrAr.Provenance; - using Convertors; - using Infrastructure.Options; - using Microsoft.Extensions.Options; - using Microsoft.SyndicationFeed; - using Microsoft.SyndicationFeed.Atom; - using NetTopologySuite.Geometries; - using NetTopologySuite.IO; - using Swashbuckle.AspNetCore.Filters; - using Polygon = NetTopologySuite.Geometries.Polygon; - using Provenance = Be.Vlaanderen.Basisregisters.GrAr.Provenance.Syndication.Provenance; - - public static class ParcelSyndicationResponse - { - private static readonly WKBReader WkbReader = WKBReaderFactory.Create(); - - public static async Task WriteParcel( - this ISyndicationFeedWriter writer, - IOptions responseOptions, - AtomFormatter formatter, - string category, - ParcelSyndicationQueryResult parcel) - { - var item = new SyndicationItem - { - Id = parcel.Position.ToString(CultureInfo.InvariantCulture), - Title = $"{parcel.ChangeType}-{parcel.Position}", - Published = parcel.RecordCreatedAt.ToBelgianDateTimeOffset(), - LastUpdated = parcel.LastChangedOn.ToBelgianDateTimeOffset(), - Description = BuildDescription(parcel, responseOptions.Value.Naamruimte) - }; - - item.AddLink( - new SyndicationLink( - new Uri($"{responseOptions.Value.Naamruimte}/{parcel.CaPaKey}"), - AtomLinkTypes.Related)); - - //item.AddLink( - // new SyndicationLink( - // new Uri(string.Format(responseOptions.Value.DetailUrl, parcel.CaPaKey)), - // AtomLinkTypes.Self)); - - //item.AddLink( - // new SyndicationLink( - // new Uri(string.Format($"{responseOptions.Value.DetailUrl}.xml", parcel.CaPaKey)), - // AtomLinkTypes.Alternate) - // { MediaType = MediaTypeNames.Application.Xml }); - - //item.AddLink( - // new SyndicationLink( - // new Uri(string.Format($"{responseOptions.Value.DetailUrl}.json", parcel.CaPaKey)), - // AtomLinkTypes.Alternate) - // { MediaType = MediaTypeNames.Application.Json }); - - item.AddCategory( - new SyndicationCategory(category)); - - item.AddContributor( - new SyndicationPerson( - parcel.Organisation == null ? Organisation.Unknown.ToName() : parcel.Organisation.Value.ToName(), - string.Empty, - AtomContributorTypes.Author)); - - await writer.Write(item); - } - - private static string BuildDescription(ParcelSyndicationQueryResult parcel, string naamruimte) - { - if (!parcel.ContainsEvent && !parcel.ContainsObject) - return "No data embedded"; - - var content = new SyndicationContent(); - if(parcel.ContainsObject) - { - var geometry = parcel.ExtendedWkbGeometry is null - ? null - : WkbReader.Read(parcel.ExtendedWkbGeometry); - - content.Object = new ParcelSyndicationContent( - parcel.ParcelId, - naamruimte, - parcel.CaPaKey, - parcel.LastChangedOn.ToBelgianDateTimeOffset(), - parcel.Status.MapToPerceelStatusSyndication(), - parcel.AddressIds, - geometry is MultiPolygon - ? GmlMultiSurfaceBuilder.Build(parcel.ExtendedWkbGeometry!, WkbReader) - : null, - geometry is Polygon - ? PolygonBuilder.Build(parcel.ExtendedWkbGeometry!, WkbReader)?.XmlPolygon - : null, - parcel.Organisation, - parcel.Reason); - } - - if (parcel.ContainsEvent) - { - var doc = new XmlDocument(); - doc.LoadXml(parcel.EventDataAsXml); - content.Event = doc.DocumentElement; - } - - return content.ToXml(); - } - } - - [DataContract(Name = "Content", Namespace = "")] - public class SyndicationContent : SyndicationContentBase - { - [DataMember(Name = "Event")] - public XmlElement Event { get; set; } - - [DataMember(Name = "Object")] - public ParcelSyndicationContent Object { get; set; } - } - - [DataContract(Name = "Perceel", Namespace = "")] - public class ParcelSyndicationContent - { - /// - /// De technische id van het perceel. - /// - [DataMember(Name = "Id", Order = 1)] - public Guid ParcelId { get; set; } - - /// - /// De identificator van het perceel. - /// - [DataMember(Name = "Identificator", Order = 2)] - public PerceelIdentificator Identificator { get; set; } - - /// - /// De status van het perceel. - /// - [DataMember(Name = "PerceelStatus", Order = 3)] - public PerceelStatus? Status { get; set; } - - /// - /// De aan het perceel gelinkte adressen - /// - [DataMember(Name = "AdressenIds", Order = 4)] - public List AddressIds { get; set; } - - /// - /// De geometrie multi-polygoon van het perceel. - /// - [DataMember(Name = "GeometrieMultiPolygoon", Order = 5)] - public SyndicationMultiSurface MultiSurfacePolygon { get; set; } - - /// - /// De geometrie polygoon van het perceel. - /// - [DataMember(Name = "GeometriePolygoon", Order = 6)] - public SyndicationPolygon Polygon { get; set; } - - /// - /// Creatie data ivm het item. - /// - [DataMember(Name = "Creatie", Order = 7)] - public Provenance Provenance { get; set; } - - public ParcelSyndicationContent( - Guid parcelId, - string naamruimte, - string caPaKey, - DateTimeOffset version, - PerceelStatus? status, - IEnumerable addressIds, - GmlMultiSurface? gmlMultiSurface, - GmlPolygon? gmlPolygon, - Organisation? organisation, - string reason) - { - ParcelId = parcelId; - Identificator = new PerceelIdentificator(naamruimte, string.IsNullOrEmpty(caPaKey) ? string.Empty : caPaKey, version); - Status = status; - AddressIds = addressIds.ToList(); - if (gmlMultiSurface != null) - { - MultiSurfacePolygon = new SyndicationMultiSurface { XmlMultiSurface = gmlMultiSurface }; - } - - if (gmlPolygon != null) - { - Polygon = new SyndicationPolygon { XmlPolygon = gmlPolygon }; - } - - Provenance = new Provenance(version, organisation, new Reason(reason)); - } - } - - public class ParcelSyndicationResponseExamples : IExamplesProvider - { - private const string RawXml = @" - - https://api.basisregisters.vlaanderen.be/v1/feeds/percelen.atom - Basisregisters Vlaanderen - feed 'percelen' - Deze Atom feed geeft leestoegang tot events op de resource 'percelen'. - Basisregisters Vlaanderen - Gratis hergebruik volgens https://overheid.vlaanderen.be/sites/default/files/documenten/ict-egov/licenties/hergebruik/modellicentie_gratis_hergebruik_v1_0.html - 2020-11-06T19:36:06Z - - Digitaal Vlaanderen - digitaal.vlaanderen@vlaanderen.be - - - - - - - - 0 - ParcelWasRegistered-0 - 2012-09-23T23:13:50+02:00 - 2012-09-23T23:13:50+02:00 - - - Gemeente - - - - 10ad670a-ab6e-5fda-9a8a-733e11f5990202012-09-23T21:13:50ZMunicipalityDecentrale bijhouding CRAB - - 10ad670a-ab6e-5fda-9a8a-733e11f59902https://data.vlaanderen.be/id/perceel/0https://data.vlaanderen.be/id/perceel02012-09-23T23:13:50+02:00Gerealiseerd2012-09-23T23:13:50+02:00GemeenteDecentrale bijhouding CRAB - ]]> - - - - 1 - ParcelWasRealized-1 - 2012-09-23T23:13:50+02:00 - 2012-09-23T23:13:50+02:00 - - - Gemeente - - - - 10ad670a-ab6e-5fda-9a8a-733e11f599022012-09-23T21:13:50ZMunicipalityDecentrale bijhouding CRAB - - 10ad670a-ab6e-5fda-9a8a-733e11f59902https://data.vlaanderen.be/id/perceel/0https://data.vlaanderen.be/id/perceel02012-09-23T23:13:50+02:00Gerealiseerd2012-09-23T23:13:50+02:00GemeenteDecentrale bijhouding CRAB - ]]> - - -"; - - public XmlElement GetExamples() - { - var example = new XmlDocument(); - example.LoadXml(RawXml); - return example.DocumentElement; - } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/Sync/SyncHandler.cs b/src/ParcelRegistry.Api.Legacy/Parcel/Sync/SyncHandler.cs deleted file mode 100644 index 38544dd5..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/Sync/SyncHandler.cs +++ /dev/null @@ -1,105 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Parcel.Sync -{ - using System; - using System.Linq; - using System.Text; - using System.Threading; - using System.Threading.Tasks; - using System.Xml; - using Be.Vlaanderen.Basisregisters.Api.Search.Filtering; - using Be.Vlaanderen.Basisregisters.Api.Search.Pagination; - using Be.Vlaanderen.Basisregisters.Api.Search.Sorting; - using Be.Vlaanderen.Basisregisters.Api.Syndication; - using Be.Vlaanderen.Basisregisters.GrAr.Common; - using MediatR; - using Microsoft.EntityFrameworkCore; - using Microsoft.Extensions.Configuration; - using Microsoft.Extensions.Options; - using Microsoft.SyndicationFeed; - using Microsoft.SyndicationFeed.Atom; - using ParcelRegistry.Api.Legacy.Infrastructure; - using ParcelRegistry.Api.Legacy.Infrastructure.Options; - using ParcelRegistry.Projections.Legacy; - - public class SyncHandler : IRequestHandler - { - private readonly IConfiguration _configuration; - private readonly LegacyContext _context; - private readonly IOptions _responseOptions; - - public SyncHandler( - IConfiguration configuration, - LegacyContext context, - IOptions responseOptions) - { - _configuration = configuration; - _context = context; - _responseOptions = responseOptions; - } - public async Task Handle(SyncRequest request, CancellationToken cancellationToken) - { - var filtering = request.HttpRequest.ExtractFilteringRequest(); - var sorting = request.HttpRequest.ExtractSortingRequest(); - var pagination = request.HttpRequest.ExtractPaginationRequest(); - - var lastFeedUpdate = await _context - .ParcelSyndication - .AsNoTracking() - .OrderByDescending(item => item.Position) - .Select(item => item.SyndicationItemCreatedAt) - .FirstOrDefaultAsync(cancellationToken); - - if (lastFeedUpdate == default) - lastFeedUpdate = new DateTimeOffset(2020, 1, 1, 0, 0, 0, TimeSpan.Zero); - - var pagedParcels = new ParcelSyndicationQuery( - _context, - filtering.Filter?.Embed) - .Fetch(filtering, sorting, pagination); - - return await BuildAtomFeed(lastFeedUpdate, pagedParcels, _responseOptions, _configuration); - } - - private static async Task BuildAtomFeed( - DateTimeOffset lastUpdate, - PagedQueryable pagedParcels, - IOptions responseOptions, - IConfiguration configuration) - { - var sw = new StringWriterWithEncoding(Encoding.UTF8); - - using (var xmlWriter = XmlWriter.Create(sw, new XmlWriterSettings { Async = true, Indent = true, Encoding = sw.Encoding })) - { - var formatter = new AtomFormatter(null, xmlWriter.Settings) { UseCDATA = true }; - var writer = new AtomFeedWriter(xmlWriter, null, formatter); - var syndicationConfiguration = configuration.GetSection("Syndication"); - var atomConfiguration = AtomFeedConfigurationBuilder.CreateFrom(syndicationConfiguration, lastUpdate); - - await writer.WriteDefaultMetadata(atomConfiguration); - - var parcels = pagedParcels.Items.ToList(); - var nextFrom = parcels.Any() - ? parcels.Max(x => x.Position) + 1 - : (long?)null; - - var nextUri = BuildNextSyncUri(pagedParcels.PaginationInfo.Limit, nextFrom, syndicationConfiguration["NextUri"]); - if (nextUri != null) - await writer.Write(new SyndicationLink(nextUri, "next")); - - foreach (var parcel in pagedParcels.Items) - await writer.WriteParcel(responseOptions, formatter, syndicationConfiguration["Category"], parcel); - - xmlWriter.Flush(); - } - - return sw.ToString(); - } - - private static Uri BuildNextSyncUri(int limit, long? from, string nextUrlBase) - { - return from.HasValue - ? new Uri(string.Format(nextUrlBase, from, limit)) - : null; - } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/Parcel/Sync/SyncRequest.cs b/src/ParcelRegistry.Api.Legacy/Parcel/Sync/SyncRequest.cs deleted file mode 100644 index 73d58c20..00000000 --- a/src/ParcelRegistry.Api.Legacy/Parcel/Sync/SyncRequest.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace ParcelRegistry.Api.Legacy.Parcel.Sync -{ - using MediatR; - using Microsoft.AspNetCore.Http; - - public record SyncRequest(HttpRequest HttpRequest) : IRequest; -} diff --git a/src/ParcelRegistry.Api.Legacy/ParcelRegistry.Api.Legacy.csproj b/src/ParcelRegistry.Api.Legacy/ParcelRegistry.Api.Legacy.csproj deleted file mode 100644 index 15adf512..00000000 --- a/src/ParcelRegistry.Api.Legacy/ParcelRegistry.Api.Legacy.csproj +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - false - true - false - - - - bin\Debug\net8.0\ParcelRegistry.Api.Legacy.xml - 1701;1702;1705;1591 - TRACE;DEBUG;NETCOREAPP;NET8_0 - - - bin\Release\net8.0\ParcelRegistry.Api.Legacy.xml - 1701;1702;1705;1591 - - - false - - - - - - - - - - - - - - - - - - diff --git a/src/ParcelRegistry.Api.Legacy/Properties/AssemblyInfo.cs b/src/ParcelRegistry.Api.Legacy/Properties/AssemblyInfo.cs deleted file mode 100644 index 4e300892..00000000 --- a/src/ParcelRegistry.Api.Legacy/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -[assembly: AssemblyDescription("Perceelregister Legacy API")] - -[assembly: AssemblyProduct("Basisregisters Vlaanderen")] -[assembly: AssemblyCopyright("Copyright (c) Vlaamse overheid")] -[assembly: AssemblyCompany("Vlaamse overheid")] -[assembly: ComVisible(false)] -[assembly: Guid("63c9c5f5-ef8d-41c3-9261-25659bf67ee2")] diff --git a/src/ParcelRegistry.Api.Legacy/Properties/launchSettings.json b/src/ParcelRegistry.Api.Legacy/Properties/launchSettings.json deleted file mode 100644 index b2a2d4ac..00000000 --- a/src/ParcelRegistry.Api.Legacy/Properties/launchSettings.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:13215/", - "sslPort": 0 - } - }, - "profiles": { - "IIS Express": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "ParcelRegistry.Api": { - "commandName": "Project", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:5000/" - } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/appsettings.json b/src/ParcelRegistry.Api.Legacy/appsettings.json deleted file mode 100755 index d29dfb5e..00000000 --- a/src/ParcelRegistry.Api.Legacy/appsettings.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "ConnectionStrings": { - "Events": "Server=(localdb)\\mssqllocaldb;Database=EFProviders.InMemory.ParcelRegistry;Trusted_Connection=True;TrustServerCertificate=True;", - "LegacyProjections": "Server=(localdb)\\mssqllocaldb;Database=EFProviders.InMemory.ParcelRegistry;Trusted_Connection=True;TrustServerCertificate=True;" - }, - - "Cors": [ - "http://localhost:3000", - "http://localhost:5000" - ], - - "BaseUrl": "https://api.staging-basisregisters.vlaanderen/", - - "Syndication": { - "Category": "percelen", - "Id": "https://legacy.staging-basisregisters.vlaanderen/v1/feeds/percelen.atom", - "Title": "Basisregisters Vlaanderen - Percelenregister", - "Subtitle": "Deze Atom feed geeft leestoegang tot events op de resource 'percelen'.", - "GeneratorTitle": "Basisregisters Vlaanderen", - "GeneratorUri": "", - "Rights": "Gratis hergebruik volgens https://overheid.vlaanderen.be/sites/default/files/documenten/ict-egov/licenties/hergebruik/modellicentie_gratis_hergebruik_v1_0.html", - "AuthorName": "Digitaal Vlaanderen", - "AuthorEmail": "digitaal.vlaanderen@vlaanderen.be", - "Self": "https://legacy.staging-basisregisters.vlaanderen/syndication/feed/parcel", - "NextUri": "https://legacy.staging-basisregisters.vlaanderen/v1/feeds/parcel.atom?from={0}&limit={1}", - "Related": [ - "https://legacy.staging-basisregisters.vlaanderen" - ] - }, - - "Naamruimte": "https://data.vlaanderen.be/id/perceel", - "DetailUrl": "https://basisregisters.vlaanderen.be/api/v1/percelen/{0}", - "VolgendeUrl": "https://basisregisters.vlaanderen.be/api/v1/percelen?offset={0}&limit={1}", - "AdresDetailUrl": "https://basisregisters.vlaanderen.be/api/v1/adressen/{0}", - - "Serilog": { - "MinimumLevel": { - "Default": "Information" - }, - "WriteTo": [ - { - "Name": "Console", - "Args": { - "formatter": "Serilog.Formatting.Compact.RenderedCompactJsonFormatter, Serilog.Formatting.Compact" - } - } - ], - "Properties": { - "Application": "ParcelRegistry - Legacy API", - "ContainerId": "REPLACE_CONTAINERID" - } - } -} diff --git a/src/ParcelRegistry.Api.Legacy/init.sh b/src/ParcelRegistry.Api.Legacy/init.sh deleted file mode 100755 index f7859d9f..00000000 --- a/src/ParcelRegistry.Api.Legacy/init.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -CONTAINERID=$(curl -s http://169.254.170.2/v2/metadata | jq -r ".Containers[] | select(.Labels[\"com.amazonaws.ecs.container-name\"] | startswith(\"basisregisters-\") and endswith(\"-legacy\")) | .DockerId") - -sed -i "s/REPLACE_CONTAINERID/$CONTAINERID/g" appsettings.json - -./ParcelRegistry.Api.Legacy diff --git a/src/ParcelRegistry.Api.Legacy/paket.references b/src/ParcelRegistry.Api.Legacy/paket.references deleted file mode 100644 index 1a80221c..00000000 --- a/src/ParcelRegistry.Api.Legacy/paket.references +++ /dev/null @@ -1,12 +0,0 @@ -AspNetCore.HealthChecks.SqlServer - -Be.Vlaanderen.Basisregisters.Api - -Datadog.Trace.Bundle - -Microsoft.SyndicationFeed.ReaderWriter - -SourceLink.Embed.AllSourceFiles -SourceLink.Copy.PdbFiles - -MediatR diff --git a/src/ParcelRegistry.Api.Legacy/paket.template b/src/ParcelRegistry.Api.Legacy/paket.template deleted file mode 100644 index 841a4d29..00000000 --- a/src/ParcelRegistry.Api.Legacy/paket.template +++ /dev/null @@ -1,31 +0,0 @@ -type file -version 1.0.0 - -id Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.Legacy -title Be.Vlaanderen.Basisregisters.ParcelRegistry.Api.Legacy - -authors Basisregisters Vlaanderen -owners Digitaal Vlaanderen -copyright Copyright (c) Digitaal Vlaanderen -requireLicenseAcceptance false -projectUrl https://github.com/Informatievlaanderen/parcel-registry -iconUrl https://raw.githubusercontent.com/Informatievlaanderen/build-pipeline/master/logo.png -licenseUrl https://opensource.org/licenses/EUPL-1.2 - -description Parcel Registry. - -dependencies - framework: net8.0 - Be.Vlaanderen.Basisregisters.GrAr.Legacy >= LOCKEDVERSION - -files - ParcelRegistry.Api.Legacy.dll => lib\net8.0 - ParcelRegistry.Api.Legacy.pdb => lib\net8.0 - ParcelRegistry.Api.Legacy.xml => lib\net8.0 - ParcelRegistry.Api.Legacy.xml => content - - ParcelRegistry.Projections.Legacy.dll => lib\net8.0 - ParcelRegistry.Projections.Legacy.pdb => lib\net8.0 - - ParcelRegistry.dll => lib\net8.0 - ParcelRegistry.pdb => lib\net8.0 diff --git a/test/ParcelRegistry.Tests/ParcelRegistry.Tests.csproj b/test/ParcelRegistry.Tests/ParcelRegistry.Tests.csproj index 9f6fc1a0..40557c97 100644 --- a/test/ParcelRegistry.Tests/ParcelRegistry.Tests.csproj +++ b/test/ParcelRegistry.Tests/ParcelRegistry.Tests.csproj @@ -4,11 +4,11 @@ - +