Class DefaultFileUploadStateHydrationService

java.lang.Object
com.broadleafcommerce.asset.service.DefaultFileUploadStateHydrationService
All Implemented Interfaces:
FileUploadStateHydrationService

public class DefaultFileUploadStateHydrationService extends Object implements FileUploadStateHydrationService
Author:
Samarth Dhruva (samarthd)
  • Constructor Details

    • DefaultFileUploadStateHydrationService

      public DefaultFileUploadStateHydrationService(@NonNull AssetService<Asset> assetService)
  • Method Details

    • hydrate

      public FileUploadState hydrate(FileUploadState unhydrated, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: FileUploadStateHydrationService
      Gets the IDs of Assets that are referenced by unhydrated, finds the corresponding items in the data store, and then replaces each reference with the fully populated representation of the item.
      Specified by:
      hydrate in interface FileUploadStateHydrationService
      Parameters:
      unhydrated - the unhydrated FileUploadState whose references should be hydrated
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      the given unhydrated instance after hydrating its references
    • determineReferencedAssetIds

      protected List<String> determineReferencedAssetIds(FileUploadState state)
    • findAssetsAndCollectToMap

      protected Map<String,Asset> findAssetsAndCollectToMap(List<String> assetIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • applyHydration

      protected FileUploadState applyHydration(FileUploadState state, Map<String,Asset> foundAssetsById)
    • getHydratedOrLog

      protected Asset getHydratedOrLog(Asset unhydrated, Map<String,Asset> foundAssetsById)
      Returns the fully-populated instance of unhydrated if it was found, otherwise logs a warning and returns unhydrated as-is.
      Parameters:
      unhydrated - the Asset instance containing just an ID for which a fully-populated replacement instance should be found
      foundAssetsById - a map of assets found in the datastore by their ID. This map will be used to source the replacement instance for unhydrated.
      Returns:
      the fully-populated version of unhydrated if it was found in foundAssetsById, otherwise the given unhydrated instance as-is
    • getAssetService

      @NonNull protected AssetService<Asset> getAssetService()