Class ContentConsistencyEngine
- java.lang.Object
-
- org.ametys.cms.content.consistency.ContentConsistencyEngine
-
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
ContentConsistencyEngine
public class ContentConsistencyEngine extends Object implements Runnable
Content consistency engine: generate consistency information for all contents. Sends a report e-mail if there are inconsistencies.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
ContentConsistencyEngine.ContentExistsHandler
Handler which tests if exists a "/contents/content" tag.
-
Field Summary
Fields Modifier and Type Field Description protected AmetysObjectResolver
_ametysResolver
The ametys object resolver.protected String
_baseUrl
The server base URL.protected Context
_context
The avalon context.protected Context
_environmentContext
The cocoon environment context.protected I18nUtils
_i18nUtils
The i18n utils.protected boolean
_initialized
Is the engine initialized ?protected static org.slf4j.Logger
_LOGGER
The logger.protected static String
_MAIL_RIGHT
The report e-mail will be sent to users who possess this right on the application context.protected String
_mailFrom
The content of "from" field in emails.protected ServiceManager
_manager
The service manager.protected File
_reportDirectory
The report directory.protected RightManager
_rightManager
The rights manager.private static boolean
_RUNNING
protected SourceResolver
_sourceResolver
The avalon source resolver.protected UserManager
_userManager
The users manager.
-
Constructor Summary
Constructors Constructor Description ContentConsistencyEngine()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_checkInitialization()
Check the initialization and throw an exception if not initialized.protected void
_dispose()
Dispose of the resources and looked-up components.protected void
_generateReport()
Generate the full consistency report.protected void
_generateReports()
Send all the alerts.protected Map<String,String>
_getEmailParams()
Get the report e-mail parameters.protected String
_getMailPart(Map<String,String> parameters)
Get a mail part.protected String
_getMailUri(Map<String,String> parameters)
Get the pipeline uri for mail bodyprotected void
_sendErrorEmail()
Send a reminder e-mail to all the users who have the right to edit.protected void
_sendMails(String subject, String body, Set<UserIdentity> users, String from)
Send the alert emails.void
configure(Configuration configuration)
Configure the engine (called by the scheduler).void
initialize(ServiceManager manager, Context context)
Initialize the alert engine.(package private) static boolean
isRunning()
Test if the engine is running at the time.void
run()
private static void
setRunning(boolean running)
-
-
-
Field Detail
-
_LOGGER
protected static final org.slf4j.Logger _LOGGER
The logger.
-
_MAIL_RIGHT
protected static final String _MAIL_RIGHT
The report e-mail will be sent to users who possess this right on the application context.- See Also:
- Constant Field Values
-
_RUNNING
private static boolean _RUNNING
-
_manager
protected ServiceManager _manager
The service manager.
-
_reportDirectory
protected File _reportDirectory
The report directory.
-
_initialized
protected boolean _initialized
Is the engine initialized ?
-
_environmentContext
protected Context _environmentContext
The cocoon environment context.
-
_ametysResolver
protected AmetysObjectResolver _ametysResolver
The ametys object resolver.
-
_sourceResolver
protected SourceResolver _sourceResolver
The avalon source resolver.
-
_rightManager
protected RightManager _rightManager
The rights manager.
-
_userManager
protected UserManager _userManager
The users manager.
-
_i18nUtils
protected I18nUtils _i18nUtils
The i18n utils.
-
-
Constructor Detail
-
ContentConsistencyEngine
public ContentConsistencyEngine()
-
-
Method Detail
-
initialize
public void initialize(ServiceManager manager, Context context) throws ContextException, ServiceException
Initialize the alert engine.- Parameters:
manager
- the avalon service manager.context
- the avalon context.- Throws:
ContextException
- if an error occurs retrieving the environment context.ServiceException
- if an error occurs retrieving a component.
-
configure
public void configure(Configuration configuration) throws ConfigurationException
Configure the engine (called by the scheduler).- Parameters:
configuration
- the component configuration.- Throws:
ConfigurationException
- if an error occurred
-
_checkInitialization
protected void _checkInitialization()
Check the initialization and throw an exception if not initialized.
-
isRunning
static boolean isRunning()
Test if the engine is running at the time.- Returns:
- true if the engine is running, false otherwise.
-
setRunning
private static void setRunning(boolean running)
-
_dispose
protected void _dispose()
Dispose of the resources and looked-up components.
-
_generateReports
protected void _generateReports() throws AmetysRepositoryException, IOException
Send all the alerts. Can be overridden to add alerts.- Throws:
AmetysRepositoryException
- if an error occurs.IOException
- if an error occurred
-
_generateReport
protected void _generateReport() throws IOException
Generate the full consistency report.- Throws:
IOException
- if an i/o error occurs.
-
_sendErrorEmail
protected void _sendErrorEmail() throws IOException
Send a reminder e-mail to all the users who have the right to edit.- Throws:
IOException
- if an error occurs building or sending the mail.
-
_getMailPart
protected String _getMailPart(Map<String,String> parameters) throws IOException
Get a mail part.- Parameters:
parameters
- the pipeline parameters.- Returns:
- the mail part.
- Throws:
IOException
- if an error occurred
-
_getMailUri
protected String _getMailUri(Map<String,String> parameters)
Get the pipeline uri for mail body- Parameters:
parameters
- the mail paramters- Returns:
- a pipeline uri
-
_getEmailParams
protected Map<String,String> _getEmailParams()
Get the report e-mail parameters.- Returns:
- the e-mail parameters.
-
_sendMails
protected void _sendMails(String subject, String body, Set<UserIdentity> users, String from)
Send the alert emails.- Parameters:
subject
- the e-mail subject.body
- the e-mail body.users
- users to send the mail to.from
- the address sending the e-mail.
-
-