Class DefaultCloneContentItemService<P extends ContentItem,R extends CloneContentItemRequest>

java.lang.Object
com.broadleafcommerce.content.clone.contentitem.service.DefaultCloneContentItemService<P,R>
All Implemented Interfaces:
CloneContentItemService<P,R>

public class DefaultCloneContentItemService<P extends ContentItem,R extends CloneContentItemRequest> extends Object implements CloneContentItemService<P,R>
Default implementation for CloneContentItemService.
Author:
Susana Cruz (susanaccruz)
  • Constructor Details

    • DefaultCloneContentItemService

      public DefaultCloneContentItemService(ContentItemService<P> ContentItemService, FieldDataService<FieldData> fieldDataService, ContentItemHydrationService hydrationService, ContentFolderItemService<ContentFolderItem> folderItemService, ContentItemRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager, com.broadleafcommerce.data.tracking.core.mapping.DomainMapperManager domainMapper, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidatorManager validator, org.springframework.transaction.support.TransactionTemplate template, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.data.tracking.core.tenant.service.CommonCatalogService<com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> catalogService)
  • Method Details

    • cloneContentItem

      public P cloneContentItem(R request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: CloneContentItemService

      Clone the product with an id CloneContentItemRequest.getContentItemId(). This will also clone the ContentItem relationships which are specified in CloneContentItemRequest.getCloneRelationships().

      Specified by:
      cloneContentItem in interface CloneContentItemService<P extends ContentItem,R extends CloneContentItemRequest>
      Parameters:
      request - the request to perform the clone operation
      context - context information surrounding sandboxing and multitenant state
      Returns:
      the cloned ContentItem
    • bulkCloneContentItems

      public List<P> bulkCloneContentItems(List<R> requests, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      bulkCloneContentItems in interface CloneContentItemService<P extends ContentItem,R extends CloneContentItemRequest>
    • performClone

      @Deprecated protected P performClone(R request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context, com.broadleafcommerce.data.tracking.core.Trackable original)
      Deprecated.
    • performClone

      protected P performClone(R request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context, com.broadleafcommerce.data.tracking.core.Trackable original, boolean hasReusableParent)
      Creates a clone ContentItem based on a CloneContentItemRequest.
      Parameters:
      request - the request to perform the clone operation.
      context - context information surrounding sandboxing and multitenant state.
      original - the original content item to clone.
      hasReusableParent - indicates whether the item to be cloned has a standalone parent item or if its parent is embedded. This is only relevant if the item to be cloned is embedded, otherwise it is ignored.
      Returns:
      the cloned content item.
    • prepareCloneContext

      protected com.broadleafcommerce.data.tracking.core.context.ContextInfo prepareCloneContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo context, com.broadleafcommerce.data.tracking.core.Trackable clone)
    • hydrateCatalogInfoInAppContext

      protected void hydrateCatalogInfoInAppContext(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.Trackable original)
      When performing a clone operation, typically for bulk cloning in an application context, it is not necessarily possible for the caller to identify which assigned catalog (a.k.a., profile) since multiple items may be getting cloned and multiple catalogs can be assigned to the application. Therefore, the items could be from different catalogs. To handle this, the item being cloned will be consulted to glean its catalog. Then, this method will resolve the implicit catalog matching the original but which belongs to the current application. This will be set on the ContextRequest.
      Parameters:
      context - The request's ContextInfo that needs to be hydrated.
      original - The item to be cloned.
      Throws:
      com.broadleafcommerce.data.tracking.core.exception.NotPermittedException - when the original item's catalog has no implicit catalog belonging to the current application.
    • generateClone

      protected com.broadleafcommerce.data.tracking.core.Trackable generateClone(R request, com.broadleafcommerce.data.tracking.core.Trackable original, Class<P> businessType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • validateForCreate

      protected void validateForCreate(P clone, R request, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • cloneFieldData

      protected void cloneFieldData(P original, P cloned, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • cloneNestedContentItem

      @Deprecated protected P cloneNestedContentItem(com.broadleafcommerce.data.tracking.core.context.ContextInfo context, P nestedItem)
      Deprecated.
    • cloneNestedContentItem

      protected P cloneNestedContentItem(com.broadleafcommerce.data.tracking.core.context.ContextInfo context, P nestedItem, boolean hasReusableParent)
    • getNestedContentItemIds

      protected LinkedHashSet<String> getNestedContentItemIds(FieldData fieldData)
    • updateFieldDataValue

      protected void updateFieldDataValue(FieldData fieldData, ContentField contentField, List<String> clonedNestedIds)
    • createNotificationState

      protected com.broadleafcommerce.common.messaging.notification.domain.NotificationState createNotificationState(P original, P cloned)
    • createFolderItem

      protected void createFolderItem(P clonedItem, R request, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • getSerializedEvent

      protected String getSerializedEvent(ContentItemCloneEvent cloneEvent)
    • notifyContentItemCloned

      protected void notifyContentItemCloned(com.broadleafcommerce.data.tracking.core.Trackable cloned)
    • getContentItemService

      protected ContentItemService<P> getContentItemService()
    • getFieldDataService

      protected FieldDataService<FieldData> getFieldDataService()
    • getHydrationService

      protected ContentItemHydrationService getHydrationService()
    • getFolderItemService

      protected ContentFolderItemService<ContentFolderItem> getFolderItemService()
    • getRepository

      protected ContentItemRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()
    • getNotificationManager

      protected com.broadleafcommerce.common.messaging.notification.NotificationManager getNotificationManager()
    • getDomainMapper

      protected com.broadleafcommerce.data.tracking.core.mapping.DomainMapperManager getDomainMapper()
    • getObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
    • getValidator

      protected com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidatorManager getValidator()
    • getTemplate

      protected org.springframework.transaction.support.TransactionTemplate getTemplate()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • getCatalogService

      protected com.broadleafcommerce.data.tracking.core.tenant.service.CommonCatalogService<com.broadleafcommerce.data.tracking.core.tenant.domain.Catalog> getCatalogService()