feat(domain): ProvideDocuments stores the diploma via the ACL then completes the wait (refs #103)
IAclClient.StoreDiplomaAsync + AclHttpClient (base64 JSON to the ACL /documenten endpoint). ProvideDocuments stores the uploaded bytes against the zaak (when opened) before completing WachtOpDocumenten; the domain endpoint accepts the file base64-encoded. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -120,8 +120,17 @@ app.MapPost("/registrations/{id}/documents", async (string id, ProvideDocumentsR
|
||||
|
||||
if (string.IsNullOrWhiteSpace(body?.Bsn))
|
||||
return Results.BadRequest(new { error = "A bsn is required to provide documents." });
|
||||
if (string.IsNullOrWhiteSpace(body.ContentBase64))
|
||||
return Results.BadRequest(new { error = "A document is required." });
|
||||
|
||||
var outcome = await provide.HandleAsync(new ProvideDocumentsCommand(new RegistrationId(guid), body.Bsn), ct);
|
||||
byte[] content;
|
||||
try { content = Convert.FromBase64String(body.ContentBase64); }
|
||||
catch (FormatException) { return Results.BadRequest(new { error = "The document content is not valid base64." }); }
|
||||
|
||||
var command = new ProvideDocumentsCommand(
|
||||
new RegistrationId(guid), body.Bsn, content,
|
||||
body.FileName ?? "diploma.pdf", body.ContentType ?? "application/pdf");
|
||||
var outcome = await provide.HandleAsync(command, ct);
|
||||
return outcome == ProvideDocumentsOutcome.Accepted ? Results.NoContent() : Results.NotFound();
|
||||
});
|
||||
|
||||
@@ -152,7 +161,7 @@ public sealed record DecideRequest(string Besluit);
|
||||
|
||||
public sealed record WithdrawRequest(string Bsn);
|
||||
|
||||
public sealed record ProvideDocumentsRequest(string Bsn);
|
||||
public sealed record ProvideDocumentsRequest(string Bsn, string ContentBase64, string? FileName = null, string? ContentType = null);
|
||||
|
||||
public sealed record RegistrationResponse(string RegistrationId, string Status, string? ZaakUrl);
|
||||
|
||||
|
||||
@@ -52,6 +52,13 @@ public interface IAclClient
|
||||
/// the zaak's final status — which OpenZaak notifies over NRC; the domain never names statustypen.
|
||||
/// </summary>
|
||||
Task ApproveZaakAsync(Uri zaakUrl, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Store an uploaded diploma against the zaak (S-10b). The domain hands over the zaak, the raw file
|
||||
/// bytes, and the file's name/type; the ACL creates the ZGW informatieobject and relates it to the
|
||||
/// zaak (§8.1). Returns the stored document's URL.
|
||||
/// </summary>
|
||||
Task<Uri> StoreDiplomaAsync(Uri zaakUrl, byte[] content, string fileName, string contentType, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,10 +2,12 @@ using Big.Domain;
|
||||
|
||||
namespace Big.Application;
|
||||
|
||||
/// <summary>A zorgprofessional's signal that they have supplied the documents their registration is
|
||||
/// waiting for ("documenten aanleveren"). <paramref name="Bsn"/> is the authenticated caller (from the
|
||||
/// DigiD token, forwarded by the BFF): only the registration's own bsn may provide its documents.</summary>
|
||||
public sealed record ProvideDocumentsCommand(RegistrationId RegistrationId, string Bsn);
|
||||
/// <summary>A zorgprofessional's upload of the diploma their registration is waiting for ("documenten
|
||||
/// aanleveren"). <paramref name="Bsn"/> is the authenticated caller (from the DigiD token, forwarded by
|
||||
/// the BFF): only the registration's own bsn may provide its documents. <paramref name="Content"/> is
|
||||
/// the raw file, with its <paramref name="FileName"/> and <paramref name="ContentType"/>.</summary>
|
||||
public sealed record ProvideDocumentsCommand(
|
||||
RegistrationId RegistrationId, string Bsn, byte[] Content, string FileName, string ContentType);
|
||||
|
||||
/// <summary>The outcome of a provide-documents request.</summary>
|
||||
public enum ProvideDocumentsOutcome
|
||||
@@ -19,14 +21,14 @@ public enum ProvideDocumentsOutcome
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The provide-documents use case (S-10a): a zorgprofessional supplies the documents their registration
|
||||
/// is parked waiting for, completing the WachtOpDocumenten task so the registratie process leaves the
|
||||
/// 30-day wait and continues to beoordeling (ADR-0017). Owner-scoped by bsn. Completing the wait is
|
||||
/// best-effort: if the registration never started a process (or already left the wait), the request
|
||||
/// still stands, mirroring how <see cref="WithdrawRegistration"/> cancels best-effort. The actual file
|
||||
/// upload and its ZGW storage via the ACL is S-10b; this is the trigger that unblocks the process.
|
||||
/// The provide-documents use case (S-10a/S-10b): a zorgprofessional uploads the diploma their
|
||||
/// registration is parked waiting for. The document is stored in ZGW via the ACL (§8.1), then the
|
||||
/// WachtOpDocumenten task is completed so the registratie process leaves the 30-day wait and continues
|
||||
/// to beoordeling (ADR-0017). Owner-scoped by bsn. Both steps are best-effort about missing preconditions
|
||||
/// (mirroring <see cref="WithdrawRegistration"/>): storage needs an opened zaak, and completion needs a
|
||||
/// running process — a request that arrives before either still stands, storing/completing what it can.
|
||||
/// </summary>
|
||||
public sealed class ProvideDocuments(IRegistrationStore store, IWorkflowClient workflow)
|
||||
public sealed class ProvideDocuments(IRegistrationStore store, IWorkflowClient workflow, IAclClient acl)
|
||||
{
|
||||
public async Task<ProvideDocumentsOutcome> HandleAsync(ProvideDocumentsCommand command, CancellationToken ct = default)
|
||||
{
|
||||
@@ -38,6 +40,11 @@ public sealed class ProvideDocuments(IRegistrationStore store, IWorkflowClient w
|
||||
if (registration is null || registration.Bsn != command.Bsn)
|
||||
return ProvideDocumentsOutcome.NotFound;
|
||||
|
||||
// Store the diploma against the zaak (once it is opened) — the ACL is the only ZGW caller (§8.1).
|
||||
if (registration.ZaakUrl is not null)
|
||||
await acl.StoreDiplomaAsync(
|
||||
registration.ZaakUrl, command.Content, command.FileName, command.ContentType, ct);
|
||||
|
||||
// Complete the document wait (if a process is running) so beoordeling can proceed.
|
||||
if (registration.ProcessInstanceId is not null)
|
||||
await workflow.CompleteDocumentWaitAsync(registration.ProcessInstanceId, ct);
|
||||
|
||||
@@ -31,6 +31,23 @@ public sealed class AclHttpClient(HttpClient http, AclOptions options) : IAclCli
|
||||
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);
|
||||
@@ -38,4 +55,13 @@ public sealed class AclHttpClient(HttpClient http, AclOptions options) : IAclCli
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public sealed class EenZaakOpenenSteps
|
||||
VerantwoordelijkeOrganisatie = values["verantwoordelijkeOrganisatie"],
|
||||
Vertrouwelijkheidaanduiding = values["vertrouwelijkheidaanduiding"],
|
||||
ZaaktypeUrl = new Uri(values["zaaktype"]),
|
||||
InformatieobjecttypeUrl = new Uri("http://openzaak/catalogi/api/v1/informatieobjecttypen/dip"),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,14 @@ public sealed class InMemoryAclClient : IAclClient
|
||||
ApprovedZaakUrl = zaakUrl;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public (Uri ZaakUrl, string FileName)? StoredDiploma { get; private set; }
|
||||
|
||||
public Task<Uri> StoreDiplomaAsync(Uri zaakUrl, byte[] content, string fileName, string contentType, CancellationToken ct = default)
|
||||
{
|
||||
StoredDiploma = (zaakUrl, fileName);
|
||||
return Task.FromResult(new Uri("http://openzaak/documenten/api/v1/enkelvoudiginformatieobjecten/acc-doc"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>An in-memory user-task client for the beoordeling acceptance scenario: it holds one open
|
||||
|
||||
@@ -27,4 +27,7 @@ public sealed class InMemoryZaakGateway : IZaakGateway
|
||||
|
||||
public Task<string> GetZaakIdentificatieAsync(Uri zaakUrl, CancellationToken ct = default)
|
||||
=> Task.FromResult("ACC-REF-1");
|
||||
|
||||
public Task<Uri> StoreDocumentAsync(DocumentRequest request, CancellationToken ct = default)
|
||||
=> Task.FromResult(new Uri("http://openzaak/documenten/api/v1/enkelvoudiginformatieobjecten/acc-doc"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user