Package org.ametys.web.filter
Class DefaultWebContentFilter
java.lang.Object
org.ametys.cms.filter.DefaultContentFilter
org.ametys.web.filter.DefaultWebContentFilter
- All Implemented Interfaces:
ContentFilter
,WebContentFilter
- Direct Known Subclasses:
PostFilter
,StaticWebContentFilter
This is the default implementation of a
WebContentFilter
. The filter's property are set by setter function and constructor-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
Compares two contents based on a given list of sort criteria.class
Default implementation of a filter search context.Nested classes/interfaces inherited from interface org.ametys.cms.filter.ContentFilter
ContentFilter.Condition, ContentFilter.ContextLanguage
Nested classes/interfaces inherited from interface org.ametys.web.filter.WebContentFilter
WebContentFilter.AccessLimitation, WebContentFilter.Context, WebContentFilter.FilterSearchContext
-
Field Summary
Modifier and TypeFieldDescriptionprotected WebContentFilter.AccessLimitation
The access limitationprotected I18nizableText
The descriptionprotected Logger
The loggerprotected boolean
The mask orphan contents propertyprotected List<WebContentFilter.FilterSearchContext>
The search contexts.protected SiteManager
The site managerprotected TagProviderExtensionPoint
The tag providerprotected I18nizableText
The titleFields inherited from class org.ametys.cms.filter.DefaultContentFilter
_additionalFilterExpression, _contentTypeEP, _contentTypes, _contextLang, _id, _length, _metadata, _metadataCondition, _resolver, _sortCriteria, _srcResolver, _viewName
-
Constructor Summary
ConstructorDescriptionConstructorDefaultWebContentFilter
(String id, AmetysObjectResolver resolver, ContentTypeExtensionPoint contentTypeExtensionPoint, SiteManager siteManager, TagProviderExtensionPoint tagProviderEP) Creates a new filterDefaultWebContentFilter
(String id, DefaultWebContentFilter originalFilter, AmetysObjectResolver resolver, ContentTypeExtensionPoint contentTypeExtensionPoint, SiteManager siteManager, TagProviderExtensionPoint tagProviderEP) Creates a new filter from copy of another -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMetadata
(String metadataId, String value) Add a metadata filterAdd a search context.protected WebContentFilter.FilterSearchContext
Create a search context.Determines the access limitation policy.Get the context languageGet the filter's descriptionprotected Expression
getFilterExpression
(String siteName, WebContentFilter.FilterSearchContext filterContext) Get the filter expression for a given search context.getMatchingContents
(String siteName, String lang, Page page) Get the contents matching this filter.<br/> In most cases, the results will need to be re-filtered by theContentFilterHelper.isContentValid(org.ametys.cms.repository.Content, org.ametys.web.repository.page.Page, org.ametys.cms.filter.ContentFilter)
method.protected AmetysObjectIterable<Content>
getMatchingContents
(String siteName, String lang, Page page, WebContentFilter.FilterSearchContext filterContext) Get the matching contents for the given search context.Get the list of search contexts.getTitle()
Get the filter's titlegetXPathQuery
(String siteName, String lang, WebContentFilter.FilterSearchContext filterContext) Creates the XPath query corresponding to this filter.protected String
getXPathQuery
(String siteName, Page page, int depth, WebContentFilter.FilterSearchContext filterContext) boolean
Determines if orphan contents must be maskedvoid
setAccessLimitation
(WebContentFilter.AccessLimitation limitation) Set the access limitation policy.void
Set the context languagevoid
setDescription
(I18nizableText description) Set the filter's descriptionvoid
setMaskOrphanContents
(boolean mask) Set if orphan contents must be maskedvoid
setTitle
(I18nizableText title) Set the filter's titleMethods inherited from class org.ametys.cms.filter.DefaultContentFilter
addContentType, addSortCriteria, getAdditionalFilterExpression, getContentTypes, getContentTypesExpression, getContextLanguagesExpression, getFilterExpression, getId, getLength, getMatchingContents, getMatchingContents, getMetadataCondition, getMetadataExpression, getMetadataValues, getSortCriteria, getView, getXPathQuery, getXPathQuery, setAdditionalFilterExpression, setId, setLength, setMetadataCondition, setResolver, setView
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ametys.cms.filter.ContentFilter
addContentType, addSortCriteria, getAdditionalFilterExpression, getContentTypes, getId, getLength, getMatchingContents, getMatchingContents, getMetadataCondition, getMetadataValues, getSortCriteria, getView, setAdditionalFilterExpression, setId, setLength, setMetadataCondition, setResolver, setView
-
Field Details
-
_searchContexts
The search contexts. -
_maskOrphan
The mask orphan contents property -
_accessLimitation
The access limitation -
_title
The title -
_description
The description -
_logger
The logger -
_siteManager
The site manager -
_tagProviderEP
The tag provider
-
-
Constructor Details
-
DefaultWebContentFilter
public DefaultWebContentFilter()Constructor -
DefaultWebContentFilter
public DefaultWebContentFilter(String id, AmetysObjectResolver resolver, ContentTypeExtensionPoint contentTypeExtensionPoint, SiteManager siteManager, TagProviderExtensionPoint tagProviderEP) Creates a new filter- Parameters:
id
- The filter unique identifierresolver
- The ametys object resolvercontentTypeExtensionPoint
- The extension point for content typessiteManager
- The site managertagProviderEP
- The tag provider
-
DefaultWebContentFilter
public DefaultWebContentFilter(String id, DefaultWebContentFilter originalFilter, AmetysObjectResolver resolver, ContentTypeExtensionPoint contentTypeExtensionPoint, SiteManager siteManager, TagProviderExtensionPoint tagProviderEP) Creates a new filter from copy of another- Parameters:
id
- The filter unique identifieroriginalFilter
- The original filter to be copiedresolver
- The ametys object resolvercontentTypeExtensionPoint
- The extension point for content typessiteManager
- The site managertagProviderEP
- The tag provider
-
-
Method Details
-
getTitle
Description copied from interface:WebContentFilter
Get the filter's title- Specified by:
getTitle
in interfaceWebContentFilter
- Returns:
- The filter's title
-
setTitle
Description copied from interface:WebContentFilter
Set the filter's title- Specified by:
setTitle
in interfaceWebContentFilter
- Parameters:
title
- The title to set
-
getDescription
Description copied from interface:WebContentFilter
Get the filter's description- Specified by:
getDescription
in interfaceWebContentFilter
- Returns:
- the filter's description
-
setDescription
Description copied from interface:WebContentFilter
Set the filter's description- Specified by:
setDescription
in interfaceWebContentFilter
- Parameters:
description
- The description to set
-
getContextLanguage
Description copied from interface:ContentFilter
Get the context language- Specified by:
getContextLanguage
in interfaceContentFilter
- Overrides:
getContextLanguage
in classDefaultContentFilter
- Returns:
- The context language
-
setContextLanguage
Description copied from interface:ContentFilter
Set the context language- Specified by:
setContextLanguage
in interfaceContentFilter
- Overrides:
setContextLanguage
in classDefaultContentFilter
- Parameters:
context
- The context language to set
-
addMetadata
Description copied from interface:ContentFilter
Add a metadata filter- Specified by:
addMetadata
in interfaceContentFilter
- Overrides:
addMetadata
in classDefaultContentFilter
- Parameters:
metadataId
- The metadata id.value
- The value to test. Set null to test existence
-
getSearchContexts
Description copied from interface:WebContentFilter
Get the list of search contexts.- Specified by:
getSearchContexts
in interfaceWebContentFilter
- Returns:
- the list of search contexts.
-
addSearchContext
Description copied from interface:WebContentFilter
Add a search context.- Specified by:
addSearchContext
in interfaceWebContentFilter
- Returns:
- the created search context.
-
createSeachContext
Create a search context.- Returns:
- the created search context.
-
setMaskOrphanContents
Description copied from interface:WebContentFilter
Set if orphan contents must be masked- Specified by:
setMaskOrphanContents
in interfaceWebContentFilter
- Parameters:
mask
- true to mask orphan contents
-
maskOrphanContents
Description copied from interface:WebContentFilter
Determines if orphan contents must be masked- Specified by:
maskOrphanContents
in interfaceWebContentFilter
- Returns:
- true if orphan contents must be masked
-
getAccessLimitation
Description copied from interface:WebContentFilter
Determines the access limitation policy.- Specified by:
getAccessLimitation
in interfaceWebContentFilter
- Returns:
- the access limitation policy.
-
setAccessLimitation
Description copied from interface:WebContentFilter
Set the access limitation policy.- Specified by:
setAccessLimitation
in interfaceWebContentFilter
- Parameters:
limitation
- the access limitation policy to set.
-
getMatchingContents
Description copied from interface:WebContentFilter
Get the contents matching this filter.<br/> In most cases, the results will need to be re-filtered by theContentFilterHelper.isContentValid(org.ametys.cms.repository.Content, org.ametys.web.repository.page.Page, org.ametys.cms.filter.ContentFilter)
method.- Specified by:
getMatchingContents
in interfaceWebContentFilter
- Parameters:
siteName
- The current site name. Can be null.lang
- The current language. Can be null.page
- The current page. Can be null.- Returns:
- The matching contents.
- See Also:
-
getMatchingContents
protected AmetysObjectIterable<Content> getMatchingContents(String siteName, String lang, Page page, WebContentFilter.FilterSearchContext filterContext) Get the matching contents for the given search context.- Parameters:
siteName
- the site name.lang
- the language.page
- the context page.filterContext
- the search context.- Returns:
- An iterable over matching Contents.
-
getXPathQuery
public String getXPathQuery(String siteName, String lang, WebContentFilter.FilterSearchContext filterContext) Creates the XPath query corresponding to this filter.- Parameters:
siteName
- The current site namelang
- The current languagefilterContext
- the filter search context.- Returns:
- the created XPath query
-
getXPathQuery
protected String getXPathQuery(String siteName, Page page, int depth, WebContentFilter.FilterSearchContext filterContext) - Parameters:
siteName
- The current site namepage
- The page where to start the searchdepth
- the search depthfilterContext
- the filter search context.- Returns:
- the created XPath query
-
getFilterExpression
protected Expression getFilterExpression(String siteName, WebContentFilter.FilterSearchContext filterContext) Get the filter expression for a given search context.- Parameters:
siteName
- The current site namefilterContext
- the filter search context.- Returns:
- the filter expression.
-