Class DefaultBulkUpdateManager

    • Constructor Detail

      • DefaultBulkUpdateManager

        public DefaultBulkUpdateManager​(BulkUpdateService<BulkUpdate> bulkUpdateService,
                                        BulkUpdateRequestValidator bulkUpdateRequestValidator,
                                        List<BulkUpdateProcessor<?>> bulkUpdateProcessors,
                                        com.broadleafcommerce.common.extension.TypeFactory typeFactory,
                                        @Nullable
                                        com.broadleafcommerce.common.extension.data.DataRouteReference reference,
                                        List<com.broadleafcommerce.data.tracking.core.web.ContextRequestHydrator> contextRequestHydrators,
                                        @Nullable
                                        com.broadleafcommerce.data.tracking.core.policy.trackable.TrackablePolicyUtils trackablePolicyUtils,
                                        int batchSize)
    • Method Detail

      • initiateBulkUpdate

        public BulkUpdate initiateBulkUpdate​(BulkUpdateRequest request,
                                             String target,
                                             @Nullable
                                             String filterString,
                                             @Nullable
                                             com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: BulkUpdateManager
        This method accepts a bulk update request and the context of the request to build a BulkUpdate and persist it in the data store.

        Will send a ProcessBulkUpdateRequest message to request that the update be processed.

        Specified by:
        initiateBulkUpdate in interface BulkUpdateManager
        Parameters:
        request - a request to perform a BulkUpdate.

        For each of the "updating context" fields describing where the operation will be performed, the default implementation will first check if the field is supplied in BulkUpdateRequest, and if not, use the value from the ContextInfo.

        target - the target of the bulk update. This is some value that can be mapped to a particular domain by the logic performing an update, rather than explicitly requiring the fully qualified classname. Used to populate BulkUpdate.getTarget().
        filterString - the filter string that should be used to find the records to update. Used to populate BulkUpdate.getFilterString().
        contextInfo - context information surrounding sandboxing and multitenant state. This is the context from which the operation itself is being initiated.
        Returns:
        The created BulkUpdate.
      • validateBulkUpdateRequest

        protected void validateBulkUpdateRequest​(BulkUpdateRequest request)
        Validates the BulkUpdateRequest, throwing a ValidationException in the event that there is a validation failure.
        Parameters:
        request - the user-supplied bulk update request
        Throws:
        com.broadleafcommerce.common.error.validation.ValidationException - in the event that there is a validation failure
      • initializeGeneralFields

        protected void initializeGeneralFields​(BulkUpdate toInitialize)
      • initializeContextFields

        protected void initializeContextFields​(BulkUpdate target,
                                               BulkUpdateRequest request,
                                               @Nullable
                                               com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Initializes the context-related fields on the given BulkUpdate, including the fields describing the context where the operation itself was initiated (such as BulkUpdate.getApplicationId()), and "updating context" fields describing the context where the operation will be performed (such as BulkUpdate.getUpdatingApplicationId()).

        For each of the "updating context" fields describing where the operation will be performed, the default implementation will first check if the field is supplied in BulkUpdateRequest, and if not, use the value from the ContextInfo.

        Parameters:
        target - the BulkUpdate whose context-related fields should be initialized
        request - the BulkUpdateRequest which should be checked as a potential source for context fields
        contextInfo - context information surrounding sandboxing and multitenant state. This is the context from which the operation itself is being initiated.
      • setTotalRecordsToProcess

        protected void setTotalRecordsToProcess​(BulkUpdate update)
      • validateCanPerformBulkUpdate

        protected void validateCanPerformBulkUpdate​(BulkUpdate update)
      • validateUpdatingContextAccessibility

        protected void validateUpdatingContextAccessibility​(BulkUpdate update)
        Builds a ContextInfo matching the updating context fields from update, and then evaluates whether the currently authenticated user is allowed to perform the operation in that context.

        In the event that policy validation is disabled, the TrackablePolicyUtils bean will be unavailable and thus this step will be skipped.

        Parameters:
        update - the bulk update whose updating context fields should be checked for accessibility
        Throws:
        com.broadleafcommerce.data.tracking.core.exception.NotVisibleException - if the updating context is not visible by the current user
        com.broadleafcommerce.data.tracking.core.exception.NotMutableException - if the updating context is not mutable by the current user
      • isSandboxBulkUpdate

        protected boolean isSandboxBulkUpdate​(@NonNull
                                              BulkUpdate bulkUpdate)
      • notifyOfCreateSandboxRequest

        protected BulkUpdate notifyOfCreateSandboxRequest​(String bulkUpdateId)
        Parameters:
        bulkUpdateId -
        Returns:
      • getTypeFactory

        @NonNull
        protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
      • getReference

        @Nullable
        protected com.broadleafcommerce.common.extension.data.DataRouteReference getReference()
      • getContextRequestHydrators

        protected List<com.broadleafcommerce.data.tracking.core.web.ContextRequestHydrator> getContextRequestHydrators()
      • getTrackablePolicyUtils

        @Nullable
        protected com.broadleafcommerce.data.tracking.core.policy.trackable.TrackablePolicyUtils getTrackablePolicyUtils()
        Used to validate that the user initiating an operation is able to access and mutate the context in which the operation will apply.

        If policy validation is disabled, this bean will be unavailable and policy validation will be skipped.

      • getBatchSize

        protected int getBatchSize()