Class ViewDraftServiceImpl
- All Implemented Interfaces:
ViewDraftService
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CurrentAuthenticationprotected UnconstrainedDataManagerprotected UiRecoveryDraftsPropertiesprotected TimeSourceprotected org.springframework.transaction.support.TransactionTemplate -
Constructor Summary
Constructors -
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.protected OffsetDateTimeFinds the current user's draft for the given view and entity identifier.findAll()Returns all drafts of the current user, newest first.protected @Nullable ViewDraftprotected booleanprotected booleanAn anonymous authentication is set while nobody is logged in, and its principal is not aUserDetails, so it does not count as an authenticated user here.voidSaves a draft for the current user, creating or updating it.protected voidsetTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) Every write runs in its own transaction, so a draft write never joins - or is rolled back by - a surrounding business transaction.
-
Field Details
-
authentication
-
dataManager
-
timeSource
-
properties
-
transaction
protected org.springframework.transaction.support.TransactionTemplate transaction
-
-
Constructor Details
-
ViewDraftServiceImpl
public ViewDraftServiceImpl()
-
-
Method Details
-
setTransactionManager
@Autowired protected void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) Every write runs in its own transaction, so a draft write never joins - or is rolled back by - a surrounding business transaction. -
find
Description copied from interface:ViewDraftServiceFinds 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).
- Specified by:
findin interfaceViewDraftService- 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
Description copied from interface:ViewDraftServiceReturns 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
ViewDraftService.find(String, String).- Specified by:
findAllin interfaceViewDraftService- 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
Description copied from interface:ViewDraftServiceSaves 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.
- Specified by:
savein interfaceViewDraftService- 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
Description copied from interface:ViewDraftServiceDeletes 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.
- Specified by:
deletein interfaceViewDraftService- Parameters:
viewId- view identifierentityId- entity identifier the draft is associated with, ornullfor a draft not tied to a specific entity instance
-
deleteExpired
public int deleteExpired()Description copied from interface:ViewDraftServiceDeletes 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.
- Specified by:
deleteExpiredin interfaceViewDraftService- Returns:
- the number of deleted drafts
-
findDraft
-
isExpired
-
expiryThreshold
-
notAuthenticated
protected boolean notAuthenticated()An anonymous authentication is set while nobody is logged in, and its principal is not aUserDetails, so it does not count as an authenticated user here.
-