Class PromotionWorkflowRequestCompletionHandler
java.lang.Object
com.broadleafcommerce.sandbox.messaging.completion.PromotionWorkflowRequestCompletionHandler
- All Implemented Interfaces:
WorkflowRequestCompletionHandler
public class PromotionWorkflowRequestCompletionHandler
extends Object
implements WorkflowRequestCompletionHandler
Handles any
WorkflowRequestCompletion
s 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 boolean
areAllSummariesFinished
(List<String> ids, String sandbox) Deprecated, for removal: This API element is subject to removal in a future version.boolean
canHandle
(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Determines if this handler can handle the givenWorkflowRequestCompletion
.protected void
Deprecated, for removal: This API element is subject to removal in a future version.A new, more performant cleanup process is favored instead atDefaultGroupDeployedCleanupServices
.protected void
finishPromotion
(String groupId, com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Performs the final steps in promoting aChangeSummaryGroup
and itsChangeSummaries
: Updates the state of theChangeSummary
indicated in the request asChangeState.PROMOTED
and its status asChangeStatusType.FINISHED
If this is the last summary in the group to finish, then theChangeSummaryGroup
is marked likewise.protected void
finishSummaryPromotion
(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Performs the final steps in promoting aChangeSummary
: Updates aChangeSummary's
status asChangeStatusType.FINISHED
and its state asChangeState.PROMOTED
.protected PromotionWorkflowRequestErrorHandler
protected ChangeSummaryGroupService<ChangeSummaryGroup>
protected IndexNotificationService
protected ChangeSummaryService<ChangeSummary>
void
handle
(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) protected boolean
Deprecated, for removal: This API element is subject to removal in a future version.A new, more performant cleanup process is favored instead atDefaultGroupDeployedCleanupServices
.void
setProperties
(CompletionCleanupProperties properties) void
setSummaryRepository
(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:WorkflowRequestCompletionHandler
Determines if this handler can handle the givenWorkflowRequestCompletion
. This is typically done by checking theWorkflowRequestCompletion.getRequestType()
.- Specified by:
canHandle
in interfaceWorkflowRequestCompletionHandler
- Parameters:
completion
- aWorkflowRequestCompletion
received 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 aChangeSummaryGroup
ID and aChangeSummary
ID from thecompetion message
. If the promotion wassuccessful
, then marks the summary asChangeStatusType.FINISHED
andChangeState.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:
handle
in interfaceWorkflowRequestCompletionHandler
- Parameters:
completion
- aWorkflowRequestCompletion
received over theWorkflowRequestCompletionConsumer channel
with 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 aChangeSummaryGroup
and itsChangeSummaries
:- Updates the state of the
ChangeSummary
indicated in the request asChangeState.PROMOTED
- and its status as
ChangeStatusType.FINISHED
- If this is the last summary in the group to finish, then the
ChangeSummaryGroup
is marked likewise.
- Parameters:
completion
- TheWorkflowRequestCompletion
indicating 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's
status asChangeStatusType.FINISHED
and its state asChangeState.PROMOTED
.- Parameters:
completion
- TheWorkflowRequestCompletion
containing 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 theChangeSummaryGroup
and updates its status toChangeStatusType.FINISHED
and state toChangeState.PROMOTED
.- Parameters:
group
- theChangeSummaryGroup
to 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 theChangeSummaryGroup
has already been marked ashaving encountered an error during promotions
.Usually, this will happen due to an error in one of the group's
ChangeSummaries
rather than because of an error processing the group itself.- Parameters:
group
- TheChangeSummaryGroup
whose 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 theChangeSummaries
in theChangeSummaryGroup
have finished being promoted.This check is done to prevent the
ChangeSummaryGroup
from 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
.