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 voidarchiveGroup(ChangeSummaryGroup group) Deprecated, for removal: This API element is subject to removal in a future version.protected booleanDeprecated, 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 voidfinishRejection(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion, String groupId) Performs the final steps in rejecting aChangeSummaryGroupand itsChangeSummaries: Updates the state of theChangeSummaryindicated in the request asChangeState.USERand its status asChangeStatusType.FINISHEDIf this is the last summary in the group to finish, then theChangeSummaryGroupis archived.protected voidfinishSummaryRejection(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Performs the final steps in rejecting aChangeSummary: Updates aChangeSummary'sstatus asChangeStatusType.FINISHEDand its state asChangeState.USER.protected RejectionWorkflowRequestErrorHandlerprotected ChangeSummaryGroupService<ChangeSummaryGroup>protected IndexNotificationServiceprotected ChangeSummaryService<ChangeSummary>voidhandle(com.broadleafcommerce.data.tracking.core.transition.WorkflowRequestCompletion completion) Gleans the ID of theChangeSummaryGroupfor which to complete the rejection process and whether the microservice sending thecompletion messageencountered errors while performing the rejection.voidsetProperties(CompletionCleanupProperties properties) voidsetSummaryRepository(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: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 the ID of theChangeSummaryGroupfor which to complete the rejection process and whether the microservice sending thecompletion messageencountered errors while performing the rejection.If errors were encountered, the statuses of the group and summary are udpated to
ChangeStatusType.ERROR_REJECTand the error stack trace is recorded onto them.- Specified by:
handlein interfaceWorkflowRequestCompletionHandler- Parameters:
completion- aWorkflowRequestCompletionreceived over theWorkflowRequestCompletionConsumer channelcontaining information about the rejectedChangeSummaryGroupand one of itsChangeSummariesfor 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 aChangeSummaryGroupand itsChangeSummaries:- Updates the state of the
ChangeSummaryindicated in the request asChangeState.USER - and its status as
ChangeStatusType.FINISHED - If this is the last summary in the group to finish, then the
ChangeSummaryGroupis archived.
- Parameters:
completion- TheWorkflowRequestCompletionindicating 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'sstatus asChangeStatusType.FINISHEDand its state asChangeState.USER.- Parameters:
completion- TheWorkflowRequestCompletioncontaining 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 theChangeSummariesin theChangeSummaryGrouphave finished being rejected.This check is done to prevent the
ChangeSummaryGroupfrom being archived until all its summaries have been processed.- Parameters:
group- TheChangeSummaryGroupto 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 theChangeSummaryGroupand updates its status toChangeStatusType.REJECTEDand marks it as archived.- Parameters:
group- theChangeSummaryGroupto 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)
-