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
ConstructorsConstructorDescriptionDefaultSandboxService
(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 TypeMethodDescriptioncreateWithIdIfDoesNotExist
(P businessInstance, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This is a custom create method that will override the autogenerated context ID produced byCreateSetupDomainMapperMember
, and instead use theSandbox.id
that is supplied in the givensandbox
.void
Deletes the sandbox with specified id, archives all change summaries, change summary groups related to that sandbox, and sends theSandboxDeleteProducer.TYPE
notification.boolean
existsByApplication
(String applicationId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines whether anySandboxes
exist for the applicationprotected ChangeSummaryGroupService<ChangeSummaryGroup>
protected ChangeSummaryService<ChangeSummary>
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 namereadByContextIdAndApplication
(String id, String applicationId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Read the sandbox by ID for the current applicationvoid
setChangeSummaryGroupService
(ChangeSummaryGroupService<ChangeSummaryGroup> changeSummaryGroupService) void
setChangeSummaryService
(ChangeSummaryService<ChangeSummary> changeSummaryService) 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 applicationMethods 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 byCreateSetupDomainMapperMember
, and instead use theSandbox.id
that is supplied in the givensandbox
.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 thecontextId
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 interfaceSandboxService<P extends Sandbox>
- Parameters:
businessInstance
- the sandbox to create, with itsSandbox.id
setcontextInfo
- 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 interfaceSandboxService<P extends Sandbox>
- Parameters:
name
- Name query by which to filter resultsapplicationId
- Id of the application that owns the sandbox. Null if not application-owned.filters
- additional filters to apply in the query, can be nullpageInfo
- results paging infocontext
- 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 interfaceSandboxService<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 nullpageInfo
- results paging infocontext
- 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 interfaceSandboxService<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 interfaceSandboxService<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 anySandboxes
exist for the application- Specified by:
existsByApplication
in interfaceSandboxService<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 inNotificationAwareDomainMapperMember
.- Specified by:
delete
in interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends Sandbox>
- Overrides:
delete
in classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends Sandbox>
- Parameters:
sandboxId
- the sandbox id to deletecontext
- 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 existArchiveChangeSummaryException
- if there areChangeSummary
in active state.- See Also:
-
getRepository
@NonNull protected SandboxRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository() -
getValidator
@NonNull protected com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidatorManager getValidator() -
getTemplate
@NonNull protected org.springframework.transaction.support.TransactionTemplate getTemplate() -
getChangeSummaryService
-
setChangeSummaryService
@Autowired @Lazy public void setChangeSummaryService(ChangeSummaryService<ChangeSummary> changeSummaryService) -
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)
-