Class ResourcePurgeServiceImpl

java.lang.Object
org.broadleafcommerce.core.util.service.ResourcePurgeServiceImpl
All Implemented Interfaces:
ResourcePurgeService

@Service("blResourcePurgeService") public class ResourcePurgeServiceImpl extends Object implements ResourcePurgeService
Service capable of deleting old or defunct entities from the persistence layer (e.g. Carts and anonymous Customers). ResourcePurgeService for additional API documentation.

A basic Quartz scheduled job configuration for calling this service can be configured as follows:

<bean id="purgeCartConfig" class="org.springframework.beans.factory.config.MapFactoryBean"> <property name="sourceMap"> <map> <entry key="SECONDS_OLD" value="2592000"/> <entry key="STATUS" value="IN_PROCESS"/> </map> </property> </bean> <p/> <bean id="purgeCartJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="blResourcePurgeService" /> <property name="targetMethod" value="purgeCarts" /> <property name="arguments"> <list> <ref bean="purgeCartConfig"/> </list> </property> </bean> <p/> <bean id="purgeCartTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean"> <property name="jobDetail" ref="purgeCartJobDetail" /> <property name="startDelay" value="30000" /> <property name="repeatInterval" value="86400000" /> </bean>

Author:
Jeff Fischer
  • Field Details

  • Constructor Details

    • ResourcePurgeServiceImpl

      public ResourcePurgeServiceImpl()
  • Method Details

    • purgeCarts

      public void purgeCarts(Map<String,String> config)
      Description copied from interface: ResourcePurgeService
      Execute a purge of carts from the persistence layer based on the configuration parameters. The default implementation is capable of looking at any combination of name, status and creation date. Take a look at org.broadleafcommerce.core.order.service.OrderService#findCarts(String[], org.broadleafcommerce.core.order.service.type.OrderStatus[], java.util.Date, Boolean, int, int) for more info on the default behavior.
      Specified by:
      purgeCarts in interface ResourcePurgeService
      Parameters:
      config - Map of params used to drive the selection of carts to purge
    • notifyCarts

      public void notifyCarts(Map<String,String> config)
      Specified by:
      notifyCarts in interface ResourcePurgeService
    • purgeOrderHistory

      public void purgeOrderHistory(Class<?> rootType, String rootTypeIdValue, Map<String,List<DeleteStatementGeneratorImpl.PathElement>> depends, Map<String,Integer> config)
      Description copied from interface: ResourcePurgeService
      Generates delete statement and executes them Originally was designed to purge orders and its dependencies
      Specified by:
      purgeOrderHistory in interface ResourcePurgeService
      Parameters:
      rootType - - entity type to start from to find all dependent entities
      rootTypeIdValue - - id value to use, can be any string like '?' that you will want to replace with concrete id, or id itself
      depends - - a map representing dependent tables that can't be navigated from a root type, where key is a table name to depend on, value is structure representing a depending table name, join column name(FK column that is in depending table) and id field name in table to depend on.
    • purgeCustomers

      public void purgeCustomers(Map<String,String> config)
      Specified by:
      purgeCustomers in interface ResourcePurgeService
    • getCartsInErrorToIgnore

      protected Set<Long> getCartsInErrorToIgnore(ResourcePurgeServiceImpl.CartPurgeParams purgeParams)
      Get the Carts Ids from cache that should be ignored due to errors in previous purge attempts. Expired cached errors removed.
      Parameters:
      purgeParams - configured parameters for the cart purge process
      Returns:
      set of cart ids to ignore/exclude from the next purge run
    • getCartsToPurge

      protected List<Order> getCartsToPurge(ResourcePurgeServiceImpl.CartPurgeParams purgeParams, int startPos, int length, List<Long> cartsInError)
      Get the list of carts to delete from the database. Subclasses may override for custom cart retrieval logic.
      Parameters:
      purgeParams - configured parameters for the Cart purge process
      cartsInError - list of cart ids to be ignored/excluded from the query
      Returns:
      list of carts to delete
    • getCartsToPurgeLength

      protected Long getCartsToPurgeLength(ResourcePurgeServiceImpl.CartPurgeParams purgeParams, List<Long> cartsInError)
      Get the count of carts to delete from the database. Subclasses may override for custom cart retrieval logic.
      Parameters:
      purgeParams - configured parameters for the Customer purge process used in the query
      cartsInError - list of cart ids to ignore/exclude from the next purge run
      Returns:
      count of carts to delete
    • notifyCart

      protected void notifyCart(Order cart)
      Notify the cart's owner of a pending purge of their cart.
      Parameters:
      cart - the cart
    • getEmailForCart

      protected String getEmailForCart(Order cart)
    • deleteCart

      protected void deleteCart(Order cart)
      Remove the cart from the persistence layer. Subclasses may override for custom cart retrieval logic.
      Parameters:
      cart - the cart to remove
    • getCustomersInErrorToIgnore

      protected Set<Long> getCustomersInErrorToIgnore(ResourcePurgeServiceImpl.CustomerPurgeParams purgeParams)
      Get the Customer Ids from cache that should be ignored due to errors in previous purge attempts
      Parameters:
      purgeParams - configured parameters for the Customer purge process
      Returns:
      set of customer ids to ignore/exclude from the next purge run
    • getCustomersToPurge

      protected List<Customer> getCustomersToPurge(ResourcePurgeServiceImpl.CustomerPurgeParams purgeParams, int startPos, int length, List<Long> customersInError)
      Get the list of carts to delete from the database. Subclasses may override for custom cart retrieval logic.
      Parameters:
      purgeParams - configured parameters for the Customer purge process
      customersInError - list of customer ids to be ignored/excluded from the query
      Returns:
      list of customers to delete
    • getCustomersToPurgeLength

      protected Long getCustomersToPurgeLength(ResourcePurgeServiceImpl.CustomerPurgeParams purgeParams, List<Long> customersInError)
      Get the count of customers to delete from the database. Subclasses may override for custom customer retrieval logic.
      Parameters:
      purgeParams - configured parameters for the Customer purge process
      customersInError - list of customer ids to be ignored/excluded from the query
      Returns:
    • deleteCustomer

      protected void deleteCustomer(Customer customer)
      Remove the cart from the persistence layer. Subclasses may override for custom cart retrieval logic.
      Parameters:
      customer - the customer to remove