Class DefaultExportManager

    • Constructor Detail

      • DefaultExportManager

        public DefaultExportManager​(ExportService<Export> exportService,
                                    ExportRequestValidator exportRequestValidator,
                                    List<ExportProcessor<?>> exportProcessors,
                                    List<ExportFileWriter<?>> exportFileWriters,
                                    StorageService storageService,
                                    com.broadleafcommerce.common.extension.TypeFactory typeFactory,
                                    ExportProcessingConfigurationProperties exportProcessingConfigurationProperties,
                                    @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)
    • Method Detail

      • initiateExport

        public Export initiateExport​(ExportRequest request,
                                     String target,
                                     @Nullable
                                     String filterString,
                                     @Nullable
                                     com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: ExportManager
        This method accepts an export request and the context of the request to build a Export and persist it in the data store.

        Sends a ProcessExportRequest message to request that the export be processed.

        Specified by:
        initiateExport in interface ExportManager
        Parameters:
        request - a request to perform an Export.

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

        target - the target of the export. This is some value that can be mapped to a particular domain by the logic performing an export, rather than explicitly requiring the fully qualified classname. Used to populate Export.target.
        filterString - the filter string that should be used to find the records to export. Used to populate Export.filterString.
        contextInfo - context information surrounding sandboxing and multitenant state
        Returns:
        the newly created Export
      • validateCanBeExported

        protected void validateCanBeExported​(Export export)
      • validateExportingContextAccessibility

        protected void validateExportingContextAccessibility​(Export export)
        Builds a ContextInfo matching the exporting context fields from export, 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:
        export - the export whose exporting context fields should be checked for accessibility
        Throws:
        com.broadleafcommerce.data.tracking.core.exception.NotVisibleException - if the exporting context is not visible by the current user
      • validateExportRequest

        protected void validateExportRequest​(ExportRequest request)
        Validates the ExportRequest, throwing a ValidationException in the event that there is a validation failure.
        Parameters:
        request - the user-supplied export request
        Throws:
        com.broadleafcommerce.common.error.validation.ValidationException - in the event that there is a validation failure
      • generateName

        protected String generateName​(String target)
      • initializeGeneralFields

        protected void initializeGeneralFields​(Export toInitialize)
      • initializeContextFields

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

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

        Parameters:
        target - the Export whose context-related fields should be initialized
        request - the ExportRequest 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​(Export export)
      • copyToStorageServiceAndFinishExport

        protected void copyToStorageServiceAndFinishExport​(Path toCopy,
                                                           Export toUpdate,
                                                           ExportFileWriter<?> fileWriter)
      • generateStoragePath

        protected String generateStoragePath​(Export export,
                                             String fileExtension)
      • setFileLocationAndFinishedStatus

        protected void setFileLocationAndFinishedStatus​(String exportId,
                                                        String fileLocation)
      • getStorageService

        @NonNull
        protected StorageService getStorageService()
      • 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 the context in which the operation will apply.

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

      • getSECURE_RANDOM

        @NonNull
        protected static Random getSECURE_RANDOM()
      • getUTC_TIMESTAMP_FORMATTER

        @NonNull
        protected static DateTimeFormatter getUTC_TIMESTAMP_FORMATTER()