Class PromoteWorkflowManagerImpl

All Implemented Interfaces:
PromoteWorkflowManager, PromotionStrategy, QualifiedStrategy, PersistenceManagerAware, WorkflowSupport, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.core.Ordered
Direct Known Subclasses:
SimplePromotionStrategy

@Service("blPromoteWorkflowManager") public class PromoteWorkflowManagerImpl extends AbstractWorkflowManager implements PromoteWorkflowManager
Author:
Jeff Fischer
See Also:
  • Field Details

    • cacheInvalidationProducer

      protected CacheInvalidationProducer cacheInvalidationProducer
    • solrSandBoxChangeProducers

      protected List<SolrSandBoxChangeProducer> solrSandBoxChangeProducers
    • versionManager

      protected VersionManager versionManager
    • syncWorkflowManager

      protected SyncWorkflowManager syncWorkflowManager
    • idGenerationService

      protected org.broadleafcommerce.common.id.service.IdGenerationService idGenerationService
    • databaseSystemEventDao

      protected com.broadleafcommerce.jobsevents.dao.DatabaseSystemEventDao databaseSystemEventDao
    • adminSecurityServiceRemote

      protected org.broadleafcommerce.openadmin.server.security.remote.AdminSecurityServiceRemote adminSecurityServiceRemote
    • eventTransUtil

      protected org.broadleafcommerce.common.util.StreamingTransactionCapableUtil eventTransUtil
    • eventTransactionManager

      protected org.springframework.transaction.PlatformTransactionManager eventTransactionManager
    • workflowEventService

      protected WorkflowEventService workflowEventService
    • lockUtil

      protected ExecutionLockUtil lockUtil
    • adminRemoteSecurityService

      protected org.broadleafcommerce.openadmin.server.security.remote.SecurityVerifier adminRemoteSecurityService
    • basicWorkflowPersistenceModule

      protected BasicWorkflowPersistenceModule basicWorkflowPersistenceModule
    • extensionManager

      protected com.broadleafcommerce.enterprise.common.extension.enterprise.WorkflowManagerExtensionManager extensionManager
    • systemEventSender

      @Deprecated protected com.broadleafcommerce.jobsevents.service.SystemEventSender systemEventSender
      Deprecated.
      No longer used internally
    • enterpriseEventProducer

      protected EnterpriseEventProducer enterpriseEventProducer
    • solrWorkflowSandBoxUtil

      protected SolrWorkflowSandBoxUtil solrWorkflowSandBoxUtil
    • systemEventNode

      protected com.broadleafcommerce.jobsevents.service.DatabaseSystemEventNode systemEventNode
    • processStatusManager

      protected com.broadleafcommerce.jobsevents.service.ProcessStatusManager processStatusManager
    • workflowManager

      protected WorkflowManager workflowManager
    • connectionExceptionHelper

      protected ConnectionExceptionHelper connectionExceptionHelper
    • workflowFeatureService

      protected WorkflowFeatureService workflowFeatureService
    • DELETE_TARGET_ITEM_ID_ATTRIBUTE

      public static final String DELETE_TARGET_ITEM_ID_ATTRIBUTE
      See Also:
    • DELETE_TARGET_TYPE_ATTRIBUTE

      public static final String DELETE_TARGET_TYPE_ATTRIBUTE
      See Also:
  • Constructor Details

    • PromoteWorkflowManagerImpl

      public PromoteWorkflowManagerImpl()
  • Method Details

    • registerPromotionEventSynchronizationAdapter

      public static void registerPromotionEventSynchronizationAdapter(PromotionEventSynchronizationAdapter adapter)
    • getRegisteredPromotionEventSynchronizationAdapter

      public static PromotionEventSynchronizationAdapter getRegisteredPromotionEventSynchronizationAdapter()
    • init

      @PostConstruct public void init()
    • allow

      public Long[] allow(Long[] sandBoxItemIds)
      Description copied from interface: QualifiedStrategy
      Review the passed list of WorkflowSandBoxItem ids and determine what portion of the list is qualified to transition using this strategy.
      Specified by:
      allow in interface QualifiedStrategy
      Parameters:
      sandBoxItemIds - The list of items to check (usually a batch of items).
      Returns:
      The subset of items (or all) that are qualified to transition using this strategy.
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface org.springframework.core.Ordered
    • scheduleSandBoxItemChanges

      public Long scheduleSandBoxItemChanges(Long[] events, String msg, Date deployTime, WorkflowDeploymentRecurrenceType recurrenceType, String deploymentName) throws com.broadleafcommerce.enterprise.common.exception.ReplayException
      Description copied from interface: PromoteWorkflowManager
      Setup a job that will launch a deployment of the requested WorkflowSandBoxItem instances on the specified date.
      Specified by:
      scheduleSandBoxItemChanges in interface PromoteWorkflowManager
      Parameters:
      events - the event ids associated with the sandBoxItemIds
      msg - a deployment message
      deployTime - the time in the future to perform the deployment
      recurrenceType - the deployment recurrence type
      Returns:
      the id of the WorkflowDeployment instance created for this schedule
      Throws:
      com.broadleafcommerce.enterprise.common.exception.ReplayException
    • approveItemChanges

      public Long approveItemChanges(Long[] sandBoxItemIds, Long sandboxId)
      Specified by:
      approveItemChanges in interface PromoteWorkflowManager
    • scheduleUserSandboxItemChanges

      public Long scheduleUserSandboxItemChanges(Long[] sandBoxItemIds, Long sandboxId, String msg, Date deployTime, WorkflowDeploymentRecurrenceType recurrenceType, String deploymentName) throws com.broadleafcommerce.enterprise.common.exception.ReplayException
      Specified by:
      scheduleUserSandboxItemChanges in interface PromoteWorkflowManager
      Throws:
      com.broadleafcommerce.enterprise.common.exception.ReplayException
    • asyncPromoteSandBoxItemChanges

      public void asyncPromoteSandBoxItemChanges(Long targetSandBox, Long[] sandBoxItemIds, boolean createEvent, String eventName, String eventMessage, Boolean isCritical) throws com.broadleafcommerce.enterprise.common.exception.ReplayException
      Description copied from interface: PromoteWorkflowManager
      Move WorkflowSandBoxItem instances from their current sandbox to a parent sandbox. The original WorkflowSandBoxItem is archived and a new one is created in the target sandbox. Additionally, as part of the promotion, the change tied to the WorkflowSandBoxItem is replayed on the target sandbox and the same changes in the current sandbox are archived. This method causes the operation to perform asynchronously by sending a system event. See PromotionSystemEventConsumer for event consumption details.
      Specified by:
      asyncPromoteSandBoxItemChanges in interface PromoteWorkflowManager
      Parameters:
      targetSandBox - the sandbox to which the items will be promoted
      sandBoxItemIds - the primary key values representing the WorkflowSandBoxItem instances to be promoted
      createEvent - whether or not a WorkflowEvent should be created to encapsulate this promotion
      eventName - the name of the event to be created (can be null)
      eventMessage - the message associated with the event to be created (can be null)
      Throws:
      com.broadleafcommerce.enterprise.common.exception.ReplayException
    • cancelDeployment

      public void cancelDeployment(Long deploymentId) throws com.broadleafcommerce.enterprise.common.exception.ReplayException
      Description copied from interface: PromoteWorkflowManager
      Cancel a deployment schedule. This removed the schedule and puts all the scheduled items back in approval state.
      Specified by:
      cancelDeployment in interface PromoteWorkflowManager
      Parameters:
      deploymentId - the primary key value of the WorkflowDeployment instance for this schedule
      Throws:
      com.broadleafcommerce.enterprise.common.exception.ReplayException
    • cancelEvents

      public void cancelEvents(Long[] events) throws com.broadleafcommerce.enterprise.common.exception.ReplayException
      Description copied from interface: PromoteWorkflowManager
      A deployment schedule can be made up of several events. Remove one or more of these events without cancelling the entire deployment schedule using this method.
      Specified by:
      cancelEvents in interface PromoteWorkflowManager
      Parameters:
      events - the event ids to remove from the scheduled deployment
      Throws:
      com.broadleafcommerce.enterprise.common.exception.ReplayException
    • promoteSandBoxItemChanges

      public Long promoteSandBoxItemChanges(Long targetSandBox, Long[] sandBoxItemIds, Long eventId, String eventMessage, boolean isCritical) throws com.broadleafcommerce.enterprise.common.exception.ReplayException
      Description copied from interface: PromotionStrategy
      Move WorkflowSandBoxItem instances from their current sandbox to a parent sandbox. The original WorkflowSandBoxItem is archived and a new one is created in the target sandbox. Additionally, as part of the promotion, the change tied to the WorkflowSandBoxItem is replayed on the target sandbox and the same changes in the current sandbox are archived.

      This method is generally not called directly. Rather, PromoteWorkflowManager.asyncPromoteSandBoxItemChanges(Long, Long[], boolean, String, String, Boolean) or PromoteWorkflowManager.scheduleSandBoxItemChanges(Long[], String, Date, WorkflowDeploymentRecurrenceType, String) are called for asynchronous operation and engagement of the ProcessStatusManager for catastrophic recovery. In order to maintain ProcessStatusManager recovery functionality during a non-asynchronous call, it is desireable to create a SystemEvent with a scopeType of EventScopeType.NON_ASYNC_LOCAL or EventScopeType.NON_ASYNC_LOCAL_NO_RESUME and then use the SystemEventSender to launch the operation as a non-async, consumable event.
      Specified by:
      promoteSandBoxItemChanges in interface PromotionStrategy
      Parameters:
      targetSandBox - the sandbox to which the items will be promoted
      sandBoxItemIds - the primary key values representing the WorkflowSandBoxItem instances to be promoted
      eventId - the id of a pre-existing event
      eventMessage - the message associated with the event to be created (can be null)
      Returns:
      Throws:
      com.broadleafcommerce.enterprise.common.exception.ReplayException
    • promoteSandBoxItemChanges

      public Long promoteSandBoxItemChanges(Long targetSandBox, Long[] sandBoxItemIds, boolean createEvent, String eventName, String eventMessage, boolean isCritical) throws com.broadleafcommerce.enterprise.common.exception.ReplayException
      Description copied from interface: PromotionStrategy
      Move WorkflowSandBoxItem instances from their current sandbox to a parent sandbox. The original WorkflowSandBoxItem is archived and a new one is created in the target sandbox. Additionally, as part of the promotion, the change tied to the WorkflowSandBoxItem is replayed on the target sandbox and the same changes in the current sandbox are archived.

      This method is generally not called directly. Rather, PromoteWorkflowManager.asyncPromoteSandBoxItemChanges(Long, Long[], boolean, String, String, Boolean) or PromoteWorkflowManager.scheduleSandBoxItemChanges(Long[], String, Date, WorkflowDeploymentRecurrenceType, String) are called for asynchronous operation and engagement of the ProcessStatusManager for catastrophic recovery. In order to maintain ProcessStatusManager recovery functionality during a non-asynchronous call, it is desireable to create a SystemEvent with a scopeType of EventScopeType.NON_ASYNC_LOCAL or EventScopeType.NON_ASYNC_LOCAL_NO_RESUME and then use the SystemEventSender to launch the operation as a non-async, consumable event.
      Specified by:
      promoteSandBoxItemChanges in interface PromotionStrategy
      Parameters:
      targetSandBox - the sandbox to which the items will be promoted
      sandBoxItemIds - the primary key values representing the WorkflowSandBoxItem instances to be promoted
      createEvent - whether or not a WorkflowEvent should be created to encapsulate this promotion
      eventName - the name of the event to be created (can be null)
      eventMessage - the message associated with the event to be created (can be null)
      Returns:
      unique id marker for this promotion
      Throws:
      com.broadleafcommerce.enterprise.common.exception.ReplayException
    • promoteSandBoxItemChanges

      public Long promoteSandBoxItemChanges(Long targetSandBox, Long[] sandBoxItemIds, boolean createEvent, String eventName, String eventMessage) throws com.broadleafcommerce.enterprise.common.exception.ReplayException
      Description copied from interface: PromotionStrategy
      Move WorkflowSandBoxItem instances from their current sandbox to a parent sandbox. The original WorkflowSandBoxItem is archived and a new one is created in the target sandbox. Additionally, as part of the promotion, the change tied to the WorkflowSandBoxItem is replayed on the target sandbox and the same changes in the current sandbox are archived.

      This method is generally not called directly. Rather, PromoteWorkflowManager.asyncPromoteSandBoxItemChanges(Long, Long[], boolean, String, String, Boolean) or PromoteWorkflowManager.scheduleSandBoxItemChanges(Long[], String, Date, WorkflowDeploymentRecurrenceType, String) are called for asynchronous operation and engagement of the ProcessStatusManager for catastrophic recovery. In order to maintain ProcessStatusManager recovery functionality during a non-asynchronous call, it is desireable to create a SystemEvent with a scopeType of EventScopeType.NON_ASYNC_LOCAL or EventScopeType.NON_ASYNC_LOCAL_NO_RESUME and then use the SystemEventSender to launch the operation as a non-async, consumable event.
      Specified by:
      promoteSandBoxItemChanges in interface PromotionStrategy
      Parameters:
      targetSandBox - the sandbox to which the items will be promoted
      sandBoxItemIds - the primary key values representing the WorkflowSandBoxItem instances to be promoted
      createEvent - whether or not a WorkflowEvent should be created to encapsulate this promotion
      eventName - the name of the event to be created (can be null)
      eventMessage - the message associated with the event to be created (can be null)
      Returns:
      unique id marker for this promotion
      Throws:
      com.broadleafcommerce.enterprise.common.exception.ReplayException
    • unsetAsyncPromote

      public void unsetAsyncPromote(Long eventId, Long[] sandBoxItemIds)
      Description copied from interface: PromoteWorkflowManager
      Revert the setup for an asynchronous promotion. This includes archiving the empty event and unmarking all the sandbox items so that they are once again visible for promotion.
      Specified by:
      unsetAsyncPromote in interface PromoteWorkflowManager
    • unsetAsyncPromoteWithStatus

      public int unsetAsyncPromoteWithStatus(Long eventId, Long[] sandBoxItemIds)
      Specified by:
      unsetAsyncPromoteWithStatus in interface PromoteWorkflowManager
    • unsetAsyncApproval

      public void unsetAsyncApproval(Long eventId)
      Description copied from interface: PromoteWorkflowManager
      Revert the setup for an asynchronous approval. This includes unmarking all the events and items so that they are once again visible for approval.
      Specified by:
      unsetAsyncApproval in interface PromoteWorkflowManager
    • setupProcessStatusManager

      protected void setupProcessStatusManager(Long eventId)
    • getPromotionEventSynchronizationAdapter

      protected PromotionEventSynchronizationAdapter getPromotionEventSynchronizationAdapter()
    • setupEvent

      protected Long[] setupEvent(Long targetSandBox, Long[] sandBoxItemIds, WorkflowEventDTO eventDTO)
    • promoteSandBoxItemChanges

      protected Long promoteSandBoxItemChanges(Long targetSandBox, Long[] sandBoxItemIds, WorkflowEventDTO eventDTO) throws com.broadleafcommerce.enterprise.common.exception.ReplayException
      Throws:
      com.broadleafcommerce.enterprise.common.exception.ReplayException
    • validateSandboxItemForAddState

      protected void validateSandboxItemForAddState(Long sandBoxItemId, Long[] allPromotingSandboxItemIds)
      Parameters:
      sandBoxItemId - the current sandbox item we are promoting
      allPromotingSandboxItemIds - all of the sandbox ids within this entire promotion
    • markPromotionError

      protected void markPromotionError(Long sandBoxItemId, Exception e)
    • startPromoteEvent

      protected void startPromoteEvent(Long id, List<Long> sandBoxItemIds)
    • buildPromotionOperation

      protected com.broadleafcommerce.enterprise.common.extension.enterprise.PromotionOperation buildPromotionOperation(boolean isProd, Long[] holder, List<String> maxedRegions, Long targetSandBox, String eventMessage, Long[] event)
    • createPromotionSystemEvent

      protected void createPromotionSystemEvent(Long eventId, Long[] sandBoxItemIds, Boolean isCritical)
    • createDeploymentJob

      protected void createDeploymentJob(WorkflowDeployment deployment, Date deployTime, Long[] sandBoxItemIds, Long[] events, Long[] deploymentId)
    • createDeploymentItem

      public WorkflowDeployment createDeploymentItem(Long[] events, Date deployTime, String message, WorkflowDeploymentRecurrenceType recurrenceType, String deploymentName)
      Description copied from interface: PromoteWorkflowManager
      Creates an empty WorkflowDeployment scheduled for the given deploy time and recurrence type
      Specified by:
      createDeploymentItem in interface PromoteWorkflowManager
    • createDeploymentItem

      public WorkflowDeployment createDeploymentItem(Long[] events, Date deployTime, String message, WorkflowDeploymentRecurrenceType recurrenceType, String deploymentName, Long adminUserId)
      Description copied from interface: PromoteWorkflowManager
      Creates an empty WorkflowDeployment scheduled for the given deploy time and recurrence type
      Specified by:
      createDeploymentItem in interface PromoteWorkflowManager
    • setupAsyncPromote

      protected Long setupAsyncPromote(Long targetSandBox, String eventName, String eventMessage, Long[] sandBoxItemIds, Date deployTime) throws com.broadleafcommerce.enterprise.common.exception.ReplayException
      Throws:
      com.broadleafcommerce.enterprise.common.exception.ReplayException
    • markItemsScheduled

      protected void markItemsScheduled(Long[] sandBoxItemIds, Long[] events, Date deployTime, boolean isApproval) throws com.broadleafcommerce.enterprise.common.exception.ReplayException
      Throws:
      com.broadleafcommerce.enterprise.common.exception.ReplayException
    • unMarkItemsScheduled

      protected void unMarkItemsScheduled(Long[] sandBoxItemIds, Long[] events)
    • promoteSandBoxItemChange

      protected boolean promoteSandBoxItemChange(WorkflowSandBoxItem sandBoxItem, Long targetSandBox, String msg, Long processStatusMarker, boolean prod, Long event, List<String> maxedRegions, Set<Long> abandonedSandBoxItemIds) throws com.broadleafcommerce.enterprise.common.exception.ReplayException
      Throws:
      com.broadleafcommerce.enterprise.common.exception.ReplayException
    • invalidateAndIndex

      protected void invalidateAndIndex(Long targetSandBox, WorkflowSandBoxItem sourceItem, boolean prod, Long processStatusMarker, List<String> maxedRegions, WorkflowSandBoxItem promotedItem)
    • finalizePromote

      @Deprecated protected void finalizePromote(boolean prod, Long[] holder)
      Deprecated.
      No longer used internally
      Parameters:
      prod -
      holder -
    • createProcessStatusMarker

      protected void createProcessStatusMarker(boolean prod, Long[] holder)
    • addSandboxItemChangesToNewDeployment

      public Long addSandboxItemChangesToNewDeployment(WorkflowDeploymentRecurrenceType recurrenceType, Date deploymentDate, Long[] ids, Long[] eventIds, String name, String message) throws com.broadleafcommerce.enterprise.common.exception.ReplayException
      Description copied from interface: PromoteWorkflowManager
      Setup a job that will launch a deployment of the requested WorkflowSandBoxItem instances on the specified date.
      Specified by:
      addSandboxItemChangesToNewDeployment in interface PromoteWorkflowManager
      Parameters:
      recurrenceType - the recurrence type (ONCE, DAILY, WEEKLY, etc)
      deploymentDate - the time in the future to perform the deployment
      ids - the ids associated with the sandBoxItemIds
      eventIds - the event ids associated with the workflowEvent
      message - a deployment message
      Returns:
      the id of the WorkflowDeployment instance created for this schedule
      Throws:
      com.broadleafcommerce.enterprise.common.exception.ReplayException
    • markEventsAsApproved

      public void markEventsAsApproved(Long[] eventIds)
      Description copied from interface: PromoteWorkflowManager
      Mark spefcified WorkflowEvent instances as APPROVED
      Specified by:
      markEventsAsApproved in interface PromoteWorkflowManager
      Parameters:
      eventIds - the eventIds to mark
    • createEmptyDeploymentJob

      public Long createEmptyDeploymentJob(WorkflowDeployment deployment)
      Description copied from interface: PromoteWorkflowManager
      Create a scheduled job that will launch a deployment of the requested WorkflowDeployment on the specified date.
      Specified by:
      createEmptyDeploymentJob in interface PromoteWorkflowManager
      Parameters:
      deployment - the deployment to schedule
    • addSandboxItemChangesToExistingDeployment

      public Long addSandboxItemChangesToExistingDeployment(Long deploymentId, Long[] ids, Long[] eventIds, String message) throws com.broadleafcommerce.enterprise.common.exception.ReplayException
      Description copied from interface: PromoteWorkflowManager
      Add the requested WorkflowSandBoxItem instances to an existing deployment
      Specified by:
      addSandboxItemChangesToExistingDeployment in interface PromoteWorkflowManager
      Parameters:
      deploymentId - the recurrence type (ONCE, DAILY, WEEKLY, etc)
      ids - the ids associated with the sandBoxItemIds
      eventIds - the event ids associated with the workflowEvent
      message - a deployment message
      Returns:
      the id of the WorkflowDeployment instance created for this schedule
      Throws:
      com.broadleafcommerce.enterprise.common.exception.ReplayException
    • setPromotionMarker

      protected void setPromotionMarker(Long[] sandBoxItemIds, Long event)
    • buildScheduleRelatedDetails

      protected com.broadleafcommerce.jobsevents.domain.ScheduledJob buildScheduleRelatedDetails(Date deployTime, String msg, WorkflowDeploymentRecurrenceType recurrenceType)
    • buildNonRecurrenceCron

      protected String buildNonRecurrenceCron(Date deployTime)
    • buildDailyRecurrenceCron

      protected String buildDailyRecurrenceCron(Date deployTime)
    • buildWeeklyRecurrenceCron

      protected String buildWeeklyRecurrenceCron(Date deployTime)
    • buildMonthlyRecurrenceCron

      protected String buildMonthlyRecurrenceCron(Date deployTime)
    • buildYearlyRecurrenceCron

      protected String buildYearlyRecurrenceCron(Date deployTime)
    • buildContextRelatedDetails

      protected void buildContextRelatedDetails(com.broadleafcommerce.jobsevents.domain.ScheduledJob job)
    • generateEventListKey

      protected String generateEventListKey(Long[] events)
    • validateSyncStateForItems

      protected void validateSyncStateForItems(Long[] sandBoxItemIds) throws com.broadleafcommerce.enterprise.common.exception.ReplayException
      Throws:
      com.broadleafcommerce.enterprise.common.exception.ReplayException
    • validateSyncStateForItem

      protected void validateSyncStateForItem(WorkflowSandBoxItem child, boolean checkAutoSync, Long targetSandBox) throws com.broadleafcommerce.enterprise.common.exception.ReplayException
      Throws:
      com.broadleafcommerce.enterprise.common.exception.ReplayException
    • getWorkflowManager

      protected WorkflowManager getWorkflowManager()