Class VendorSandboxPropagationHandler

  • All Implemented Interfaces:
    PropagationAware, PropagationHandler, org.springframework.core.Ordered

    public class VendorSandboxPropagationHandler
    extends Object
    implements PropagationHandler
    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
    • Method Detail

      • 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 interface PropagationHandler
        Parameters:
        incoming - The Trackable instance that contains the change information to propagate
        incomingCatalog - The current catalog in which the propagation is occuring
        parentCatalog - The parent catalog up one level
        candidate - The candidate, if available, representing a catalog override already existing in the incomingCatalog.
        changeType - The type of change requested. See OperationType.
        Returns:
        Is this handler capable of handling the propagation process
      • getOrder

        public int getOrder()
        Specified by:
        getOrder in interface org.springframework.core.Ordered
        Specified by:
        getOrder in interface PropagationHandler
      • 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 propagated
        childMarketplaceCatalog - 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(Catalog, Catalog)
      • getUniversalMarketplaceVendorSandboxName

        protected String getUniversalMarketplaceVendorSandboxName​(Catalog parentVendorCatalog,
                                                                  Catalog childMarketplaceCatalog)
        Create a name befitting the "universal" marketplace vendor sandbox described in getUniversalMarketplaceVendorSandboxId(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 propagated
        childMarketplaceCatalog - 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:
        getUniversalMarketplaceVendorSandboxId(Catalog, Catalog)
      • setAuditUtility

        @Autowired
        public void setAuditUtility​(@Nullable
                                    BasicAuditUtility auditUtility)