Package su.onno.ui
Class DocumentCommandService
java.lang.Object
su.onno.ui.DocumentCommandService
Write-side commands for documents — create, update, delete, post, unpost — plus
the document reconstruction needed for posting. Extracted from
GenericDocumentController so the same code path is shared by the REST API
and other callers (e.g. the MCP server), and access control / read-only checks
are enforced in exactly one place.
Every mutating method enforces requireWritable() (global read-only mode)
and UiAccessService.requireWrite(java.security.Principal, su.onno.metadata.CatalogDescriptor) against the caller's Principal, so
callers never bypass the role model.
-
Constructor Summary
ConstructorsConstructorDescriptionDocumentCommandService(MetadataRegistry registry, org.jdbi.v3.core.Jdbi jdbi, UiProperties properties, NumberGenerator numberGenerator, PostingService postingService, DocumentQueryService query, UiAccessService access, org.springframework.context.ApplicationEventPublisher events, SecretCipher secretCipher) -
Method Summary
Modifier and TypeMethodDescriptionvoiddelete(DocumentDescriptor desc, UUID id, Principal principal) post(DocumentDescriptor desc, UUID id, Principal principal) postingPreview(DocumentDescriptor desc, UUID id, Principal principal) unpost(DocumentDescriptor desc, UUID id, Principal principal) Dry-run the write lifecycle against a form's current values and report every failure without persisting anything — the backend of the form's live (as-you-type) validation.
-
Constructor Details
-
DocumentCommandService
public DocumentCommandService(MetadataRegistry registry, org.jdbi.v3.core.Jdbi jdbi, UiProperties properties, NumberGenerator numberGenerator, PostingService postingService, DocumentQueryService query, UiAccessService access, org.springframework.context.ApplicationEventPublisher events, SecretCipher secretCipher)
-
-
Method Details
-
create
-
update
-
validate
public Map<String,Object> validate(DocumentDescriptor desc, UUID id, Map<String, Object> requestBody, Principal principal) Dry-run the write lifecycle against a form's current values and report every failure without persisting anything — the backend of the form's live (as-you-type) validation. Runs the same pipeline ascreate(su.onno.metadata.DocumentDescriptor, java.util.Map<java.lang.String, java.lang.Object>, java.security.Principal)/update(su.onno.metadata.DocumentDescriptor, java.util.UUID, java.util.Map<java.lang.String, java.lang.Object>, java.security.Principal): declarative attribute constraints, then the typed document'sonFilling/beforeWritehooks andValidatedrules on the merged state (tabular rows included), so a conflict check written in Java surfaces while the user is still on the field. No number is consumed from the sequence and no events fire. Always returns 200 — the outcome is the{valid, fieldErrors, formErrors}payload. -
post
-
postingPreview
-
unpost
-
delete
-