Class DefaultApplicationCatalogService
- All Implemented Interfaces:
ApplicationCatalogService
- Author:
- Samarth Dhruva (samarthd)
-
Constructor Summary
ConstructorDescriptionDefaultApplicationCatalogService
(ApplicationService<Application> applicationService, CatalogService<Catalog> catalogService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, org.springframework.transaction.support.TransactionTemplate template, ApplicationCatalogValidator applicationCatalogValidator) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.broadleafcommerce.data.tracking.core.context.ContextInfo
copyContextExcludeApplication
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.since 1.4.createCatalogAndAssignToApplication
(ApplicationCatalog applicationCatalog, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Creates the catalog provided inApplicationCatalog.getCatalog()
, and immediately assigns it to the application found in the contextInfo.void
deleteApplicationCatalogRef
(String applicationCatalogRefId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) For the application found in the contextInfo, scans itsApplication.getIsolatedCatalogs()
for the one with the given ID and removes it from the list.protected ApplicationCatalog
hydrateToApplicationCatalog
(ApplicationCatalogRef applicationCatalogRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds theCatalog
matching the givenApplicationCatalogRef.getId()
in the data store, and builds a newApplicationCatalog
object matching the givenApplicationCatalogRef
with the found catalog.protected ApplicationCatalog
mapToApplicationCatalog
(ApplicationCatalogRef applicationCatalogRef, Catalog catalog) org.springframework.data.domain.Page<ApplicationCatalogRef>
readAllApplicationCatalogs
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, String type) For the application found in the contextInfo, returns the full list of the application'sApplicationCatalogRefs
.org.springframework.data.domain.Page<ApplicationCatalogRef>
readAllApplicationCatalogs
(cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.readApplicationCatalogRef
(String applicationCatalogRefId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) For the application found in the contextInfo, scans itsApplication.getIsolatedCatalogs()
and returns theApplicationCatalogRef
with the given ID.readApplicationCatalogRefsByCatalogId
(@NonNull String catalogId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) For all the applications, finds the list of applications that contain the given catalog ID in theirApplication.getIsolatedCatalogs()
.replaceApplicationCatalogRef
(String applicationCatalogRefId, ApplicationCatalogRef applicationCatalogRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) For the application found in the contextInfo, scans itsApplication.getIsolatedCatalogs()
for the one with the given ID and replaces it with the supplied replacement.protected void
validateApplicationCatalogForCreate
(Application application, ApplicationCatalog applicationCatalog, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method is intended to provide fail-fast behavior increateCatalogAndAssignToApplication(ApplicationCatalog, ContextInfo)
to avoid situations where theCrudEntityService.create(Object, ContextInfo)
succeeds but the subsequentCrudEntityService.replace(String, Object, ContextInfo)
fails due to validation errors.protected void
validateApplicationCatalogRefForReplace
(Application application, Catalog referencedCatalog, ApplicationCatalogRef original, ApplicationCatalogRef replacement, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method is intended to perform any validation that should specifically apply when doing catalog management from an application context.
-
Constructor Details
-
DefaultApplicationCatalogService
public DefaultApplicationCatalogService(ApplicationService<Application> applicationService, CatalogService<Catalog> catalogService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, org.springframework.transaction.support.TransactionTemplate template, ApplicationCatalogValidator applicationCatalogValidator)
-
-
Method Details
-
readAllApplicationCatalogs
@Deprecated public org.springframework.data.domain.Page<ApplicationCatalogRef> readAllApplicationCatalogs(@Nullable cz.jirutka.rsql.parser.ast.Node filters, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InvalidApplicationContextException Deprecated.Description copied from interface:ApplicationCatalogService
For the application found in the contextInfo, returns the full list of the application'sApplicationCatalogRefs
.This operation is invalid for non-application contexts.
- Specified by:
readAllApplicationCatalogs
in interfaceApplicationCatalogService
- Parameters:
filters
- additional filters to apply in the query, can be nullcontextInfo
- context information surrounding the sandboxing and multitenant state- Returns:
- all of the application's
ApplicationCatalogRefs
- Throws:
InvalidApplicationContextException
- if theapplication ID
in thecontext info's context request
is empty. This operation is invalid for non-application contexts
-
readAllApplicationCatalogs
public org.springframework.data.domain.Page<ApplicationCatalogRef> readAllApplicationCatalogs(@NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @Nullable String type) throws InvalidApplicationContextException Description copied from interface:ApplicationCatalogService
For the application found in the contextInfo, returns the full list of the application'sApplicationCatalogRefs
.This operation is invalid for non-application contexts.
- Specified by:
readAllApplicationCatalogs
in interfaceApplicationCatalogService
- Parameters:
contextInfo
- context information surrounding the sandboxing and multitenant statetype
- TheCatalog.getType()
to filter the results by.- Returns:
- all of the application's
ApplicationCatalogRefs
- Throws:
InvalidApplicationContextException
- if theapplication ID
in thecontext info's context request
is empty. This operation is invalid for non-application contexts
-
createCatalogAndAssignToApplication
public ApplicationCatalog createCatalogAndAssignToApplication(@NonNull ApplicationCatalog applicationCatalog, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InvalidApplicationContextException Description copied from interface:ApplicationCatalogService
Creates the catalog provided inApplicationCatalog.getCatalog()
, and immediately assigns it to the application found in the contextInfo.This operation is invalid for non-application contexts.
- Specified by:
createCatalogAndAssignToApplication
in interfaceApplicationCatalogService
- Parameters:
applicationCatalog
- an object containing the catalog to create and the relationship fields required to associate that catalog to the application found in the contextInfocontextInfo
- context information surrounding the sandboxing and multitenant state- Returns:
- a
ApplicationCatalog
containing the created catalog and relationship - Throws:
InvalidApplicationContextException
- if theapplication ID
in thecontext info's context request
is empty. This operation is invalid for non-application contexts
-
validateApplicationCatalogForCreate
protected void validateApplicationCatalogForCreate(Application application, ApplicationCatalog applicationCatalog, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method is intended to provide fail-fast behavior increateCatalogAndAssignToApplication(ApplicationCatalog, ContextInfo)
to avoid situations where theCrudEntityService.create(Object, ContextInfo)
succeeds but the subsequentCrudEntityService.replace(String, Object, ContextInfo)
fails due to validation errors.It also performs any validation specific to catalog management done from an application context.
Delegates to
ApplicationCatalogValidator.validateForCreate(Application, ApplicationCatalog, ContextInfo, Errors)
.- Parameters:
application
- the application for which a catalog is being createdapplicationCatalog
- the application catalog to validate- Throws:
com.broadleafcommerce.common.error.validation.ValidationException
- if there was an error with the givenapplicationCatalog
- See Also:
-
readApplicationCatalogRef
public ApplicationCatalog readApplicationCatalogRef(@NonNull String applicationCatalogRefId, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InvalidApplicationContextException Description copied from interface:ApplicationCatalogService
For the application found in the contextInfo, scans itsApplication.getIsolatedCatalogs()
and returns theApplicationCatalogRef
with the given ID.On the result, the catalog matching the
ApplicationCatalogRef.getId()
will be fully hydrated onApplicationCatalog.getCatalog()
.This operation is invalid for non-application contexts.
- Specified by:
readApplicationCatalogRef
in interfaceApplicationCatalogService
- Parameters:
applicationCatalogRefId
- theApplicationCatalogRef.getId()
of the target application catalog refcontextInfo
- context information surrounding the sandboxing and multitenant state- Returns:
- the application catalog ref matching the given ID with its catalog fully hydrated
- Throws:
InvalidApplicationContextException
- if theapplication ID
in thecontext info's context request
is empty. This operation is invalid for non-application contexts
-
hydrateToApplicationCatalog
protected ApplicationCatalog hydrateToApplicationCatalog(ApplicationCatalogRef applicationCatalogRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds theCatalog
matching the givenApplicationCatalogRef.getId()
in the data store, and builds a newApplicationCatalog
object matching the givenApplicationCatalogRef
with the found catalog.- Parameters:
applicationCatalogRef
- the application catalog ref to build a new hydrated application catalog object forcontextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- a new
ApplicationCatalog
instance matching the givenapplicationCatalogRef
with a fully hydratedApplicationCatalog.getCatalog()
-
mapToApplicationCatalog
protected ApplicationCatalog mapToApplicationCatalog(ApplicationCatalogRef applicationCatalogRef, Catalog catalog) -
replaceApplicationCatalogRef
public ApplicationCatalog replaceApplicationCatalogRef(@NonNull String applicationCatalogRefId, @NonNull ApplicationCatalogRef applicationCatalogRef, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InvalidApplicationContextException Description copied from interface:ApplicationCatalogService
For the application found in the contextInfo, scans itsApplication.getIsolatedCatalogs()
for the one with the given ID and replaces it with the supplied replacement.On the result, the catalog matching the
ApplicationCatalogRef.getId()
will be fully hydrated onApplicationCatalog.getCatalog()
.This operation is invalid for non-application contexts.
- Specified by:
replaceApplicationCatalogRef
in interfaceApplicationCatalogService
- Parameters:
applicationCatalogRefId
- theApplicationCatalogRef.getId()
of the target application catalog refapplicationCatalogRef
- the replacementApplicationCatalogRef
contextInfo
- context information surrounding the sandboxing and multitenant state- Returns:
- the replaced application catalog ref with its catalog fully hydrated
- Throws:
InvalidApplicationContextException
- if theapplication ID
in thecontext info's context request
is empty. This operation is invalid for non-application contexts
-
validateApplicationCatalogRefForReplace
protected void validateApplicationCatalogRefForReplace(Application application, Catalog referencedCatalog, ApplicationCatalogRef original, ApplicationCatalogRef replacement, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method is intended to perform any validation that should specifically apply when doing catalog management from an application context.- Parameters:
application
- the application for which anApplicationCatalogRef
is being replaced. This should be the fully-hydrated value from the data store.referencedCatalog
- the fully-hydrated catalog corresponding to the id referenced byApplicationCatalogRef.getId()
onoriginal
original
- theApplicationCatalogRef
that currently exists on theApplication
and is being replacedreplacement
- theApplicationCatalogRef
that will replaceoriginal
on the applicationcontextInfo
- context information surrounding sandboxing and multitenant state- Throws:
com.broadleafcommerce.common.error.validation.ValidationException
- if there was an error with the replacement- See Also:
-
deleteApplicationCatalogRef
public void deleteApplicationCatalogRef(@NonNull String applicationCatalogRefId, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InvalidApplicationContextException Description copied from interface:ApplicationCatalogService
For the application found in the contextInfo, scans itsApplication.getIsolatedCatalogs()
for the one with the given ID and removes it from the list.This operation is invalid for non-application contexts.
- Specified by:
deleteApplicationCatalogRef
in interfaceApplicationCatalogService
- Parameters:
applicationCatalogRefId
- theApplicationCatalogRef.getId()
of the target application catalog refcontextInfo
- context information surrounding the sandboxing and multitenant state- Throws:
InvalidApplicationContextException
- if theapplication ID
in thecontext info's context request
is empty. This operation is invalid for non-application contexts
-
readApplicationCatalogRefsByCatalogId
public List<ApplicationCatalogRef> readApplicationCatalogRefsByCatalogId(@NonNull @NonNull String catalogId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ApplicationCatalogService
For all the applications, finds the list of applications that contain the given catalog ID in theirApplication.getIsolatedCatalogs()
.- Specified by:
readApplicationCatalogRefsByCatalogId
in interfaceApplicationCatalogService
- Parameters:
catalogId
- the catalog ID of the target application catalog refcontextInfo
- context information surrounding the sandboxing and multitenant state- Returns:
- the list of
ApplicationCatalogRef
for the given catalog ID
-
copyContextExcludeApplication
@Deprecated protected com.broadleafcommerce.data.tracking.core.context.ContextInfo copyContextExcludeApplication(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.since 1.4. This method should not be used, as it will cause policy validation to fail for application-restricted users.Work-around to allow modification of application/catalog relationships via an application context. Applications are tenant trackable and typically only modifiable from a tenant context, but we need to allow application level admins to manipulate catalog/application relationships.- Parameters:
contextInfo
- The supplied ContextInfo.- Returns:
- A contextInfo copy with application set to null.
-