Class PromotionWorkflowRequestCompletionHandler
java.lang.Object
com.broadleafcommerce.sandbox.messaging.completion.PromotionWorkflowRequestCompletionHandler
- All Implemented Interfaces:
WorkflowRequestCompletionHandler
public class PromotionWorkflowRequestCompletionHandler
extends Object
implements WorkflowRequestCompletionHandler
Handles any
WorkflowRequestCompletions resulting from WorkflowPromoteRequest- Author:
- Jeff Fischer, Nathan Moore (nathandmoore), Phillip Verheyden (phillipuniverse)
-
Constructor Summary
ConstructorsConstructorDescriptionPromotionWorkflowRequestCompletionHandler(ChangeSummaryService<ChangeSummary> summaryService, ChangeSummaryGroupService<ChangeSummaryGroup> groupService, PromotionWorkflowRequestErrorHandler errorHandler, IndexNotificationService indexNotificationService) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanareAllSummariesFinished(List<String> ids, String sandbox) Deprecated, for removal: This API element is subject to removal in a future version.booleancanHandle(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Determines if this handler can handle the givenWorkflowRequestCompletion.protected voidDeprecated, for removal: This API element is subject to removal in a future version.A new, more performant cleanup process is favored instead atDefaultGroupDeployedCleanupServices.protected voidfinishPromotion(String groupId, com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Performs the final steps in promoting aChangeSummaryGroupand itsChangeSummaries: Updates the state of theChangeSummaryindicated in the request asChangeState.PROMOTEDand its status asChangeStatusType.FINISHEDIf this is the last summary in the group to finish, then theChangeSummaryGroupis marked likewise.protected voidfinishSummaryPromotion(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Performs the final steps in promoting aChangeSummary: Updates aChangeSummary'sstatus asChangeStatusType.FINISHEDand its state asChangeState.PROMOTED.protected PromotionWorkflowRequestErrorHandlerprotected ChangeSummaryGroupService<ChangeSummaryGroup>protected IndexNotificationServiceprotected ChangeSummaryService<ChangeSummary>voidhandle(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) protected booleanDeprecated, for removal: This API element is subject to removal in a future version.A new, more performant cleanup process is favored instead atDefaultGroupDeployedCleanupServices.voidsetProperties(CompletionCleanupProperties properties) voidsetSummaryRepository(ChangeSummaryRepository<com.broadleafcommerce.data.tracking.core.mapping.ModelMapperMappable> summaryRepository)
-
Constructor Details
-
PromotionWorkflowRequestCompletionHandler
public PromotionWorkflowRequestCompletionHandler(ChangeSummaryService<ChangeSummary> summaryService, ChangeSummaryGroupService<ChangeSummaryGroup> groupService, PromotionWorkflowRequestErrorHandler errorHandler, IndexNotificationService indexNotificationService)
-
-
Method Details
-
canHandle
public boolean canHandle(@NonNull com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Description copied from interface:WorkflowRequestCompletionHandlerDetermines if this handler can handle the givenWorkflowRequestCompletion. This is typically done by checking theWorkflowRequestCompletion.getRequestType().- Specified by:
canHandlein interfaceWorkflowRequestCompletionHandler- Parameters:
completion- aWorkflowRequestCompletionreceived over theWorkflowRequestCompletionConsumer channel- Returns:
- whether this handler can handle the given
WorkflowRequestCompletion
-
handle
public void handle(@NonNull com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Gleans aChangeSummaryGroupID and aChangeSummaryID from thecompetion message. If the promotion wassuccessful, then marks the summary asChangeStatusType.FINISHEDandChangeState.PROMOTED. If successful and this is the last change summary in the group, also marks the group as finished and promoted.If the promotion failed, then marks the summary and group as
ChangeStatusType.ERROR_PROMOTE.- Specified by:
handlein interfaceWorkflowRequestCompletionHandler- Parameters:
completion- aWorkflowRequestCompletionreceived over theWorkflowRequestCompletionConsumer channelwith information about the promoted changes
-
finishPromotion
protected void finishPromotion(String groupId, com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Performs the final steps in promoting aChangeSummaryGroupand itsChangeSummaries:- Updates the state of the
ChangeSummaryindicated in the request asChangeState.PROMOTED - and its status as
ChangeStatusType.FINISHED - If this is the last summary in the group to finish, then the
ChangeSummaryGroupis marked likewise.
- Parameters:
completion- TheWorkflowRequestCompletionindicating the group and summary for which to finish the promoting processgroupId- The ID of the group gleaned from the completion message- Throws:
IllegalStateException- Thrown if the summary's ID is missing from theWorkflowRequestCompletion.getTransferTypeIdMap().QualifiedStateException- Thrown if either the group or summary encounters errors while being updated.
- Updates the state of the
-
finishSummaryPromotion
protected void finishSummaryPromotion(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Performs the final steps in promoting aChangeSummary: Updates aChangeSummary'sstatus asChangeStatusType.FINISHEDand its state asChangeState.PROMOTED.- Parameters:
completion- TheWorkflowRequestCompletioncontaining the information needed to identify a promotedChangeSummary.- Throws:
QualifiedStateException- Thrown if the update fails.
-
finishGroupPromotion
@Deprecated(forRemoval=true, since="2.0.1") protected void finishGroupPromotion(ChangeSummaryGroup group) Deprecated, for removal: This API element is subject to removal in a future version.A new, more performant cleanup process is favored instead atDefaultGroupDeployedCleanupServices. SeeCompletionCleanupProperties.isEnabled().Obtains a lock on theChangeSummaryGroupand updates its status toChangeStatusType.FINISHEDand state toChangeState.PROMOTED.- Parameters:
group- theChangeSummaryGroupto update- Throws:
QualifiedStateException- Thrown if the update fails.
-
isGroupInErrorState
@Deprecated(forRemoval=true, since="2.0.1") protected boolean isGroupInErrorState(ChangeSummaryGroup group) Deprecated, for removal: This API element is subject to removal in a future version.A new, more performant cleanup process is favored instead atDefaultGroupDeployedCleanupServices. SeeCompletionCleanupProperties.isEnabled().Checks if theChangeSummaryGrouphas already been marked ashaving encountered an error during promotions.Usually, this will happen due to an error in one of the group's
ChangeSummariesrather than because of an error processing the group itself.- Parameters:
group- TheChangeSummaryGroupwhose status to check- Returns:
- whether the group has already been marked as having encountered an error.
-
areAllSummariesFinished
@Deprecated(forRemoval=true, since="2.0.1") protected boolean areAllSummariesFinished(List<String> ids, String sandbox) Deprecated, for removal: This API element is subject to removal in a future version.A new, more performant cleanup process is favored instead atDefaultGroupDeployedCleanupServices. SeeCompletionCleanupProperties.isEnabled().Check if all of theChangeSummariesin theChangeSummaryGrouphave finished being promoted.This check is done to prevent the
ChangeSummaryGroupfrom being updated until all its summaries have been processed.- Parameters:
ids- All the change summary ids that will be associated with the group for the transitionsandbox- The sandbox in which the transition is taking place- Returns:
- whether all of the group's summaries have finished being promoted.
-
getSummaryService
-
getGroupService
-
getErrorHandler
-
getIndexNotificationService
-
setProperties
-
setSummaryRepository
@Autowired public void setSummaryRepository(ChangeSummaryRepository<com.broadleafcommerce.data.tracking.core.mapping.ModelMapperMappable> summaryRepository)
-
DefaultGroupDeployedCleanupServices.