Class DuplicateContentsManager
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.cms.duplicate.contents.DuplicateContentsManager
-
- All Implemented Interfaces:
LogEnabled
,Component
,Configurable
,Serviceable
- Direct Known Subclasses:
DuplicateContentsManager
public class DuplicateContentsManager extends AbstractLogEnabled implements Component, Serviceable, Configurable
Component able to detect duplicates (and near duplicates) for a given content.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DuplicateContentsManager.Status
The status of the query
-
Field Summary
Fields Modifier and Type Field Description protected ContentHelper
_contentHelper
The content helperprotected ContentSearcherFactory
_contentSearcherFactory
The content searcher factory.protected DuplicateContentConfiguration
_duplicateContentConfiguration
The duplicate content descriptionstatic String
DUPLICATE_CONTENTS_KEY
key for duplicate contents liststatic String
NEAR_DUPLICATE_CONTENTS_KEY
key for near duplicate contents liststatic String
NO_DUPLICATE_CONTENTS_CONTENT_TYPE_KEY
key for boolean to know whether there are some content types or notstatic String
ROLE
The component role.static String
STATUS_KEY
key for boolean to know the query status
-
Constructor Summary
Constructors Constructor Description DuplicateContentsManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Set<String>
_addDuplicatesContentTypes(String[] contentTypeIds)
Get the configured duplicates content typesprotected List<Pair<String,List<Object>>>
_getConfigurationErrors()
Get the list of configuration errorsprotected List<Pair<String,List<Object>>>
_getConfigurationWarns()
Get the list of configuration warnsprotected AmetysObjectIterable<Content>
_getContents(Collection<String> contentTypes)
Retrieves indexed contents that have at least one of the listed content typesprotected List<Content>
_getDuplicates(Content content, Set<DuplicateContentTypeConfiguration> duplicateContentTypeConfigurations, boolean nearDuplicates, String[] contentTypes)
Get the list of duplicatesprotected List<Query>
_getDuplicatesQueries(Content content, Set<DuplicateContentTypeConfiguration> duplicateContentTypeConfigurations, boolean nearDuplicates, String[] contentTypes)
Get the list of queries to search for duplicatesvoid
configure(Configuration configuration)
Set<String>
getContentTypeIds()
Get the content types setboolean
hasConfigurationErrors()
Returnstrue
if there is at least one configuration errorvoid
logConfigurationErrors(org.slf4j.Logger logger)
Log all errors of the configurationMap<String,Object>
searchDuplicates()
Get the data about duplicates and near duplicates for all contents that match the content types included in the configurationMap<String,Object>
searchDuplicates(Iterable<Content> contents)
Get the data about duplicates and near duplicates for a list of contentsMap<String,Object>
searchDuplicates(Content content)
Get the data about duplicates and near duplicated for a given contentvoid
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
DUPLICATE_CONTENTS_KEY
public static final String DUPLICATE_CONTENTS_KEY
key for duplicate contents list- See Also:
- Constant Field Values
-
NEAR_DUPLICATE_CONTENTS_KEY
public static final String NEAR_DUPLICATE_CONTENTS_KEY
key for near duplicate contents list- See Also:
- Constant Field Values
-
NO_DUPLICATE_CONTENTS_CONTENT_TYPE_KEY
public static final String NO_DUPLICATE_CONTENTS_CONTENT_TYPE_KEY
key for boolean to know whether there are some content types or not- See Also:
- Constant Field Values
-
STATUS_KEY
public static final String STATUS_KEY
key for boolean to know the query status- See Also:
- Constant Field Values
-
_contentSearcherFactory
protected ContentSearcherFactory _contentSearcherFactory
The content searcher factory.
-
_contentHelper
protected ContentHelper _contentHelper
The content helper
-
_duplicateContentConfiguration
protected DuplicateContentConfiguration _duplicateContentConfiguration
The duplicate content description
-
-
Constructor Detail
-
DuplicateContentsManager
public DuplicateContentsManager()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
searchDuplicates
public Map<String,Object> searchDuplicates(Content content)
Get the data about duplicates and near duplicated for a given content- Parameters:
content
- The content- Returns:
- A map of data. key "duplicates" contains a list of the duplicates (id and label for each entry), and key "nearDuplicates" contains the near duplicates if requested (duplicates excluded).
-
searchDuplicates
public Map<String,Object> searchDuplicates()
Get the data about duplicates and near duplicates for all contents that match the content types included in the configuration- Returns:
- the data about duplicates and near duplicates
-
searchDuplicates
public Map<String,Object> searchDuplicates(Iterable<Content> contents)
Get the data about duplicates and near duplicates for a list of contents- Parameters:
contents
- the contents to check- Returns:
- the data about duplicates and near duplicates
-
_getDuplicates
protected List<Content> _getDuplicates(Content content, Set<DuplicateContentTypeConfiguration> duplicateContentTypeConfigurations, boolean nearDuplicates, String[] contentTypes) throws Exception
Get the list of duplicates- Parameters:
content
- The contentduplicateContentTypeConfigurations
- the attribute listnearDuplicates
- true to check for near duplicatescontentTypes
- the content types- Returns:
- list of duplicates
- Throws:
Exception
- if a problem occurs while searching for duplicates
-
_getDuplicatesQueries
protected List<Query> _getDuplicatesQueries(Content content, Set<DuplicateContentTypeConfiguration> duplicateContentTypeConfigurations, boolean nearDuplicates, String[] contentTypes)
Get the list of queries to search for duplicates- Parameters:
content
- The contentduplicateContentTypeConfigurations
- the attribute listnearDuplicates
- true to check for near duplicatescontentTypes
- the content types- Returns:
- list of duplicates
-
_addDuplicatesContentTypes
protected Set<String> _addDuplicatesContentTypes(String[] contentTypeIds)
Get the configured duplicates content types- Parameters:
contentTypeIds
- The content type identifiers for which duplicates content types should be found- Returns:
- the duplicate content types
-
_getContents
protected AmetysObjectIterable<Content> _getContents(Collection<String> contentTypes)
Retrieves indexed contents that have at least one of the listed content types- Parameters:
contentTypes
- The desired content types- Returns:
- solr query results
-
_getConfigurationErrors
protected List<Pair<String,List<Object>>> _getConfigurationErrors()
Get the list of configuration errors- Returns:
- the configuration error list
-
_getConfigurationWarns
protected List<Pair<String,List<Object>>> _getConfigurationWarns()
Get the list of configuration warns- Returns:
- the configuration warn list
-
getContentTypeIds
public Set<String> getContentTypeIds()
Get the content types set- Returns:
- the content types set
-
logConfigurationErrors
public void logConfigurationErrors(org.slf4j.Logger logger)
Log all errors of the configuration- Parameters:
logger
- the logger
-
hasConfigurationErrors
public boolean hasConfigurationErrors()
Returnstrue
if there is at least one configuration error- Returns:
true
if there is at least one configuration error
-
-