Class ContentConsistencyManager
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.cms.content.consistency.ContentConsistencyManager
- All Implemented Interfaces:
LogEnabled
,Initializable
,Component
,Contextualizable
,Serviceable
- Direct Known Subclasses:
ContentConsistencyManager
public class ContentConsistencyManager
extends AbstractLogEnabled
implements Initializable, Contextualizable, Serviceable, Component
Manage all operation related to checking the consistency of a content
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
Record holding the results of a consistency checks on multiple contentsstatic class
Expression which tests if contents have consistency informations. -
Field Summary
Modifier and TypeFieldDescriptionprotected ConsistencyChecker
The consistency checkerprotected AmetysObjectResolver
The ametys object resolver.static final String
The avalon role -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription_checkContents
(AmetysObjectIterable<Content> contents) Check all the content provided by the iterable for broken links.protected AmetysObjectIterable<Content>
_getContents
(Expression filterExpression) Get the contents with inconsistency information.Check all contents to see if there references are consistent.void
contextualize
(Context context) void
protected void
removeOutdatedResult
(ZonedDateTime date, Expression filterExpression) Remove results older than a given dateresultToJSON
(ContentConsistencyResult result, List<Map<String, Object>> columns) Serialize a content consistency result as JSONvoid
service
(ServiceManager manager) protected ContentConsistencyResult
storeResult
(WorkflowAwareContent content, int successCount, int unknownCount, int unauthorizedCount, int notFoundCount, int serverErrorCount) Store the result of the consistency check done on the contentMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The avalon role -
_resolver
The ametys object resolver. -
_consistencyChecker
The consistency checker
-
-
Constructor Details
-
ContentConsistencyManager
public ContentConsistencyManager()
-
-
Method Details
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
checkAllContents
Check all contents to see if there references are consistent. All result will also be stored in the consistency result database table for later access.- Returns:
- record describing the results of the checks
-
removeOutdatedResult
Remove results older than a given date- Parameters:
date
- the thresholdfilterExpression
- an expression to filter the content to consider, null to consider all contents
-
_checkContents
protected ContentConsistencyManager.ConsistenciesReport _checkContents(AmetysObjectIterable<Content> contents) Check all the content provided by the iterable for broken links. This method will actually provideCallable
to anExecutor
that parallelize the checks.- Parameters:
contents
- an iterable of contents to check- Returns:
- record describing the results of the checks
-
storeResult
protected ContentConsistencyResult storeResult(WorkflowAwareContent content, int successCount, int unknownCount, int unauthorizedCount, int notFoundCount, int serverErrorCount) Store the result of the consistency check done on the content- Parameters:
content
- the content checkedsuccessCount
- the number of successunknownCount
- the number of unknownunauthorizedCount
- the number of unauthorizednotFoundCount
- the number of not foundserverErrorCount
- the number of server error- Returns:
- the result
-
_getContents
Get the contents with inconsistency information.- Parameters:
filterExpression
- an expression to filter content to check, or null to check all contents- Returns:
- an iterator on contents.
-
resultToJSON
public Map<String,Object> resultToJSON(ContentConsistencyResult result, List<Map<String, Object>> columns) Serialize a content consistency result as JSON- Parameters:
result
- the results to serializecolumns
- the list of columns to use as "view"- Returns:
- a JSON representation of the result
-