Class VendorSandboxPropagationHandler
java.lang.Object
com.broadleafcommerce.data.tracking.core.transition.VendorSandboxPropagationHandler
- All Implemented Interfaces:
PropagationAware
,PropagationHandler
,org.springframework.core.Ordered
Specialized instance of
PropagationHandler
capable of propagating vendor catalog
(catalogs related to a vendor instance via the vendorRef property) changes into a promotion
sandbox state in an associated application. The intent is for the application administrator(s) to
review incoming changes before accepting and exposing those changes to the application storefront
customers. This is a common use case for marketplace style applications whose product catalog is
curated by a number of independent vendors.- Author:
- Jeff Fischer
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionVendorSandboxPropagationHandler
(CommonCatalogService<? extends Catalog> catalogService, CommonApplicationService<? extends Application> applicationService, DomainMapperManager mapperManager, CrudEntityHelper helper, SandboxPropagationProperties propagationProperties, org.modelmapper.ModelMapper cloneMapper, List<ChangeTransformer> changeTransformers, TrackableDomainMapperMemberSupport domainMapperMemberSupport, WorkflowMapper workflowMapper, CommonMarketplaceApplicationCatalogRepository<Trackable> applicationCatalogRepository) -
Method Summary
Modifier and TypeMethodDescriptionboolean
canHandle
(Trackable incoming, String incomingCatalog, String parentCatalog, Trackable candidate, OperationType changeType) Is this handler capable of handling the propagation process given the contextual information.int
getOrder()
protected String
getUniversalMarketplaceVendorSandboxId
(Catalog parentVendorCatalog, Catalog childMarketplaceCatalog) For each marketplace application that a vendor contributes to, we should target a single, consistent "universal" sandbox for that vendor in which to propagate changes.protected String
getUniversalMarketplaceVendorSandboxName
(Catalog parentVendorCatalog, Catalog childMarketplaceCatalog) Create a name befitting the "universal" marketplace vendor sandbox described ingetUniversalMarketplaceVendorSandboxId(Catalog, Catalog)
.handleCreate
(Trackable incoming, String incomingCatalog, String parentCatalog, String propagationId, TrackableRepository<Trackable> repository) handleDelete
(Trackable incoming, String incomingCatalog, String parentCatalog, String propagationId, Trackable candidate, TrackableRepository<Trackable> repository) handleUpdate
(Trackable incoming, String incomingCatalog, String parentCatalog, String propagationId, Trackable candidate, TrackableRepository<Trackable> repository) void
setAuditUtility
(BasicAuditUtility auditUtility)
-
Field Details
-
PROMOTION_TRACKING_LEVEL
public static final int PROMOTION_TRACKING_LEVEL- See Also:
-
SORT_ORDER
public static final int SORT_ORDER- See Also:
-
-
Constructor Details
-
VendorSandboxPropagationHandler
public VendorSandboxPropagationHandler(CommonCatalogService<? extends Catalog> catalogService, CommonApplicationService<? extends Application> applicationService, DomainMapperManager mapperManager, CrudEntityHelper helper, SandboxPropagationProperties propagationProperties, org.modelmapper.ModelMapper cloneMapper, List<ChangeTransformer> changeTransformers, TrackableDomainMapperMemberSupport domainMapperMemberSupport, WorkflowMapper workflowMapper, CommonMarketplaceApplicationCatalogRepository<Trackable> applicationCatalogRepository)
-
-
Method Details
-
canHandle
public boolean canHandle(Trackable incoming, String incomingCatalog, String parentCatalog, @Nullable Trackable candidate, OperationType changeType) Description copied from interface:PropagationHandler
Is this handler capable of handling the propagation process given the contextual information.- Specified by:
canHandle
in interfacePropagationHandler
- Parameters:
incoming
- The Trackable instance that contains the change information to propagateincomingCatalog
- The current catalog in which the propagation is occuringparentCatalog
- The parent catalog up one levelcandidate
- The candidate, if available, representing a catalog override already existing in the incomingCatalog.changeType
- The type of change requested. SeeOperationType
.- Returns:
- Is this handler capable of handling the propagation process
-
handleDelete
public Trackable handleDelete(Trackable incoming, String incomingCatalog, String parentCatalog, String propagationId, @Nullable Trackable candidate, TrackableRepository<Trackable> repository) - Specified by:
handleDelete
in interfacePropagationAware
-
handleCreate
public Trackable handleCreate(Trackable incoming, String incomingCatalog, String parentCatalog, String propagationId, TrackableRepository<Trackable> repository) - Specified by:
handleCreate
in interfacePropagationAware
-
handleUpdate
public Trackable handleUpdate(Trackable incoming, String incomingCatalog, String parentCatalog, String propagationId, @Nullable Trackable candidate, TrackableRepository<Trackable> repository) - Specified by:
handleUpdate
in interfacePropagationAware
-
getOrder
public int getOrder()- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
- Specified by:
getOrder
in interfacePropagationHandler
-
getUniversalMarketplaceVendorSandboxId
protected String getUniversalMarketplaceVendorSandboxId(Catalog parentVendorCatalog, Catalog childMarketplaceCatalog) For each marketplace application that a vendor contributes to, we should target a single, consistent "universal" sandbox for that vendor in which to propagate changes. This means that all changes from a particular vendor that are targeting the same marketplace application will always be in the same sandbox. By doing this, we minimize the amount of sandboxes that are created and consolidate changes as much as possible.The sandbox service will only create a provided sandbox if it does not already exist by a given ID, so we can rely on it to only ever create the sandbox once if given the same ID.
This means we must produce a predictable, consistent ID for the provided inputs, and thus we cannot simply use a randomly generated value. The default implementation will first build a string with the format "{vendorRef}-{marketplaceApplicationId}", then return the hex string representing its MD5 hash.
- Parameters:
parentVendorCatalog
- the parent vendor catalog in which the deployment occurred and whose changes are being propagatedchildMarketplaceCatalog
- a child catalog of the parent vendor catalog which is in a marketplace application. This is the catalog to which changes are being propagated.- Returns:
- a sandbox ID that will be the same for all of the vendor's changes in the marketplace application
- See Also:
-
getUniversalMarketplaceVendorSandboxName
protected String getUniversalMarketplaceVendorSandboxName(Catalog parentVendorCatalog, Catalog childMarketplaceCatalog) Create a name befitting the "universal" marketplace vendor sandbox described ingetUniversalMarketplaceVendorSandboxId(Catalog, Catalog)
.The default implementation will return a string of the format "{vendorRef}-{marketplaceApplicationName}", truncated to a reasonable length if necessary.
- Parameters:
parentVendorCatalog
- the parent vendor catalog in which the deployment occurred and whose changes are being propagatedchildMarketplaceCatalog
- a child catalog of the parent vendor catalog which is in a marketplace application. This is the catalog to which changes are being propagated.- Returns:
- the name to use for the sandbox that will contain all of a vendor's changes in the marketplace application
- See Also:
-
setAuditUtility
-