Interface ViewDraftService
- All Known Implementing Classes:
ViewDraftServiceImpl
ViewDraft entities on behalf of the current authenticated user.
Every method operates strictly on the drafts belonging to the current authenticated user
(as reported by CurrentAuthentication), except deleteExpired() which
clears expired drafts of all users. When there is no authenticated user - neither an
authentication at all, nor an anonymous one - every other method is a silent no-op
returning an empty result.
-
Method Summary
Modifier and TypeMethodDescriptionvoidDeletes the current user's draft for the given view and entity identifier, if any.intDeletes drafts of all users older than the configured retention period.Finds the current user's draft for the given view and entity identifier.findAll()Returns all drafts of the current user, newest first.voidSaves a draft for the current user, creating or updating it.
-
Method Details
-
find
Finds the current user's draft for the given view and entity identifier.If a matching draft exists but is older than the configured retention period, it is deleted as a side effect and an empty result is returned (opportunistic cleanup).
- Parameters:
viewId- view identifierentityId- entity identifier the draft is associated with, ornullfor a draft not tied to a specific entity instance- Returns:
- the current user's draft, or empty if none exists, it has expired, or there is no authenticated user
-
findAll
Returns all drafts of the current user, newest first.Drafts older than the configured retention period are deleted as a side effect and are not returned (opportunistic cleanup), just as in
find(String, String).- Returns:
- the current user's drafts ordered by creation date descending, or an empty list if there are none or there is no authenticated user
-
save
Saves a draft for the current user, creating or updating it.This is an upsert: there is at most one draft per (username, viewId, entityId) combination. If a draft for this key already exists, it is updated in place; otherwise a new one is created.
Does nothing if there is no authenticated user.
- Parameters:
viewId- view identifierentityId- entity identifier the draft is associated with, ornullfor a draft not tied to a specific entity instancepayload- serialized draft content
-
delete
Deletes the current user's draft for the given view and entity identifier, if any.Does nothing if there is no authenticated user or no matching draft exists.
- Parameters:
viewId- view identifierentityId- entity identifier the draft is associated with, ornullfor a draft not tied to a specific entity instance
-
deleteExpired
int deleteExpired()Deletes drafts of all users older than the configured retention period.Unlike the other methods, this is not scoped to the current user and does not require an authenticated user, so a scheduled cleanup job can call it directly.
- Returns:
- the number of deleted drafts
-