Class DefaultApplicationCatalogService
- All Implemented Interfaces:
ApplicationCatalogService
- Author:
- Samarth Dhruva (samarthd)
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultApplicationCatalogService(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.ContextInfocopyContextExcludeApplication(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.voiddeleteApplicationCatalogRef(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 ApplicationCataloghydrateToApplicationCatalog(ApplicationCatalogRef applicationCatalogRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds theCatalogmatching the givenApplicationCatalogRef.getId()in the data store, and builds a newApplicationCatalogobject matching the givenApplicationCatalogRefwith the found catalog.protected ApplicationCatalogmapToApplicationCatalog(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 theApplicationCatalogRefwith the given ID.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 voidvalidateApplicationCatalogForCreate(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 voidvalidateApplicationCatalogRefForReplace(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:ApplicationCatalogServiceFor the application found in the contextInfo, returns the full list of the application'sApplicationCatalogRefs.This operation is invalid for non-application contexts.
- Specified by:
readAllApplicationCatalogsin 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 IDin thecontext info's context requestis 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:ApplicationCatalogServiceFor the application found in the contextInfo, returns the full list of the application'sApplicationCatalogRefs.This operation is invalid for non-application contexts.
- Specified by:
readAllApplicationCatalogsin 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 IDin thecontext info's context requestis 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:ApplicationCatalogServiceCreates 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:
createCatalogAndAssignToApplicationin 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
ApplicationCatalogcontaining the created catalog and relationship - Throws:
InvalidApplicationContextException- if theapplication IDin thecontext info's context requestis 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:ApplicationCatalogServiceFor the application found in the contextInfo, scans itsApplication.getIsolatedCatalogs()and returns theApplicationCatalogRefwith 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:
readApplicationCatalogRefin 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 IDin thecontext info's context requestis empty. This operation is invalid for non-application contexts
-
hydrateToApplicationCatalog
protected ApplicationCatalog hydrateToApplicationCatalog(ApplicationCatalogRef applicationCatalogRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds theCatalogmatching the givenApplicationCatalogRef.getId()in the data store, and builds a newApplicationCatalogobject matching the givenApplicationCatalogRefwith 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
ApplicationCataloginstance matching the givenapplicationCatalogRefwith 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:ApplicationCatalogServiceFor 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:
replaceApplicationCatalogRefin interfaceApplicationCatalogService- Parameters:
applicationCatalogRefId- theApplicationCatalogRef.getId()of the target application catalog refapplicationCatalogRef- the replacementApplicationCatalogRefcontextInfo- context information surrounding the sandboxing and multitenant state- Returns:
- the replaced application catalog ref with its catalog fully hydrated
- Throws:
InvalidApplicationContextException- if theapplication IDin thecontext info's context requestis 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 anApplicationCatalogRefis 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()onoriginaloriginal- theApplicationCatalogRefthat currently exists on theApplicationand is being replacedreplacement- theApplicationCatalogRefthat will replaceoriginalon 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:ApplicationCatalogServiceFor 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:
deleteApplicationCatalogRefin interfaceApplicationCatalogService- Parameters:
applicationCatalogRefId- theApplicationCatalogRef.getId()of the target application catalog refcontextInfo- context information surrounding the sandboxing and multitenant state- Throws:
InvalidApplicationContextException- if theapplication IDin thecontext info's context requestis empty. This operation is invalid for non-application contexts
-
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.
-