Class CatalogFinder<P extends Catalog>
java.lang.Object
com.broadleafcommerce.data.tracking.core.policy.trackable.CatalogFinder<P>
Utility class for fetching
Catalog
instances. Generally, the CommonCatalogService
would serve this duty, but there are some circumstances where a separate, lightweight fetch
mechanism is called for. Specifically, in DefaultTrackablePolicyUtils
, there is a need to
resolve catalog instances for tenant related security checks, but to inject CommonCatalogService
there creates a circular dependency, since CommonCatalogService also requires PolicyUtils
to secure its functions.
In addition, this utility class honors cases where tenancy is not active. In those cases, the
CatalogFinder.CatalogResponse
returned from method calls will indicate this via
CatalogFinder.CatalogResponse.getTenantState()
. Callers should check this result and gracefully ignore
tenant related checks for catalog state when the tenant state returned is
CatalogFinder.TenantState.NOT_AVAILABLE
.
- Author:
- Jeff Fischer
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
CatalogFinder.CatalogResponse<P extends Catalog>
Response object indicating if tenancy is active, and if so, the catalog that was found based on the request, if any.static enum
Indicates if tenant related functionality is active -
Field Summary
-
Constructor Summary
ConstructorDescriptionCatalogFinder
(CommonCatalogRepository<?> repository, DomainMapperManager manager) -
Method Summary
Modifier and TypeMethodDescriptionRetrieve aCatalogFinder.CatalogResponse
based on the contextId for the catalog.getInherited
(String contextId, String applicationId) Find any application owned catalog that inherits from the starting catalog based on the requested application.
-
Field Details
-
CACHE_BY_CATALOG
- See Also:
-
CACHE_BY_CATALOG_INHERITED
- See Also:
-
-
Constructor Details
-
CatalogFinder
-
-
Method Details
-
get
@Cacheable(value="trackingCacheByCatalog", condition="@cacheStateManager.isEnabled(#root.caches, #root.args)") public CatalogFinder.CatalogResponse<P> get(String contextId) Retrieve aCatalogFinder.CatalogResponse
based on the contextId for the catalog. Similar toCrudEntityService.readByContextId(String, ContextInfo)
.- Parameters:
contextId
- The contextId of the catalogTrackable.getContextId()
- Returns:
- The response indicating if tenancy is active, and if so, the catalog that was found matching the contextId (if any)
-
getInherited
@Cacheable(value="trackingCacheByCatalogInherited", condition="@cacheStateManager.isEnabled(#root.caches, #root.args)") public CatalogFinder.CatalogResponse<P> getInherited(String contextId, String applicationId) Find any application owned catalog that inherits from the starting catalog based on the requested application. Similar toCommonCatalogService.readApplicationOwnedInheritedCatalog(String, String)
.- Parameters:
contextId
- The ancestor catalog from which to check inheritanceapplicationId
- The id of the application that should own the inherited catalog- Returns:
- The response indicating if tenancy is active, and if so, the application owned catalog that was found (if any).
-