Class CleanupCampaignLifecycle
java.lang.Object
org.exoplatform.addons.documents.cleanup.service.CleanupCampaignLifecycle
Single authority over campaign state transitions and their side effects: the
allowed-transitions guard, persisting the new state, the WebSocket
stateChanged event, and registering/unregistering the JCR freshness
observation listener on entry/exit of PUBLISHED. Every state change of the
cleanup services goes through
transition(org.exoplatform.addons.documents.cleanup.model.CleanupCampaign, org.exoplatform.addons.documents.cleanup.constant.CleanupCampaignState). Depends only on Storage
and the WebSocket service, never on the cleanup services (no bean cycle).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiontransition(CleanupCampaign campaign, CleanupCampaignState targetState) Variant oftransition(CleanupCampaign, CleanupCampaignState, BiConsumer)for transitions never entering PUBLISHED.transition(CleanupCampaign campaign, CleanupCampaignState targetState, BiConsumer<String, String> refreshCallback) Applies a campaign state transition with all its side effects: guards it against the allowed-transitions map, persists the new state, registers/unregisters the JCR freshness observation listener on entry/exit of PUBLISHED (a campaign leaving PUBLISHED or getting cancelled never leaks the listener) and broadcasts the stateChanged WebSocket event.
-
Constructor Details
-
CleanupCampaignLifecycle
public CleanupCampaignLifecycle()
-
-
Method Details
-
transition
Variant oftransition(CleanupCampaign, CleanupCampaignState, BiConsumer)for transitions never entering PUBLISHED.- Parameters:
campaign- campaign to transition, its non-state fields already settargetState- target state- Returns:
- the persisted campaign
-
transition
public CleanupCampaign transition(CleanupCampaign campaign, CleanupCampaignState targetState, BiConsumer<String, String> refreshCallback) Applies a campaign state transition with all its side effects: guards it against the allowed-transitions map, persists the new state, registers/unregisters the JCR freshness observation listener on entry/exit of PUBLISHED (a campaign leaving PUBLISHED or getting cancelled never leaks the listener) and broadcasts the stateChanged WebSocket event.- Parameters:
campaign- campaign to transition, its non-state fields already settargetState- target staterefreshCallback- observation callback, mandatory when entering PUBLISHED- Returns:
- the persisted campaign
- Throws:
IllegalArgumentException- "cleanup.invalidState" on an illegal transition
-