Class DefaultAuditPruneService
java.lang.Object
com.broadleafcommerce.audit.service.DefaultAuditPruneService
- All Implemented Interfaces:
org.springframework.context.Lifecycle
,org.springframework.context.Phased
,org.springframework.context.SmartLifecycle
public class DefaultAuditPruneService
extends Object
implements org.springframework.context.SmartLifecycle
ClusterService
responsible for interval polling workflows whose retention period have
expired and deleting them.-
Field Summary
FieldsFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultAuditPruneService
(AuditPruneProperties properties, AuditHeaderRepository<com.broadleafcommerce.data.tracking.core.Trackable> headerRepository, AuditDetailRepository<com.broadleafcommerce.data.tracking.core.Trackable> detailRepository, org.springframework.scheduling.TaskScheduler scheduler, org.springframework.context.ApplicationEventPublisher eventPublisher) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
cleanup()
On interval, remove expired records from hot storage.boolean
boolean
boolean
preProcess
(List<String> headerPruneIds) Perform pre-processing onJpaAuditHeader
records before deletion as a result of exceeding the retention period.protected long
processPageOfResults
(Function<org.springframework.data.domain.Pageable, org.springframework.data.domain.Page<HeaderIdProjection>> fetch, org.springframework.data.domain.Pageable first) Find and attempt to clean upJpaAuditHeader
andJpaAuditDetail
records whereJpaAuditHeader.getExpiryDate()
orAuditPruneProperties.getRetentionPeriod()
is surpassed.void
start()
void
stop()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.SmartLifecycle
getPhase, stop
-
Field Details
-
started
protected boolean started
-
-
Constructor Details
-
DefaultAuditPruneService
public DefaultAuditPruneService(AuditPruneProperties properties, AuditHeaderRepository<com.broadleafcommerce.data.tracking.core.Trackable> headerRepository, AuditDetailRepository<com.broadleafcommerce.data.tracking.core.Trackable> detailRepository, org.springframework.scheduling.TaskScheduler scheduler, org.springframework.context.ApplicationEventPublisher eventPublisher)
-
-
Method Details
-
isRunning
public boolean isRunning()- Specified by:
isRunning
in interfaceorg.springframework.context.Lifecycle
-
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartup
in interfaceorg.springframework.context.SmartLifecycle
-
start
public void start()- Specified by:
start
in interfaceorg.springframework.context.Lifecycle
-
stop
public void stop()- Specified by:
stop
in interfaceorg.springframework.context.Lifecycle
-
cleanup
protected void cleanup()On interval, remove expired records from hot storage. SeepreProcess(List)
. -
processPageOfResults
protected long processPageOfResults(Function<org.springframework.data.domain.Pageable, org.springframework.data.domain.Page<HeaderIdProjection>> fetch, org.springframework.data.domain.Pageable first) Find and attempt to clean upJpaAuditHeader
andJpaAuditDetail
records whereJpaAuditHeader.getExpiryDate()
orAuditPruneProperties.getRetentionPeriod()
is surpassed. -
preProcess
Perform pre-processing onJpaAuditHeader
records before deletion as a result of exceeding the retention period. Several actions may be taken:- Do nothing and simply return the ids in the response collection so that the record may be cleared from hot storage.
- Strip ids out and don't return them in the collection so that the items are spared. In
this case, you may want to update the
JpaAuditHeader.setExpiryDate(Instant)
to a future timestamp to avoid unwanted repeat attempts for deletion. - Archive one or more of the records (headers and details) to a cold storage. Still return the ids in the response collection so that the records may be cleared from hot storage.
- Parameters:
headerPruneIds
- The primary key values of the deletion candidateJpaAuditHeader
entities- Returns:
- The possibly filtered list of ids that actually result in deletion (possibly a subset of the incoming list). The default is to return all the passed in ids.
-
isStarted
public boolean isStarted()
-