Class ExternalSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>

java.lang.Object
com.broadleafcommerce.subscriptionoperation.service.provider.external.AbstractExternalProvider
com.broadleafcommerce.subscriptionoperation.service.provider.external.ExternalSubscriptionProvider<SWI,S,SO>
All Implemented Interfaces:
SubscriptionProvider<SWI,S,SO>

public class ExternalSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo> extends AbstractExternalProvider implements SubscriptionProvider<SWI,S,SO>
  • Field Details

    • SANDBOX_IGNORE_DELETE_FILTERING_HEADER

      protected static final String SANDBOX_IGNORE_DELETE_FILTERING_HEADER
      See Also:
  • Constructor Details

    • ExternalSubscriptionProvider

      public ExternalSubscriptionProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalSubscriptionProperties properties)
  • Method Details

    • create

      public SWI create(@NonNull SWI subscriptionWithItems, boolean createSandboxRecord, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SubscriptionProvider
      Persists a subscription alongside its items
      Specified by:
      create in interface SubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>
      Parameters:
      subscriptionWithItems - subscription with items to persist
      createSandboxRecord - Whether to create a sandbox record
      contextInfo - context information around multi-tenant state
      Returns:
      the created subscription and items
    • createOrReturnIfExists

      public SWI createOrReturnIfExists(@NonNull SWI subscriptionWithItems, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SubscriptionProvider
      Persists a subscription alongside its items. If the subscription already exists, returns it.
      Specified by:
      createOrReturnIfExists in interface SubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>
      Parameters:
      subscriptionWithItems - subscription with items to persist
      contextInfo - context information around multi-tenant state
      Returns:
      the created subscription and items
    • readSubscriptionsForUserRefTypeAndUserRef

      public org.springframework.data.domain.Page<SWI> readSubscriptionsForUserRefTypeAndUserRef(@NonNull @NonNull String userRefType, @NonNull @NonNull String userRef, @Nullable org.springframework.data.domain.Pageable page, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SubscriptionProvider
      Retrieves a page of subscriptions with items for a given user type and user id, taking into account the provided filters and paging
      Specified by:
      readSubscriptionsForUserRefTypeAndUserRef in interface SubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>
      Parameters:
      userRefType - type of the owning user
      userRef - id of the owning user
      page - pageable
      filters - Additional RSQL filters
      contextInfo - context information around multi-tenant state
      Returns:
      a page of subscriptions with items for a given user type and user id
    • readAllSubscriptionOwnerInfosByPriceData

      public org.springframework.data.domain.Page<SO> readAllSubscriptionOwnerInfosByPriceData(@NonNull @NonNull String priceDataId, @Nullable Set<String> statuses, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SubscriptionProvider
      Find all SubscriptionOwnerInfo by priceDataId.
      Specified by:
      readAllSubscriptionOwnerInfosByPriceData in interface SubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>
      Parameters:
      priceDataId - The id of the priceData belonging to one or more of the contained SubscriptionItem instances in associated Subscription instances.
      statuses - Set of statuses to filter by.
      page - The page information
      contextInfo - Additional sandbox and multitenant info
    • addPriceDataChanges

      public List<String> addPriceDataChanges(@NonNull @NonNull PriceDataChangeRequest priceDataChangeRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SubscriptionProvider
      Add a price data change to a batch of subscriptions
      Specified by:
      addPriceDataChanges in interface SubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>
      Parameters:
      priceDataChangeRequest - The request to add price data changes
      contextInfo - Additional sandbox and multitenant info
      Returns:
      The list of subscription ids that were updated
    • readAllSubscriptionsByIds

      public List<SWI> readAllSubscriptionsByIds(@NonNull @NonNull Collection<String> subscriptionIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SubscriptionProvider
      Retrieves a list of subscriptions with items for the given ids
      Specified by:
      readAllSubscriptionsByIds in interface SubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>
      Parameters:
      subscriptionIds - The ids of the subscriptions
      contextInfo - context information around multi-tenant state
      Returns:
      A list of subscriptions with items for the given ids
    • readSubscription

      public Optional<S> readSubscription(@NonNull @NonNull String subscriptionId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SubscriptionProvider
      Retrieves a subscription for a given id.
      Specified by:
      readSubscription in interface SubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>
      Parameters:
      subscriptionId - The id of the subscription
      contextInfo - context information around multi-tenant state
      Returns:
      a subscription for the given id
    • readSubscriptionById

      public Optional<SWI> readSubscriptionById(@NonNull @NonNull String subscriptionId, boolean isSandboxAware, boolean ignoreDeleteFiltering, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SubscriptionProvider
      Retrieves a subscription with items for a given id
      Specified by:
      readSubscriptionById in interface SubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>
      Parameters:
      subscriptionId - The id of the subscription
      isSandboxAware - Whether to look for sandbox records
      ignoreDeleteFiltering - Whether to ignore sandbox delete filtering
      contextInfo - context information around multi-tenant state
      Returns:
      a subscription with items for the given id
    • readUserSubscriptionById

      public SWI readUserSubscriptionById(@NonNull @NonNull String userRefType, @NonNull @NonNull String userRef, @NonNull @NonNull String subscriptionId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SubscriptionProvider
      Retrieves a user-owned subscription with items for a given id
      Specified by:
      readUserSubscriptionById in interface SubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>
      Parameters:
      userRefType - type of the owning user
      userRef - id of the owning user
      subscriptionId - The id of the subscription
      contextInfo - context information around multi-tenant state
      Returns:
      a user-owned subscription with items for a given id
    • replaceSubscription

      public S replaceSubscription(@NonNull S subscription, boolean isSandboxAware, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SubscriptionProvider
      Replaces a subscription.
      Specified by:
      replaceSubscription in interface SubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>
      Parameters:
      subscription - the Subscription used for the put operation
      isSandboxAware - Whether the request should target a sandbox record
      contextInfo - context information around multi-tenant state
      Returns:
      the updated subscription
    • replaceSubscriptionWithItems

      public SWI replaceSubscriptionWithItems(@NonNull SWI subscriptionWithItems, boolean isSandboxAware, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SubscriptionProvider
      Replaces a subscription and its items.
      Specified by:
      replaceSubscriptionWithItems in interface SubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>
      isSandboxAware - Whether the request should target a sandbox record
      contextInfo - context information around multi-tenant state
      Returns:
      the updated subscription
    • readAllSubscriptionsByUserRefAndStatuses

      public org.springframework.data.domain.Page<SWI> readAllSubscriptionsByUserRefAndStatuses(@NonNull @NonNull String userRefType, @NonNull @NonNull String userRef, @NonNull @NonNull Collection<String> statuses, @Nullable org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SubscriptionProvider
      Find all subscriptions by userRef and statuses.
      Specified by:
      readAllSubscriptionsByUserRefAndStatuses in interface SubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>
      Parameters:
      userRefType - the type of userRef provided. Could be "BLC_ACCOUNT" or "BLC_CUSTOMER"
      userRef - the reference to the user
      statuses - the list of SubscriptionStatuses
      pageable - The page information
      contextInfo - context information around multi-tenant state
      Returns:
      a list of SubscriptionWithItems that match the userRef and statuses.
    • lockSubscription

      public LockStatus lockSubscription(String subscriptionId, @Nullable List<String> reservations)
      Description copied from interface: SubscriptionProvider
      Create a top-level lock for a subscription
      Specified by:
      lockSubscription in interface SubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>
      Parameters:
      subscriptionId - The subscription ID to lock
      reservations - The child lock identifiers to reserve
      Returns:
      The status of the lock operation
    • clearLock

      public LockStatus clearLock(String subscriptionId, boolean isRevert)
      Description copied from interface: SubscriptionProvider
      Clear a lock for a subscription
      Specified by:
      clearLock in interface SubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>
      Parameters:
      subscriptionId - The subscription ID to clear the lock for
      isRevert - Whether the unlock operation is the result of a revert operation. Optional. Default is true.
      Returns:
      The status of the lock operation
    • unlockToken

      public LockStatus unlockToken(String subscriptionId, String token, boolean propagate)
      Description copied from interface: SubscriptionProvider
      Unlock a child lock identified by a token
      Specified by:
      unlockToken in interface SubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>
      Parameters:
      subscriptionId - The subscription ID to unlock a child lock for
      token - The token identifying the child lock
      propagate - Whether to propagate the unlock operation to the parent lock
      Returns:
      The status of the unlock operation
    • createToken

      public LockStatus createToken(String subscriptionId, String tokenIdentifier)
      Description copied from interface: SubscriptionProvider
      Create a reservation token for a child lock
      Specified by:
      createToken in interface SubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription,SO extends SubscriptionOwnerInfo>
      Parameters:
      subscriptionId - The subscription ID to create a token for
      tokenIdentifier - The identifier for the token
      Returns:
      The status of the token creation operation
    • getPageType

      protected org.springframework.core.ParameterizedTypeReference<ResponsePageGenerator<SWI>> getPageType()
      Gets the type reference for a page generator of item list items.
      Returns:
      type reference for a page generator of item list items
    • getSubscriptionOwnerInfoPageType

      protected org.springframework.core.ParameterizedTypeReference<ResponsePageGenerator<SO>> getSubscriptionOwnerInfoPageType()
      Gets the type reference for a page generator of SubscriptionOwnerInfo.
      Returns:
      type reference for a page generator of SubscriptionOwnerInfo
    • getBaseUri

      protected org.springframework.web.util.UriComponentsBuilder getBaseUri()
      Gets the base URI to read subscriptions.
      Returns:
      a URI to read subscriptions
    • getSubscriptionWithItemsBaseUri

      protected org.springframework.web.util.UriComponentsBuilder getSubscriptionWithItemsBaseUri()
      Gets the base URI to read subscription with items.
      Returns:
      a URI to read subscription with items
    • getSubscriptionPriceDataBaseUri

      protected org.springframework.web.util.UriComponentsBuilder getSubscriptionPriceDataBaseUri()
      Gets the base URI to read subscription price data.
      Returns:
      a URI to read subscription price data
    • getBaseLockUri

      protected org.springframework.web.util.UriComponentsBuilder getBaseLockUri()
    • getType

      protected org.springframework.core.ParameterizedTypeReference<SWI> getType()
    • getBaseType

      protected org.springframework.core.ParameterizedTypeReference<S> getBaseType()
    • getListType

      protected org.springframework.core.ParameterizedTypeReference<List<SWI>> getListType()
    • getServiceClient

      protected String getServiceClient()
    • getProperties

      protected ExternalSubscriptionProperties getProperties()