Class DefaultSandboxService<P extends Sandbox>

java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.sandbox.service.DefaultSandboxService<P>
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>, SandboxService<P>

public class DefaultSandboxService<P extends Sandbox> extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P> implements SandboxService<P>
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultSandboxService(SandboxRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidatorManager validator, org.springframework.transaction.support.TransactionTemplate template)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    createWithIdIfDoesNotExist(P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    This is a custom create method that will override the autogenerated context ID produced by CreateSetupDomainMapperMember, and instead use the Sandbox.id that is supplied in the given sandbox.
    void
    delete(String sandboxId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Deletes the sandbox with specified id, archives all change summaries, change summary groups related to that sandbox, and sends the SandboxDeleteProducer.TYPE notification.
    boolean
    existsByApplication(String applicationId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Determines whether any Sandboxes exist for the application
     
     
    protected com.broadleafcommerce.common.messaging.notification.NotificationManager
     
    protected com.broadleafcommerce.common.messaging.notification.NotificationStateService
     
    protected SandboxRepository<com.broadleafcommerce.data.tracking.core.Trackable>
     
    protected org.springframework.transaction.support.TransactionTemplate
     
    protected com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidatorManager
     
    org.springframework.data.domain.Page<P>
    readAllByApplication(String applicationId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageInfo, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Read all the sandboxes for the current application.
    org.springframework.data.domain.Page<P>
    readAllByNameAndApplication(String name, String applicationId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageInfo, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Read all the sandboxes for the current application with the given name
    readByContextIdAndApplication(String id, String applicationId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Read the sandbox by ID for the current application
    void
     
    void
     
    void
    setNotificationManager(com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager)
     
    void
    setNotificationStateService(com.broadleafcommerce.common.messaging.notification.NotificationStateService notificationStateService)
     
    void
    validateExistsByContextIdAndApplication(String id, String applicationId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Validates that the sandbox with the given ID belongs to the current application

    Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService

    getRsqlHelper, readAll, readAll, readAll, readAll

    Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService

    convertFromPersistentDomain, convertToPersistentDomain, create, createAll, createAllAllowingPartialSuccess, getHelper, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, update, updateAll, updateAllAllowingPartialSuccess, updateSort

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService

    create, createAll, createAllAllowingPartialSuccess, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSort

    Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService

    readAll, readAll, readAll, readAll
  • Constructor Details

    • DefaultSandboxService

      public DefaultSandboxService(SandboxRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidatorManager validator, org.springframework.transaction.support.TransactionTemplate template)
  • Method Details

    • createWithIdIfDoesNotExist

      public P createWithIdIfDoesNotExist(@NonNull P businessInstance, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SandboxService
      This is a custom create method that will override the autogenerated context ID produced by CreateSetupDomainMapperMember, and instead use the Sandbox.id that is supplied in the given sandbox.

      This method will perform an atomic upsert, returning the sandbox if it was newly created, null otherwise. This differs from the normal save/create in that whether or not a new entity should be created is based on the contextId rather than the data-store ID.

      This method is solely intended for use in CreateSandboxRequestListener, and should not be used elsewhere.

      Specified by:
      createWithIdIfDoesNotExist in interface SandboxService<P extends Sandbox>
      Parameters:
      businessInstance - the sandbox to create, with its Sandbox.id set
      contextInfo - context information surrounding multitenant state
      Returns:
      the sandbox if it was newly created, null otherwise
    • readAllByNameAndApplication

      @NonNull public org.springframework.data.domain.Page<P> readAllByNameAndApplication(@NonNull String name, @Nullable String applicationId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable pageInfo, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: SandboxService
      Read all the sandboxes for the current application with the given name
      Specified by:
      readAllByNameAndApplication in interface SandboxService<P extends Sandbox>
      Parameters:
      name - Name query by which to filter results
      applicationId - Id of the application that owns the sandbox. Null if not application-owned.
      filters - additional filters to apply in the query, can be null
      pageInfo - results paging info
      context - contains the application context
      Returns:
      all the valid (un-archived) sandboxes for the current application context
    • readAllByApplication

      @NonNull public org.springframework.data.domain.Page<P> readAllByApplication(@Nullable String applicationId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable pageInfo, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: SandboxService
      Read all the sandboxes for the current application.
      Specified by:
      readAllByApplication in interface SandboxService<P extends Sandbox>
      Parameters:
      applicationId - Id of the application that owns the sandbox. Null if not application-owned.
      filters - additional filters to apply in the query, can be null
      pageInfo - results paging info
      context - contains the application context
      Returns:
      all the valid (un-archived) sandboxes for the current application context
    • readByContextIdAndApplication

      @NonNull public P readByContextIdAndApplication(@NonNull String id, @Nullable String applicationId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: SandboxService
      Read the sandbox by ID for the current application
      Specified by:
      readByContextIdAndApplication in interface SandboxService<P extends Sandbox>
      Parameters:
      id - ID of the Sandbox.
      applicationId - Id of the application that owns the sandbox. Null if not application-owned.
      context - contains the application context
      Returns:
      all the valid (un-archived) sandboxes for the current application context
    • validateExistsByContextIdAndApplication

      public void validateExistsByContextIdAndApplication(@NonNull String id, @Nullable String applicationId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: SandboxService
      Validates that the sandbox with the given ID belongs to the current application
      Specified by:
      validateExistsByContextIdAndApplication in interface SandboxService<P extends Sandbox>
      Parameters:
      id - ID of the Sandbox.
      applicationId - Id of the application that owns the sandbox. Null if not application-owned.
      context - contains the application context
    • existsByApplication

      public boolean existsByApplication(String applicationId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: SandboxService
      Determines whether any Sandboxes exist for the application
      Specified by:
      existsByApplication in interface SandboxService<P extends Sandbox>
      Parameters:
      applicationId - Id of the application that owns the sandbox. Null if not application-owned.
      contextInfo - contains the application context
      Returns:
      Whether any Sandboxes exist for the application
    • delete

      @Transactional("sandboxTransactionManager") public void delete(@NonNull String sandboxId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)

      Deletes the sandbox with specified id, archives all change summaries, change summary groups related to that sandbox, and sends the SandboxDeleteProducer.TYPE notification.

      Note: the setup for the SandboxDeleteProducer.TYPE notification state happens in NotificationAwareDomainMapperMember.

      Specified by:
      delete in interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends Sandbox>
      Overrides:
      delete in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends Sandbox>
      Parameters:
      sandboxId - the sandbox id to delete
      context - Context information used to discriminate the correct version of an entity by context id when multiple verions may be available across sandboxes, catalogs and applications.
      Throws:
      com.broadleafcommerce.data.tracking.core.exception.EntityMissingException - if the sandbox doesn't exist
      ArchiveChangeSummaryException - if there are ChangeSummary in active state.
      See Also:
    • getRepository

      @NonNull protected SandboxRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()
      Overrides:
      getRepository in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends Sandbox>
    • getValidator

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

      @NonNull protected org.springframework.transaction.support.TransactionTemplate getTemplate()
    • getChangeSummaryService

      @NonNull protected ChangeSummaryService<ChangeSummary> getChangeSummaryService()
    • setChangeSummaryService

      @Autowired @Lazy public void setChangeSummaryService(ChangeSummaryService<ChangeSummary> changeSummaryService)
    • getChangeSummaryGroupService

      @NonNull protected ChangeSummaryGroupService<ChangeSummaryGroup> getChangeSummaryGroupService()
    • setChangeSummaryGroupService

      @Autowired public void setChangeSummaryGroupService(ChangeSummaryGroupService<ChangeSummaryGroup> changeSummaryGroupService)
    • getNotificationManager

      @NonNull protected com.broadleafcommerce.common.messaging.notification.NotificationManager getNotificationManager()
    • setNotificationManager

      @Autowired public void setNotificationManager(com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager)
    • getNotificationStateService

      @NonNull protected com.broadleafcommerce.common.messaging.notification.NotificationStateService getNotificationStateService()
    • setNotificationStateService

      @Autowired public void setNotificationStateService(com.broadleafcommerce.common.messaging.notification.NotificationStateService notificationStateService)