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
public class DefaultWebContentFilter extends DefaultContentFilter implements WebContentFilter
This is the default implementation of aWebContentFilter
. The filter's property are set by setter function and constructor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
DefaultWebContentFilter.ContentComparator
Compares two contents based on a given list of sort criteria.class
DefaultWebContentFilter.DefaultFilterSearchContext
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
Fields Modifier and Type Field Description protected WebContentFilter.AccessLimitation
_accessLimitation
The access limitationprotected I18nizableText
_description
The descriptionprotected org.slf4j.Logger
_logger
The loggerprotected boolean
_maskOrphan
The mask orphan contents propertyprotected List<WebContentFilter.FilterSearchContext>
_searchContexts
The search contexts.protected SiteManager
_siteManager
The site managerprotected TagProviderExtensionPoint
_tagProviderEP
The tag providerprotected I18nizableText
_title
The title-
Fields inherited from class org.ametys.cms.filter.DefaultContentFilter
_additionalFilterExpression, _contentTypeEP, _contentTypes, _contextLang, _id, _length, _metadata, _metadataCondition, _resolver, _sortCriteria, _srcResolver, _viewName
-
-
Constructor Summary
Constructors Constructor Description DefaultWebContentFilter()
ConstructorDefaultWebContentFilter(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static String
_encode(String path)
void
addMetadata(String metadataId, String value)
Add a metadata filterWebContentFilter.FilterSearchContext
addSearchContext()
Add a search context.protected WebContentFilter.FilterSearchContext
createSeachContext()
Create a search context.WebContentFilter.AccessLimitation
getAccessLimitation()
Determines the access limitation policy.ContentFilter.ContextLanguage
getContextLanguage()
Get the context languageI18nizableText
getDescription()
Get the filter's descriptionprotected Expression
getFilterExpression(String siteName, WebContentFilter.FilterSearchContext filterContext)
Get the filter expression for a given search context.AmetysObjectIterable<Content>
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.List<WebContentFilter.FilterSearchContext>
getSearchContexts()
Get the list of search contexts.I18nizableText
getTitle()
Get the filter's titleString
getXPathQuery(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
maskOrphanContents()
Determines if orphan contents must be maskedvoid
setAccessLimitation(WebContentFilter.AccessLimitation limitation)
Set the access limitation policy.void
setContextLanguage(ContentFilter.ContextLanguage context)
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 title-
Methods 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 Detail
-
_searchContexts
protected List<WebContentFilter.FilterSearchContext> _searchContexts
The search contexts.
-
_maskOrphan
protected boolean _maskOrphan
The mask orphan contents property
-
_accessLimitation
protected WebContentFilter.AccessLimitation _accessLimitation
The access limitation
-
_title
protected I18nizableText _title
The title
-
_description
protected I18nizableText _description
The description
-
_logger
protected org.slf4j.Logger _logger
The logger
-
_siteManager
protected SiteManager _siteManager
The site manager
-
_tagProviderEP
protected TagProviderExtensionPoint _tagProviderEP
The tag provider
-
-
Constructor Detail
-
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 Detail
-
getTitle
public I18nizableText getTitle()
Description copied from interface:WebContentFilter
Get the filter's title- Specified by:
getTitle
in interfaceWebContentFilter
- Returns:
- The filter's title
-
setTitle
public void setTitle(I18nizableText title)
Description copied from interface:WebContentFilter
Set the filter's title- Specified by:
setTitle
in interfaceWebContentFilter
- Parameters:
title
- The title to set
-
getDescription
public I18nizableText getDescription()
Description copied from interface:WebContentFilter
Get the filter's description- Specified by:
getDescription
in interfaceWebContentFilter
- Returns:
- the filter's description
-
setDescription
public void setDescription(I18nizableText description)
Description copied from interface:WebContentFilter
Set the filter's description- Specified by:
setDescription
in interfaceWebContentFilter
- Parameters:
description
- The description to set
-
getContextLanguage
public ContentFilter.ContextLanguage getContextLanguage()
Description copied from interface:ContentFilter
Get the context language- Specified by:
getContextLanguage
in interfaceContentFilter
- Overrides:
getContextLanguage
in classDefaultContentFilter
- Returns:
- The context language
-
setContextLanguage
public void setContextLanguage(ContentFilter.ContextLanguage context)
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
public void addMetadata(String metadataId, String value)
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
public List<WebContentFilter.FilterSearchContext> getSearchContexts()
Description copied from interface:WebContentFilter
Get the list of search contexts.- Specified by:
getSearchContexts
in interfaceWebContentFilter
- Returns:
- the list of search contexts.
-
addSearchContext
public WebContentFilter.FilterSearchContext addSearchContext()
Description copied from interface:WebContentFilter
Add a search context.- Specified by:
addSearchContext
in interfaceWebContentFilter
- Returns:
- the created search context.
-
createSeachContext
protected WebContentFilter.FilterSearchContext createSeachContext()
Create a search context.- Returns:
- the created search context.
-
setMaskOrphanContents
public void setMaskOrphanContents(boolean mask)
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
public boolean 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
public WebContentFilter.AccessLimitation getAccessLimitation()
Description copied from interface:WebContentFilter
Determines the access limitation policy.- Specified by:
getAccessLimitation
in interfaceWebContentFilter
- Returns:
- the access limitation policy.
-
setAccessLimitation
public void setAccessLimitation(WebContentFilter.AccessLimitation limitation)
Description copied from interface:WebContentFilter
Set the access limitation policy.- Specified by:
setAccessLimitation
in interfaceWebContentFilter
- Parameters:
limitation
- the access limitation policy to set.
-
getMatchingContents
public AmetysObjectIterable<Content> getMatchingContents(String siteName, String lang, Page page)
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:
ContentFilterHelper.isContentValid(Content, Page, ContentFilter)
-
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.
-
-