Class CatalogFinder<P extends Catalog>
- java.lang.Object
-
- com.broadleafcommerce.data.tracking.core.policy.trackable.CatalogFinder<P>
-
public class CatalogFinder<P extends Catalog> extends Object
Utility class for fetchingCatalog
instances. Generally, theCommonCatalogService
would serve this duty, but there are some circumstances where a separate, lightweight fetch mechanism is called for. Specifically, inDefaultTrackablePolicyUtils
, 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 requiresPolicyUtils
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 viaCatalogFinder.CatalogResponse.getTenantState()
. Callers should check this result and gracefully ignore tenant related checks for catalog state when the tenant state returned isCatalogFinder.TenantState.NOT_AVAILABLE
.- Author:
- Jeff Fischer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static 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 class
CatalogFinder.TenantState
Indicates if tenant related functionality is active
-
Field Summary
Fields Modifier and Type Field Description static String
CACHE_BY_CATALOG
static String
CACHE_BY_CATALOG_INHERITED
-
Constructor Summary
Constructors Constructor Description CatalogFinder(CommonCatalogRepository<?> repository, DomainMapperManager manager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CatalogFinder.CatalogResponse<P>
get(String contextId)
Retrieve aCatalogFinder.CatalogResponse
based on the contextId for the catalog.CatalogFinder.CatalogResponse<P>
getInherited(String contextId, String applicationId)
Find any application owned catalog that inherits from the starting catalog based on the requested application.
-
-
-
Field Detail
-
CACHE_BY_CATALOG
public static final String CACHE_BY_CATALOG
- See Also:
- Constant Field Values
-
CACHE_BY_CATALOG_INHERITED
public static final String CACHE_BY_CATALOG_INHERITED
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CatalogFinder
public CatalogFinder(@Nullable CommonCatalogRepository<?> repository, DomainMapperManager manager)
-
-
Method Detail
-
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).
-
-