Interface CustomizedAssetRepository<D extends com.broadleafcommerce.data.tracking.core.Trackable>

All Known Subinterfaces:
AssetRepository<D>, JpaAssetRepository<D>
All Known Implementing Classes:
JpaCustomizedAssetRepository

public interface CustomizedAssetRepository<D extends com.broadleafcommerce.data.tracking.core.Trackable>
Advanced functionality related to asset maintenance and filtering.
Author:
Nathan Moore (nathanmoore).
  • Method Summary

    Modifier and Type
    Method
    Description
    findByUrlAndStorageType(String url, String storageType, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Finds the asset whose url and storage type match the provided values.
    org.springframework.data.domain.Page<D>
    searchAll(String searchString, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageInfo, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    If searchString is provided, then this method will search for assets whose Asset.url, Asset.title, Asset.altText, or Asset.tags contain it.
  • Method Details

    • searchAll

      @Policy(operationTypes=READ) org.springframework.data.domain.Page<D> searchAll(@Nullable String searchString, @NonNull cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable pageInfo, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      If searchString is provided, then this method will search for assets whose Asset.url, Asset.title, Asset.altText, or Asset.tags contain it.

      If no searchString is provided, then this method will simply return all assets.

      This method also supports RSQL filtration via filters.

      Parameters:
      searchString - (optional) a string which should be found in Asset.url, Asset.title, Asset.altText, or Asset.tags
      filters - additional filters to apply in the query. Should be EmptyNode if no additional filters should be applied.
      pageInfo - information about which page of results to return from the database
      contextInfo - context information surrounding sandboxing/multitenant state
      Returns:
      the assets matching the given search/filter arguments if provided, otherwise all assets
    • findByUrlAndStorageType

      @Policy(operationTypes=READ) @NonNull Optional<D> findByUrlAndStorageType(@NonNull String url, @Nullable String storageType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds the asset whose url and storage type match the provided values.

      This is a custom repository method because there is a scenario where an asset in the tenant and an asset in a standard application can have the same URL. This scenario arises in the event that a standard-application asset is uploaded, and then on the tenant an asset with the same URL is uploaded. Due to the mechanism by which application discrimination works, the tenant asset upload will succeed because the standard-application asset will not be visible in the tenant context, and therefore will not be recognized as a duplicate.

      This ultimately means that "findByUrlAndStorageType" can potentially return more than one result, which is undesirable. The target behavior should be that if an asset with the given URL is found in both the tenant and standard-application contexts, the standard-application asset should be returned.

      Parameters:
      url - the url which should match with Asset.url
      storageType - (optional) the storage type which should match with Asset.storageType. If left null, results will not be filtered by storage type.
      contextInfo - context information around sandboxing and multitenant state
      Returns:
      an optional containing the asset whose url and storage type (optional) match the provided values, empty otherwise