## What & why S-10b: the self-service **diploma upload** is now real. After submitting, the citizen picks a PDF and uploads it; the portal base64-encodes it client-side → BFF → domain → **ACL**, which stores it in the ZGW **Documenten (DRC) API** as an `enkelvoudiginformatieobject` and relates it to the zaak, then the `WachtOpDocumenten` wait completes and the case advances to beoordeling. Per §8.1 only the ACL talks to ZGW. Closes #103 Mechanism in **ADR-0018** (proposal #107). Builds on S-10a (#102). The zaak-close-on-expiry item is carved to **#106 (S-10c)**. ## Definition of Done - [x] Linked Gitea issue (above). - [x] Failing test committed before the implementation (red→green per layer). - [x] Conventional Commits referencing the issue (`refs #103`). - [ ] CI green — all Gitea Actions jobs (pending on this PR). - [x] `docker compose up` health unaffected (ACL boots on a placeholder informatieobjecttype URL; the real one is injected by verify-domain). - [x] Docs updated (ADR-0018, demo-script, BACKLOG + S-10c). - [x] ADR added (`docs/architecture/adr-0018-diploma-upload-via-acl-documenten.md`). - [x] Demo note in `docs/demo-script.md`. ## Notes for reviewers - **ACL** (`OpenZaakGateway.StoreDocumentAsync` + `AclService.StoreDiplomaAsync` + `POST /documenten`) reuses the existing gateway patterns (ZGW Bearer, buffered non-chunked body, **no CRS** — Documenten isn't geo). Unit-tested via the stub handler; an **integration test** stores a real document against live OpenZaak (verify-acl). - **Transport:** base64 JSON on every hop (portal encodes client-side) — I deviated from proposal #107's multipart to keep one contract shape and avoid `IFormFile`/antiforgery/multipart-client plumbing; fine at diploma size (ADR-0018 §Alternatives). - **Infra:** `seed_catalogus.py` seeds + publishes a "Diploma" `informatieobjecttype` and relates it to the zaaktype (while both concept); `verify-domain` injects its URL into the ACL. No new ZGW scopes (seed applicatie has `heeft_alle_autorisaties`). - **e2e:** uploads a real PDF (`setInputFiles`) after the openbaar INGEDIEND row confirms the zaak is open (so storage doesn't race the OpenZaak worker). - **Scope boundary:** the ZGW zaak is not set to a cancellation status on 30-day expiry — that's #106 (S-10c). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Reviewed-on: #108
68 lines
3.1 KiB
C#
68 lines
3.1 KiB
C#
using System.Net.Http.Json;
|
|
using System.Text.Json.Serialization;
|
|
using Big.Application;
|
|
|
|
namespace Big.Infrastructure;
|
|
|
|
/// <summary>
|
|
/// HTTP client to the ACL service — the boundary the domain crosses to open a zaak (§8.1). It POSTs
|
|
/// the bsn to the ACL's <c>/zaken</c> endpoint and returns the created zaak URL; it never constructs
|
|
/// ZGW URLs or talks to OpenZaak itself.
|
|
/// </summary>
|
|
public sealed class AclHttpClient(HttpClient http, AclOptions options) : IAclClient
|
|
{
|
|
public async Task<Uri> OpenZaakAsync(string bsn, string reference, CancellationToken ct = default)
|
|
{
|
|
using var response = await http.PostAsJsonAsync(
|
|
new Uri(options.BaseUrl, "zaken"), new OpenZaakRequest(bsn, reference), ct);
|
|
response.EnsureSuccessStatusCode();
|
|
|
|
var opened = await response.Content.ReadFromJsonAsync<OpenZaakResponse>(ct)
|
|
?? throw new InvalidOperationException("The ACL returned an empty zaak response.");
|
|
return new Uri(opened.ZaakUrl);
|
|
}
|
|
|
|
public async Task ApproveZaakAsync(Uri zaakUrl, CancellationToken ct = default)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(zaakUrl);
|
|
|
|
using var response = await http.PostAsJsonAsync(
|
|
new Uri(options.BaseUrl, "statussen"), new SetStatusRequest(zaakUrl.ToString()), ct);
|
|
response.EnsureSuccessStatusCode();
|
|
}
|
|
|
|
public async Task<Uri> StoreDiplomaAsync(Uri zaakUrl, byte[] content, string fileName, string contentType, CancellationToken ct = default)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(zaakUrl);
|
|
ArgumentNullException.ThrowIfNull(content);
|
|
|
|
// The file crosses this boundary base64-encoded in JSON — the domain and ACL contracts are
|
|
// JSON, and a diploma is small (S-10b, ADR). The ACL turns it into a ZGW informatieobject.
|
|
using var response = await http.PostAsJsonAsync(
|
|
new Uri(options.BaseUrl, "documenten"),
|
|
new StoreDocumentRequest(zaakUrl.ToString(), Convert.ToBase64String(content), fileName, contentType), ct);
|
|
response.EnsureSuccessStatusCode();
|
|
|
|
var stored = await response.Content.ReadFromJsonAsync<StoreDocumentResponse>(ct)
|
|
?? throw new InvalidOperationException("The ACL returned an empty document response.");
|
|
return new Uri(stored.InformatieobjectUrl);
|
|
}
|
|
|
|
private sealed record OpenZaakRequest(
|
|
[property: JsonPropertyName("bsn")] string Bsn,
|
|
[property: JsonPropertyName("reference")] string Reference);
|
|
|
|
private sealed record OpenZaakResponse([property: JsonPropertyName("zaakUrl")] string ZaakUrl);
|
|
|
|
private sealed record SetStatusRequest([property: JsonPropertyName("zaakUrl")] string ZaakUrl);
|
|
|
|
private sealed record StoreDocumentRequest(
|
|
[property: JsonPropertyName("zaakUrl")] string ZaakUrl,
|
|
[property: JsonPropertyName("contentBase64")] string ContentBase64,
|
|
[property: JsonPropertyName("fileName")] string FileName,
|
|
[property: JsonPropertyName("contentType")] string ContentType);
|
|
|
|
private sealed record StoreDocumentResponse(
|
|
[property: JsonPropertyName("informatieobjectUrl")] string InformatieobjectUrl);
|
|
}
|