Class RejectionWorkflowRequestCompletionHandler
java.lang.Object
com.broadleafcommerce.sandbox.messaging.completion.RejectionWorkflowRequestCompletionHandler
- All Implemented Interfaces:
WorkflowRequestCompletionHandler
public class RejectionWorkflowRequestCompletionHandler
extends Object
implements WorkflowRequestCompletionHandler
This handler deals with cleaning up rejected
ChangeSummaryGroups'
states and statuses.- Author:
- Nathan Moore (nathandmoore)
-
Constructor Summary
ConstructorsConstructorDescriptionRejectionWorkflowRequestCompletionHandler
(ChangeSummaryService<ChangeSummary> summaryService, ChangeSummaryGroupService<ChangeSummaryGroup> groupService, RejectionWorkflowRequestErrorHandler errorHandler, IndexNotificationService indexNotificationService) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
archiveGroup
(ChangeSummaryGroup group) Deprecated, for removal: This API element is subject to removal in a future version.protected boolean
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
finishRejection
(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion, String groupId) Performs the final steps in rejecting aChangeSummaryGroup
and itsChangeSummaries
: Updates the state of theChangeSummary
indicated in the request asChangeState.USER
and its status asChangeStatusType.FINISHED
If this is the last summary in the group to finish, then theChangeSummaryGroup
is archived.protected void
finishSummaryRejection
(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Performs the final steps in rejecting aChangeSummary
: Updates aChangeSummary's
status asChangeStatusType.FINISHED
and its state asChangeState.USER
.protected RejectionWorkflowRequestErrorHandler
protected ChangeSummaryGroupService<ChangeSummaryGroup>
protected IndexNotificationService
protected ChangeSummaryService<ChangeSummary>
void
handle
(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Gleans the ID of theChangeSummaryGroup
for which to complete the rejection process and whether the microservice sending thecompletion message
encountered errors while performing the rejection.void
setProperties
(CompletionCleanupProperties properties) void
setSummaryRepository
(ChangeSummaryRepository<com.broadleafcommerce.data.tracking.core.mapping.ModelMapperMappable> summaryRepository)
-
Constructor Details
-
RejectionWorkflowRequestCompletionHandler
public RejectionWorkflowRequestCompletionHandler(ChangeSummaryService<ChangeSummary> summaryService, ChangeSummaryGroupService<ChangeSummaryGroup> groupService, RejectionWorkflowRequestErrorHandler 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 the ID of theChangeSummaryGroup
for which to complete the rejection process and whether the microservice sending thecompletion message
encountered errors while performing the rejection.If errors were encountered, the statuses of the group and summary are udpated to
ChangeStatusType.ERROR_REJECT
and the error stack trace is recorded onto them.- Specified by:
handle
in interfaceWorkflowRequestCompletionHandler
- Parameters:
completion
- aWorkflowRequestCompletion
received over theWorkflowRequestCompletionConsumer channel
containing information about the rejectedChangeSummaryGroup
and one of itsChangeSummaries
for which to complete the rejection process.
-
finishRejection
protected void finishRejection(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion, String groupId) Performs the final steps in rejecting aChangeSummaryGroup
and itsChangeSummaries
:- Updates the state of the
ChangeSummary
indicated in the request asChangeState.USER
- and its status as
ChangeStatusType.FINISHED
- If this is the last summary in the group to finish, then the
ChangeSummaryGroup
is archived.
- Parameters:
completion
- TheWorkflowRequestCompletion
indicating the group and summary for which to finish the rejection 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
-
finishSummaryRejection
protected void finishSummaryRejection(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Performs the final steps in rejecting aChangeSummary
: Updates aChangeSummary's
status asChangeStatusType.FINISHED
and its state asChangeState.USER
.- Parameters:
completion
- TheWorkflowRequestCompletion
containing the information needed to identify a rejectedChangeSummary
.- Throws:
QualifiedStateException
- Thrown if the update fails.
-
areAllSummariesFinished
@Deprecated(forRemoval=true, since="2.0.1") protected boolean areAllSummariesFinished(ChangeSummaryGroup group) Deprecated, for removal: This API element is subject to removal in a future version.Check if all of theChangeSummaries
in theChangeSummaryGroup
have finished being rejected.This check is done to prevent the
ChangeSummaryGroup
from being archived until all its summaries have been processed.- Parameters:
group
- TheChangeSummaryGroup
to potentially finish rejecting- Returns:
- whether all of the group's summaries have finished being rejected.
-
archiveGroup
Deprecated, for removal: This API element is subject to removal in a future version.Obtains a lock on theChangeSummaryGroup
and updates its status toChangeStatusType.REJECTED
and marks it as archived.- Parameters:
group
- theChangeSummaryGroup
to update- Throws:
QualifiedStateException
- Thrown if the update fails.
-
getSummaryService
-
getGroupService
-
getErrorHandler
-
getIndexNotificationService
-
setProperties
-
setSummaryRepository
@Autowired public void setSummaryRepository(ChangeSummaryRepository<com.broadleafcommerce.data.tracking.core.mapping.ModelMapperMappable> summaryRepository)
-