Class CleanupCampaignLifecycle

java.lang.Object
org.exoplatform.addons.documents.cleanup.service.CleanupCampaignLifecycle

@Component public class CleanupCampaignLifecycle extends Object
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 Details

    • CleanupCampaignLifecycle

      public CleanupCampaignLifecycle()
  • Method Details

    • transition

      public CleanupCampaign transition(CleanupCampaign campaign, CleanupCampaignState targetState)
      Variant of transition(CleanupCampaign, CleanupCampaignState, BiConsumer) for transitions never entering PUBLISHED.
      Parameters:
      campaign - campaign to transition, its non-state fields already set
      targetState - 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 set
      targetState - target state
      refreshCallback - observation callback, mandatory when entering PUBLISHED
      Returns:
      the persisted campaign
      Throws:
      IllegalArgumentException - "cleanup.invalidState" on an illegal transition