Class DefaultContentItemResolverService<I extends ContentItem>
java.lang.Object
com.broadleafcommerce.content.service.DefaultContentItemResolverService<I>
- All Implemented Interfaces:
ContentItemResolverService<I>
,EventListener
,org.springframework.context.ApplicationListener<ContentCacheInvalidationEvent>
public class DefaultContentItemResolverService<I extends ContentItem>
extends Object
implements ContentItemResolverService<I>, org.springframework.context.ApplicationListener<ContentCacheInvalidationEvent>
- Author:
- Nathan Moore (nathandmoore)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultContentItemResolverService
(ContentZoneService<ContentZone> zoneService, ContentModelService<ContentModel> modelService, ContentItemService<I> itemService, ContentItemHydrationService hydrationService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> rsqlParser) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
checkContentItemDisplayRule
(ContentItem contentItem, ContentContext context) protected void
evaluateContentItemDisplayRules
(I item, ContentContext request) void
evaluateDisplayRulesForResponse
(@NonNull ContentResolverResponse<I> response, ContentContext request) Recursively evaluates the display rules for the givenresponse
to filter out anyContentItems
that should not be displayed.protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils
protected com.broadleafcommerce.common.extension.cache.CacheStateManager
protected Optional<ContentResolverResponse<I>>
getContentByContentZoneName
(@NonNull ContentResolverRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Optional<ContentResolverResponse<I>>
getContentByUri
(String uri, @NonNull org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Optional<ContentResolverResponse<I>>
getContentForItemIds
(@NonNull Collection<String> ids, @NonNull org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Optional<ContentResolverResponse<I>>
getContentForItemNames
(@NonNull Collection<String> names, @NonNull org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Optional<ContentResolverResponse<I>>
getContentForModelId
(String id, @NonNull org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Optional<ContentResolverResponse<I>>
getContentForModelName
(String name, @NonNull org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) getContentForRequest
(@NonNull ContentResolverRequest request, @NonNull org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) ResolvesContentItems
for the givenrequest
.getContentItemIdsFromItemList
(List<ContentZoneItem> items, ContentContext context) protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen
protected ContentItemHydrationService
protected ContentItemService<I>
protected ContentModelService<ContentModel>
protected ContentItemResolverProperties
protected com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node>
protected com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService
protected com.broadleafcommerce.common.extension.TypeFactory
protected ContentZoneService<ContentZone>
protected ContentResolverResponse<I>
hydrateResponse
(@NonNull ContentResolverResponse<I> response, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hydrates theContentModel
on the items so that theContentFields
are present.hydrateRuleBasedItems
(List<ContentZoneItem> items, ContentContext context, String allowedModelsRule, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected boolean
protected boolean
protected boolean
isPaginated
(org.springframework.data.domain.Pageable page) protected boolean
protected ContentResolverResponse<I>
minifyResponse
(@NonNull ContentResolverResponse<I> response) Removes any unnecessary data likeContentItem.getContextState()
from the response.void
protected void
protected void
populateDisplayOrder
(List<I> contentItems, List<ContentZoneItem> contentZoneItemList) protected ContentResolverResponse<I>
postProcessResponse
(@NonNull ContentResolverResponse<I> response, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Performs post-processing on the results such as hydration and minification.protected boolean
recursivelyCheckDisplayRule
(FieldData fieldData, ContentContext context) void
setAuthenticationUtils
(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils) void
setCacheStateManager
(com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager) void
setContentResolverCacheByItemIdIn
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentResolverCacheByItemIdIn) void
setContentResolverCacheByItemNameIn
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentResolverCacheByItemNameIn) void
setContentResolverCacheByModelId
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentResolverCacheByModelId) void
setContentResolverCacheByModelName
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentResolverCacheByModelName) void
setContentResolverCacheByUri
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentResolverCacheByUri) void
setContentResolverCacheByZoneName
(com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentResolverCacheByZoneName) void
setProperties
(ContentItemResolverProperties properties) void
setRuleEvaluationService
(com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
-
Field Details
-
BY_ZONE_NAME
- See Also:
-
BY_URI
- See Also:
-
BY_MODEL_ID
- See Also:
-
BY_MODEL_NAME
- See Also:
-
BY_ITEM_ID_IN
- See Also:
-
BY_ITEM_NAME_IN
- See Also:
-
ruleEvaluationService
protected com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService
-
-
Constructor Details
-
DefaultContentItemResolverService
public DefaultContentItemResolverService(ContentZoneService<ContentZone> zoneService, ContentModelService<ContentModel> modelService, ContentItemService<I> itemService, ContentItemHydrationService hydrationService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> rsqlParser)
-
-
Method Details
-
getContentForRequest
public Optional<ContentResolverResponse<I>> getContentForRequest(@NonNull @NonNull ContentResolverRequest request, @NonNull @NonNull org.springframework.data.domain.Pageable page, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:ContentItemResolverService
ResolvesContentItems
for the givenrequest
. This accepts aPageable
and RSQL filters.If the
Pageable
is aDefaultPageRequest
, then it will be ignored since that type of pagination is not supported byContentItems
. The correct type would beNarrowedPageable
orUnnumberedPageable
. It will also be considered to mean that no pagination information was in the original request, but instead thePageableDefault
annotation was used to provide defaults.- Specified by:
getContentForRequest
in interfaceContentItemResolverService<I extends ContentItem>
- Parameters:
request
- All relevant information for retrieving the desiredContentItems
.page
- Pagination information. This will be ignored if not aNarrowedPageable
orUnnumberedPageable
,DefaultPageRequest
should only indicate that the original request did not include any pagination parameters and was created by thePageableDefault
annotation on an endpoint.filters
- RSQL filters to be applied to the result set.contextInfo
- Additional sandbox and multitenant information.- Returns:
ContentItems
for the givenrequest
.
-
getContentByContentZoneName
protected Optional<ContentResolverResponse<I>> getContentByContentZoneName(@NonNull @NonNull ContentResolverRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getContentByUri
protected Optional<ContentResolverResponse<I>> getContentByUri(String uri, @NonNull @NonNull org.springframework.data.domain.Pageable page, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getContentForModelId
protected Optional<ContentResolverResponse<I>> getContentForModelId(String id, @NonNull @NonNull org.springframework.data.domain.Pageable page, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getContentForModelName
protected Optional<ContentResolverResponse<I>> getContentForModelName(String name, @NonNull @NonNull org.springframework.data.domain.Pageable page, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getContentForItemNames
protected Optional<ContentResolverResponse<I>> getContentForItemNames(@NonNull @NonNull Collection<String> names, @NonNull @NonNull org.springframework.data.domain.Pageable page, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getContentForItemIds
protected Optional<ContentResolverResponse<I>> getContentForItemIds(@NonNull @NonNull Collection<String> ids, @NonNull @NonNull org.springframework.data.domain.Pageable page, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
isPaginated
protected boolean isPaginated(@Nullable org.springframework.data.domain.Pageable page) -
populateDisplayOrder
protected void populateDisplayOrder(List<I> contentItems, List<ContentZoneItem> contentZoneItemList) -
hydrateRuleBasedItems
protected List<I> hydrateRuleBasedItems(List<ContentZoneItem> items, ContentContext context, String allowedModelsRule, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getContentItemIdsFromItemList
protected List<String> getContentItemIdsFromItemList(List<ContentZoneItem> items, ContentContext context) -
isRuleBasedContentItemMembership
-
isExplicitContentItemMembership
-
postProcessResponse
protected ContentResolverResponse<I> postProcessResponse(@NonNull @NonNull ContentResolverResponse<I> response, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Performs post-processing on the results such as hydration and minification.- Parameters:
response
- TheContentResolverResponse
-
hydrateResponse
protected ContentResolverResponse<I> hydrateResponse(@NonNull @NonNull ContentResolverResponse<I> response, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hydrates theContentModel
on the items so that theContentFields
are present.- Parameters:
response
- TheContentResolverResponse
- Returns:
- The
ContentResolverResponse
-
minifyResponse
protected ContentResolverResponse<I> minifyResponse(@NonNull @NonNull ContentResolverResponse<I> response) Removes any unnecessary data likeContentItem.getContextState()
from the response.- Parameters:
response
- TheContentResolverResponse
- Returns:
- The
ContentResolverResponse
-
populateCustomerRef
-
evaluateDisplayRulesForResponse
public void evaluateDisplayRulesForResponse(@NonNull @NonNull ContentResolverResponse<I> response, ContentContext request) Description copied from interface:ContentItemResolverService
Recursively evaluates the display rules for the givenresponse
to filter out anyContentItems
that should not be displayed.- Specified by:
evaluateDisplayRulesForResponse
in interfaceContentItemResolverService<I extends ContentItem>
- Parameters:
response
- The response to evaluate.request
- The context of the request.
-
evaluateContentItemDisplayRules
-
recursivelyCheckDisplayRule
-
checkContentItemDisplayRule
-
isCallerWhitelistedService
protected boolean isCallerWhitelistedService()- Since:
- Content Services 2.0.5
- See Also:
-
onApplicationEvent
- Specified by:
onApplicationEvent
in interfaceorg.springframework.context.ApplicationListener<I extends ContentItem>
-
getRuleEvaluationService
protected com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService getRuleEvaluationService() -
setRuleEvaluationService
@Autowired @Lazy public void setRuleEvaluationService(com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService) -
getAuthenticationUtils
protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils getAuthenticationUtils() -
setAuthenticationUtils
@Autowired @Lazy public void setAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils) -
getZoneService
-
getModelService
-
getItemService
-
getHydrationService
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getRsqlParser
protected com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> getRsqlParser() -
setProperties
-
getProperties
-
getCacheStateManager
@Nullable protected com.broadleafcommerce.common.extension.cache.CacheStateManager getCacheStateManager() -
setCacheStateManager
@Autowired(required=false) public void setCacheStateManager(@Nullable com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager) -
setContentResolverCacheByZoneName
@Autowired(required=false) @Qualifier("contentResolverCacheByZoneName") public void setContentResolverCacheByZoneName(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentResolverCacheByZoneName) -
getContentResolverCacheByZoneName
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getContentResolverCacheByZoneName() -
setContentResolverCacheByUri
@Autowired(required=false) @Qualifier("contentResolverCacheByUri") public void setContentResolverCacheByUri(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentResolverCacheByUri) -
getContentResolverCacheByUri
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getContentResolverCacheByUri() -
setContentResolverCacheByModelId
@Autowired(required=false) @Qualifier("contentResolverCacheByModelId") public void setContentResolverCacheByModelId(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentResolverCacheByModelId) -
getContentResolverCacheByModelId
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getContentResolverCacheByModelId() -
setContentResolverCacheByModelName
@Autowired(required=false) @Qualifier("contentResolverCacheByModelName") public void setContentResolverCacheByModelName(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentResolverCacheByModelName) -
getContentResolverCacheByModelName
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getContentResolverCacheByModelName() -
setContentResolverCacheByItemIdIn
@Autowired(required=false) @Qualifier("contentResolverCacheByItemIdIn") public void setContentResolverCacheByItemIdIn(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentResolverCacheByItemIdIn) -
getContentResolverCacheByItemIdIn
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getContentResolverCacheByItemIdIn() -
setContentResolverCacheByItemNameIn
@Autowired(required=false) @Qualifier("contentResolverCacheByItemNameIn") public void setContentResolverCacheByItemNameIn(@Nullable com.broadleafcommerce.common.extension.cache.key.ContextKeyGen contentResolverCacheByItemNameIn) -
getContentResolverCacheByItemNameIn
@Nullable protected com.broadleafcommerce.common.extension.cache.key.ContextKeyGen getContentResolverCacheByItemNameIn()
-