The ACL now discovers its BIG zaaktype (by identificatie) and diploma informatieobjecttype (by omschrijving) from OpenZaak's Catalogi API, instead of being handed server-assigned URLs in config. A CachedZaaktypeCatalog resolves lazily on first use and caches (success only, so a pre-publish miss is retried); AclDefaults now carries ZaaktypeIdentificatie/InformatieobjecttypeOmschrijving. Clear errors replace the opaque placeholder-URL 400. Unit tests cover the resolver (resolve/cache/retry-on-failure) and the gateway lookups (match/miss). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
75 lines
3.3 KiB
C#
75 lines
3.3 KiB
C#
using Acl.Application;
|
|
using Acl.Infrastructure;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services.AddSingleton<IClock, SystemClock>();
|
|
builder.Services.AddSingleton(sp => sp.GetRequiredService<IConfiguration>()
|
|
.GetSection("Acl:Defaults").Get<AclDefaults>()
|
|
?? throw new InvalidOperationException("Missing configuration section 'Acl:Defaults'"));
|
|
builder.Services.AddSingleton(sp => sp.GetRequiredService<IConfiguration>()
|
|
.GetSection("Acl:OpenZaak").Get<OpenZaakOptions>()
|
|
?? throw new InvalidOperationException("Missing configuration section 'Acl:OpenZaak'"));
|
|
builder.Services.AddHttpClient<IZaakGateway, OpenZaakGateway>();
|
|
// Singleton so the resolved zaaktype/informatieobjecttype URLs are cached across requests (S-27).
|
|
builder.Services.AddSingleton<IZaaktypeCatalog, CachedZaaktypeCatalog>();
|
|
builder.Services.AddScoped<AclService>();
|
|
|
|
var app = builder.Build();
|
|
|
|
app.MapGet("/health", () => "Healthy");
|
|
|
|
// The ACL's single operation, exposed as a service endpoint.
|
|
app.MapPost("/zaken", async (OpenZaakRequest body, AclService acl, CancellationToken ct) =>
|
|
{
|
|
var zaakUrl = await acl.OpenZaakAsync(new DomainRegistration(body.Bsn, body.Reference), ct);
|
|
return Results.Ok(new { zaakUrl = zaakUrl.ToString() });
|
|
});
|
|
|
|
// Approve a zaak: set it to its zaaktype's eindstatus (S-09b). The domain hands over only the zaak
|
|
// URL; the ACL owns the ZGW statustype resolution (§8.1).
|
|
app.MapPost("/statussen", async (SetStatusRequest body, AclService acl, CancellationToken ct) =>
|
|
{
|
|
await acl.ApproveZaakAsync(new Uri(body.ZaakUrl), ct);
|
|
return Results.NoContent();
|
|
});
|
|
|
|
// Cancel a zaak on document-timeout expiry (S-10c): set it to its zaaktype's cancellation statustype
|
|
// + resultaat. The domain hands over only the zaak URL; the ACL owns the ZGW resolution (§8.1).
|
|
app.MapPost("/annuleringen", async (CancelZaakRequest body, AclService acl, CancellationToken ct) =>
|
|
{
|
|
await acl.CancelZaakAsync(new Uri(body.ZaakUrl), ct);
|
|
return Results.NoContent();
|
|
});
|
|
|
|
// Read a zaak's public-safe reference (its identificatie). The Event Subscriber calls this to enrich
|
|
// the read projection without reading ZGW itself (§8.1, #78).
|
|
app.MapPost("/zaken/reference", async (ZaakReferenceRequest body, AclService acl, CancellationToken ct) =>
|
|
{
|
|
var reference = await acl.GetZaakReferenceAsync(new Uri(body.ZaakUrl), ct);
|
|
return Results.Ok(new { reference });
|
|
});
|
|
|
|
// Store an uploaded diploma against a zaak (S-10b): the domain sends the file as base64; the ACL
|
|
// creates the ZGW enkelvoudiginformatieobject and relates it to the zaak (§8.1). Returns its URL.
|
|
app.MapPost("/documenten", async (StoreDocumentRequest body, AclService acl, CancellationToken ct) =>
|
|
{
|
|
var url = await acl.StoreDiplomaAsync(
|
|
new Uri(body.ZaakUrl), Convert.FromBase64String(body.ContentBase64), body.FileName, body.ContentType, ct);
|
|
return Results.Ok(new { informatieobjectUrl = url.ToString() });
|
|
});
|
|
|
|
app.Run();
|
|
|
|
public sealed record OpenZaakRequest(string Bsn, string Reference);
|
|
|
|
public sealed record SetStatusRequest(string ZaakUrl);
|
|
|
|
public sealed record CancelZaakRequest(string ZaakUrl);
|
|
|
|
public sealed record ZaakReferenceRequest(string ZaakUrl);
|
|
|
|
public sealed record StoreDocumentRequest(string ZaakUrl, string ContentBase64, string FileName, string ContentType);
|
|
|
|
public partial class Program;
|