namespace Acl.Application; /// The ACL's single operation: open a zaak from a domain payload, /// default-filling the ZGW-mandatory fields (ADR-0003). public sealed class AclService(IZaakGateway gateway, AclDefaults defaults, IZaaktypeCatalog catalog, IClock clock) { public async Task OpenZaakAsync(DomainRegistration registration, CancellationToken ct = default) { ArgumentNullException.ThrowIfNull(registration); var request = new ZaakRequest( defaults.Bronorganisatie, defaults.VerantwoordelijkeOrganisatie, defaults.Vertrouwelijkheidaanduiding, await catalog.GetZaaktypeUrlAsync(ct), clock.Today, registration.Reference); return await gateway.OpenZaakAsync(request, ct); } /// /// Approve a zaak: set it to the eindstatus of the BIG zaaktype (resolved by identificatie, S-27). /// The domain hands over only the zaak URL; the ACL owns which statustype means "approved" (§8.1). /// public async Task ApproveZaakAsync(Uri zaakUrl, CancellationToken ct = default) { ArgumentNullException.ThrowIfNull(zaakUrl); await gateway.SetZaakToEindstatusAsync(zaakUrl, await catalog.GetZaaktypeUrlAsync(ct), clock.Today, ct); } /// /// Cancel a zaak on document-timeout expiry (S-10c): set it to the BIG zaaktype's cancellation /// statustype + resultaat. The domain hands over only the zaak URL; the ACL owns which /// statustype/resultaat means "cancelled" (§8.1). /// public async Task CancelZaakAsync(Uri zaakUrl, CancellationToken ct = default) { ArgumentNullException.ThrowIfNull(zaakUrl); await gateway.SetZaakToCancellationStatusAsync(zaakUrl, await catalog.GetZaaktypeUrlAsync(ct), clock.Today, ct); } /// The published zaaktypen, for the beheer catalogus viewer (S-15a). Read-only passthrough: /// no default-fill, the ACL is simply the only code allowed to read ZGW (§8.1). public Task> ListZaaktypenAsync(CancellationToken ct = default) => // ponytail: stub for the red test; real passthrough lands in the green commit. Task.FromResult>([]); /// The zaak's reference (its ZGW identificatie), for the read projection (#78). public Task GetZaakReferenceAsync(Uri zaakUrl, CancellationToken ct = default) { ArgumentNullException.ThrowIfNull(zaakUrl); return gateway.GetZaakIdentificatieAsync(zaakUrl, ct); } /// /// Store an uploaded diploma against the zaak (S-10b): default-fill the ZGW-mandatory document /// fields (informatieobjecttype, bronorganisatie, vertrouwelijkheidaanduiding, taal, creatiedatum) /// and hand the file to the gateway, which creates the informatieobject and relates it to the zaak. /// The domain supplies only the zaak, the bytes, and the file's name/type (§8.1). /// public async Task StoreDiplomaAsync(Uri zaakUrl, byte[] content, string fileName, string contentType, CancellationToken ct = default) { ArgumentNullException.ThrowIfNull(zaakUrl); ArgumentNullException.ThrowIfNull(content); ArgumentException.ThrowIfNullOrWhiteSpace(fileName); ArgumentException.ThrowIfNullOrWhiteSpace(contentType); var request = new DocumentRequest( defaults.Bronorganisatie, await catalog.GetInformatieobjecttypeUrlAsync(ct), defaults.Vertrouwelijkheidaanduiding, zaakUrl, clock.Today, Titel: "Diploma", Auteur: "zorgprofessional", Taal: "nld", Bestandsnaam: fileName, Formaat: contentType, Inhoud: content); return await gateway.StoreDocumentAsync(request, ct); } }