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 Summary
FieldsFields inherited from class com.broadleafcommerce.subscriptionoperation.service.provider.external.AbstractExternalProvider
ENTITY_NOT_FOUND, RSQL_FILTER_PARAM, SANDBOX_AWARE_HEADER -
Constructor Summary
ConstructorsConstructorDescriptionExternalSubscriptionProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalSubscriptionProperties properties) -
Method Summary
Modifier and TypeMethodDescriptionaddPriceDataChanges(@NonNull PriceDataChangeRequest priceDataChangeRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Add a price data change to a batch of subscriptionsClear a lock for a subscriptioncreate(SWI subscriptionWithItems, boolean createSandboxRecord, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Persists a subscription alongside its itemscreateOrReturnIfExists(SWI subscriptionWithItems, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Persists a subscription alongside its items.createToken(String subscriptionId, String tokenIdentifier) Create a reservation token for a child lockprotected org.springframework.web.util.UriComponentsBuilderprotected org.springframework.core.ParameterizedTypeReference<S>protected org.springframework.web.util.UriComponentsBuilderGets the base URI to read subscriptions.protected org.springframework.core.ParameterizedTypeReference<ResponsePageGenerator<SWI>>Gets the type reference for a page generator of item list items.protected ExternalSubscriptionPropertiesprotected Stringprotected org.springframework.core.ParameterizedTypeReference<ResponsePageGenerator<SO>>Gets the type reference for a page generator of SubscriptionOwnerInfo.protected org.springframework.web.util.UriComponentsBuilderGets the base URI to read subscription price data.protected org.springframework.web.util.UriComponentsBuilderGets the base URI to read subscription with items.protected org.springframework.core.ParameterizedTypeReference<SWI>getType()lockSubscription(String subscriptionId, List<String> reservations) Create a top-level lock for a subscriptionorg.springframework.data.domain.Page<SO>readAllSubscriptionOwnerInfosByPriceData(@NonNull String priceDataId, Set<String> statuses, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find allSubscriptionOwnerInfoby priceDataId.readAllSubscriptionsByIds(@NonNull Collection<String> subscriptionIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a list of subscriptions with items for the given idsorg.springframework.data.domain.Page<SWI>readAllSubscriptionsByUserRefAndStatuses(@NonNull String userRefType, @NonNull String userRef, @NonNull Collection<String> statuses, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find allsubscriptionsby userRef and statuses.readSubscription(@NonNull String subscriptionId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a subscription for a given id.readSubscriptionById(@NonNull String subscriptionId, boolean isSandboxAware, boolean ignoreDeleteFiltering, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a subscription with items for a given idorg.springframework.data.domain.Page<SWI>readSubscriptionsForUserRefTypeAndUserRef(@NonNull String userRefType, @NonNull String userRef, org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a page of subscriptions with items for a given user type and user id, taking into account the provided filters and pagingreadUserSubscriptionById(@NonNull String userRefType, @NonNull String userRef, @NonNull String subscriptionId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a user-owned subscription with items for a given idreplaceSubscription(S subscription, boolean isSandboxAware, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Replaces a subscription.replaceSubscriptionWithItems(SWI subscriptionWithItems, boolean isSandboxAware, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Replaces a subscription and its items.unlockToken(String subscriptionId, String token, boolean propagate) Unlock a child lock identified by a tokenMethods inherited from class com.broadleafcommerce.subscriptionoperation.service.provider.external.AbstractExternalProvider
addOffsetOrPageNumber, buildNotFoundException, executeRequest, getHeaders, getObjectMapper, getTypeFactory, getWebClient, isEntityNotFound, pageableToParams, uriVarsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.subscriptionoperation.service.provider.SubscriptionProvider
create, readSubscriptionById, readSubscriptionById, replaceSubscription, replaceSubscriptionWithItems
-
Field Details
-
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:SubscriptionProviderPersists a subscription alongside its items- Specified by:
createin interfaceSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription, SO extends SubscriptionOwnerInfo> - Parameters:
subscriptionWithItems- subscription with items to persistcreateSandboxRecord- Whether to create a sandbox recordcontextInfo- 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:SubscriptionProviderPersists a subscription alongside its items. If the subscription already exists, returns it.- Specified by:
createOrReturnIfExistsin interfaceSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription, SO extends SubscriptionOwnerInfo> - Parameters:
subscriptionWithItems- subscription with items to persistcontextInfo- 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:SubscriptionProviderRetrieves a page of subscriptions with items for a given user type and user id, taking into account the provided filters and paging- Specified by:
readSubscriptionsForUserRefTypeAndUserRefin interfaceSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription, SO extends SubscriptionOwnerInfo> - Parameters:
userRefType- type of the owning useruserRef- id of the owning userpage- pageablefilters- Additional RSQL filterscontextInfo- 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:SubscriptionProviderFind allSubscriptionOwnerInfoby priceDataId.- Specified by:
readAllSubscriptionOwnerInfosByPriceDatain interfaceSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription, SO extends SubscriptionOwnerInfo> - Parameters:
priceDataId- The id of the priceData belonging to one or more of the containedSubscriptionIteminstances in associatedSubscriptioninstances.statuses- Set of statuses to filter by.page- The page informationcontextInfo- 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:SubscriptionProviderAdd a price data change to a batch of subscriptions- Specified by:
addPriceDataChangesin interfaceSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription, SO extends SubscriptionOwnerInfo> - Parameters:
priceDataChangeRequest- The request to add price data changescontextInfo- 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:SubscriptionProviderRetrieves a list of subscriptions with items for the given ids- Specified by:
readAllSubscriptionsByIdsin interfaceSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription, SO extends SubscriptionOwnerInfo> - Parameters:
subscriptionIds- The ids of the subscriptionscontextInfo- 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:SubscriptionProviderRetrieves a subscription for a given id.- Specified by:
readSubscriptionin interfaceSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription, SO extends SubscriptionOwnerInfo> - Parameters:
subscriptionId- The id of the subscriptioncontextInfo- 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:SubscriptionProviderRetrieves a subscription with items for a given id- Specified by:
readSubscriptionByIdin interfaceSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription, SO extends SubscriptionOwnerInfo> - Parameters:
subscriptionId- The id of the subscriptionisSandboxAware- Whether to look for sandbox recordsignoreDeleteFiltering- Whether to ignore sandbox delete filteringcontextInfo- 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:SubscriptionProviderRetrieves a user-owned subscription with items for a given id- Specified by:
readUserSubscriptionByIdin interfaceSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription, SO extends SubscriptionOwnerInfo> - Parameters:
userRefType- type of the owning useruserRef- id of the owning usersubscriptionId- The id of the subscriptioncontextInfo- 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:SubscriptionProviderReplaces a subscription.- Specified by:
replaceSubscriptionin interfaceSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription, SO extends SubscriptionOwnerInfo> - Parameters:
subscription- theSubscriptionused for the put operationisSandboxAware- Whether the request should target a sandbox recordcontextInfo- 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:SubscriptionProviderReplaces a subscription and its items.- Specified by:
replaceSubscriptionWithItemsin interfaceSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription, SO extends SubscriptionOwnerInfo> isSandboxAware- Whether the request should target a sandbox recordcontextInfo- 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:SubscriptionProviderFind allsubscriptionsby userRef and statuses.- Specified by:
readAllSubscriptionsByUserRefAndStatusesin interfaceSubscriptionProvider<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 userstatuses- the list ofSubscriptionStatusespageable- The page informationcontextInfo- context information around multi-tenant state- Returns:
- a list of
SubscriptionWithItemsthat match the userRef and statuses.
-
lockSubscription
Description copied from interface:SubscriptionProviderCreate a top-level lock for a subscription- Specified by:
lockSubscriptionin interfaceSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription, SO extends SubscriptionOwnerInfo> - Parameters:
subscriptionId- The subscription ID to lockreservations- The child lock identifiers to reserve- Returns:
- The status of the lock operation
-
clearLock
Description copied from interface:SubscriptionProviderClear a lock for a subscription- Specified by:
clearLockin interfaceSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription, SO extends SubscriptionOwnerInfo> - Parameters:
subscriptionId- The subscription ID to clear the lock forisRevert- Whether the unlock operation is the result of a revert operation. Optional. Default is true.- Returns:
- The status of the lock operation
-
unlockToken
Description copied from interface:SubscriptionProviderUnlock a child lock identified by a token- Specified by:
unlockTokenin interfaceSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription, SO extends SubscriptionOwnerInfo> - Parameters:
subscriptionId- The subscription ID to unlock a child lock fortoken- The token identifying the child lockpropagate- Whether to propagate the unlock operation to the parent lock- Returns:
- The status of the unlock operation
-
createToken
Description copied from interface:SubscriptionProviderCreate a reservation token for a child lock- Specified by:
createTokenin interfaceSubscriptionProvider<SWI extends SubscriptionWithItems,S extends Subscription, SO extends SubscriptionOwnerInfo> - Parameters:
subscriptionId- The subscription ID to create a token fortokenIdentifier- 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
-
getBaseType
-
getListType
-
getServiceClient
-
getProperties
-