## 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
This commit was merged in pull request #108.
This commit is contained in:
@@ -80,6 +80,39 @@ public sealed class OpenZaakGateway(HttpClient http, OpenZaakOptions options) :
|
||||
return zaak.Identificatie;
|
||||
}
|
||||
|
||||
public async Task<Uri> StoreDocumentAsync(DocumentRequest request, CancellationToken ct = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(request);
|
||||
|
||||
// 1. Create the enkelvoudiginformatieobject in the Documenten API (not a geo API — no CRS).
|
||||
var created = await PostForUrlAsync(
|
||||
"/documenten/api/v1/enkelvoudiginformatieobjecten",
|
||||
new EnkelvoudigInformatieobjectDto(
|
||||
request.Bronorganisatie,
|
||||
request.Creatiedatum.ToString("yyyy-MM-dd"),
|
||||
request.Titel,
|
||||
request.Auteur,
|
||||
request.Taal,
|
||||
request.Informatieobjecttype.ToString(),
|
||||
Convert.ToBase64String(request.Inhoud),
|
||||
request.Bestandsnaam,
|
||||
request.Inhoud.Length,
|
||||
request.Vertrouwelijkheidaanduiding,
|
||||
request.Formaat,
|
||||
"definitief",
|
||||
// No usage-rights restrictions apply. Left null, OpenZaak rejects closing the related
|
||||
// zaak with "indicatiegebruiksrecht-unset"; false records the deliberate "none" answer.
|
||||
false),
|
||||
"Creating the informatieobject", ct);
|
||||
|
||||
// 2. Relate it to the zaak (Zaken API — no CRS).
|
||||
await PostAsync("/zaken/api/v1/zaakinformatieobjecten",
|
||||
new ZaakInformatieobjectDto(request.Zaak.ToString(), created.ToString()),
|
||||
"Relating the informatieobject to the zaak", ct);
|
||||
|
||||
return created;
|
||||
}
|
||||
|
||||
// POSTs a non-geo ZGW resource (resultaat/status — no CRS headers). Buffers the body so uwsgi gets
|
||||
// a Content-Length instead of a chunked body (as with zaak-create).
|
||||
private async Task PostAsync(string path, object dto, string action, CancellationToken ct)
|
||||
@@ -96,6 +129,26 @@ public sealed class OpenZaakGateway(HttpClient http, OpenZaakOptions options) :
|
||||
await EnsureSuccessAsync(response, action, ct);
|
||||
}
|
||||
|
||||
// POSTs a non-geo ZGW resource and returns the created resource's URL (as PostAsync, but reads back
|
||||
// the `url` of the created object). Buffers the body so uwsgi gets a Content-Length.
|
||||
private async Task<Uri> PostForUrlAsync(string path, object dto, string action, CancellationToken ct)
|
||||
{
|
||||
using var message = new HttpRequestMessage(HttpMethod.Post, new Uri(options.BaseUrl, path))
|
||||
{
|
||||
Content = JsonContent.Create(dto),
|
||||
};
|
||||
message.Headers.Authorization =
|
||||
new AuthenticationHeaderValue("Bearer", ZgwToken.Mint(options.ClientId, options.Secret));
|
||||
await message.Content.LoadIntoBufferAsync(ct);
|
||||
|
||||
using var response = await http.SendAsync(message, ct);
|
||||
await EnsureSuccessAsync(response, action, ct);
|
||||
|
||||
var created = await response.Content.ReadFromJsonAsync<CreatedDto>(ct)
|
||||
?? throw new InvalidOperationException($"OpenZaak returned an empty response for {action}");
|
||||
return new Uri(created.Url);
|
||||
}
|
||||
|
||||
// EnsureSuccessStatusCode discards the response body; ZGW returns a JSON problem detail on 400 that
|
||||
// is essential for diagnosing a rejected request, so surface it in the exception.
|
||||
private static async Task EnsureSuccessAsync(HttpResponseMessage response, string action, CancellationToken ct)
|
||||
@@ -182,4 +235,26 @@ public sealed class OpenZaakGateway(HttpClient http, OpenZaakOptions options) :
|
||||
|
||||
private sealed record ResultaattypeDto(
|
||||
[property: JsonPropertyName("url")] string Url);
|
||||
|
||||
private sealed record CreatedDto(
|
||||
[property: JsonPropertyName("url")] string Url);
|
||||
|
||||
private sealed record EnkelvoudigInformatieobjectDto(
|
||||
[property: JsonPropertyName("bronorganisatie")] string Bronorganisatie,
|
||||
[property: JsonPropertyName("creatiedatum")] string Creatiedatum,
|
||||
[property: JsonPropertyName("titel")] string Titel,
|
||||
[property: JsonPropertyName("auteur")] string Auteur,
|
||||
[property: JsonPropertyName("taal")] string Taal,
|
||||
[property: JsonPropertyName("informatieobjecttype")] string Informatieobjecttype,
|
||||
[property: JsonPropertyName("inhoud")] string Inhoud,
|
||||
[property: JsonPropertyName("bestandsnaam")] string Bestandsnaam,
|
||||
[property: JsonPropertyName("bestandsomvang")] int Bestandsomvang,
|
||||
[property: JsonPropertyName("vertrouwelijkheidaanduiding")] string Vertrouwelijkheidaanduiding,
|
||||
[property: JsonPropertyName("formaat")] string Formaat,
|
||||
[property: JsonPropertyName("status")] string Status,
|
||||
[property: JsonPropertyName("indicatieGebruiksrecht")] bool IndicatieGebruiksrecht);
|
||||
|
||||
private sealed record ZaakInformatieobjectDto(
|
||||
[property: JsonPropertyName("zaak")] string Zaak,
|
||||
[property: JsonPropertyName("informatieobject")] string Informatieobject);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user