public class AutomaticNewslettersEngine extends Object implements Runnable
| Modifier and Type | Field and Description | 
|---|---|
protected AutomaticNewsletterExtensionPoint | 
_autoNewsletterEP
The automatic newsletter extension point. 
 | 
protected CategoryProviderExtensionPoint | 
_categoryEP
The newsletter category provider extension point. 
 | 
protected ContentFilterExtensionPoint | 
_contentFilterEP
The content filter extension point. 
 | 
protected ContentFilterHelper | 
_contentFilterHelper
The content filter helper. 
 | 
protected Context | 
_context
The avalon context. 
 | 
protected Context | 
_environmentContext
The cocoon environment context. 
 | 
protected Map<String,List<String>> | 
_filterContentIdCache
A map of the content IDs by filter, reset on each run. 
 | 
protected I18nUtils | 
_i18nUtils
The i18n utils. 
 | 
protected boolean | 
_initialized
Is the engine initialized ? 
 | 
protected static Logger | 
_LOGGER
The logger. 
 | 
protected ServiceManager | 
_manager
The service manager. 
 | 
protected static String | 
_NEWSLETTER_CONTENT_TYPE
The newsletter content type. 
 | 
protected AmetysObjectResolver | 
_resolver
The ametys object resolver. 
 | 
protected Date | 
_runDate
The instant the engine was started. 
 | 
protected SiteManager | 
_siteManager
The site manager. 
 | 
protected int | 
_wfInitialActionId
The workflow initial action ID. 
 | 
protected List<Integer> | 
_wfValidateActionIds
A list of action IDs to validate a newsletter from initial step. 
 | 
protected String | 
_workflowName
The newsletter workflow name. 
 | 
protected WorkflowProvider | 
_workflowProvider
The workflow provider. 
 | 
| Constructor and Description | 
|---|
AutomaticNewslettersEngine()  | 
| Modifier and Type | Method and Description | 
|---|---|
protected void | 
checkInitialization()
Check the initialization and throw an exception if not initialized. 
 | 
void | 
configure(Configuration configuration)
Configure the engine (to be called by the scheduler or the action). 
 | 
protected void | 
createAndValidateAutomaticNewsletter(String siteName,
                                    String sitemapName,
                                    Category category,
                                    CategoryProvider provider,
                                    AutomaticNewsletter autoNewsletter)
Create an automatic newsletter content in a category. 
 | 
protected void | 
createAutomaticNewsletters()
Launch the creation process for each site and sitemap. 
 | 
protected void | 
createAutomaticNewsletters(String siteName,
                          String sitemapName)
Test each category in a site and sitemap and launch the newsletter creation if needed. 
 | 
protected WorkflowAwareContent | 
createNewsletterContent(String siteName,
                       String language,
                       Category category,
                       AutomaticNewsletter autoNewsletter,
                       long newsletterNumber,
                       Map<String,AutomaticNewsletterFilterResult> filterResults)
Create the newsletter content. 
 | 
protected boolean | 
createNow(AutomaticNewsletter autoNewsletter)
Test if an automatic newsletter content has to be created now. 
 | 
protected void | 
dispose()
Dispose of the resources and looked-up components. 
 | 
protected Map<String,AutomaticNewsletterFilterResult> | 
getFilterResults(String siteName,
                String sitemapName,
                AutomaticNewsletter autoNewsletter)
Get the list of contents for the automatic newsletter filters. 
 | 
protected String | 
getNewsletterTitle(String language,
                  Category category,
                  AutomaticNewsletter autoNewsletter,
                  long newsletterNumber)
Compute the newsletter title. 
 | 
protected long | 
getNextNumber(Category category,
             CategoryProvider provider,
             String siteName,
             String language)
Compute the newsletter number. 
 | 
protected boolean | 
hasResults(Collection<AutomaticNewsletterFilterResult> results)
Test if there is at least one content in a collection of filter results. 
 | 
void | 
initialize(ServiceManager manager,
          Context context)
Initialize the engine. 
 | 
void | 
run()  | 
protected boolean | 
testMonth(Collection<Integer> dayNumbers,
         DateTime runDate)
Test if we are in the configured month creation period. 
 | 
protected boolean | 
testWeek(Collection<Integer> dayNumbers,
        DateTime runDate)
Test if we are in the configured week creation period. 
 | 
protected void | 
validateNewsletter(WorkflowAwareContent newsletterContent)
Validate the newly created newsletter. 
 | 
protected static final String _NEWSLETTER_CONTENT_TYPE
protected ServiceManager _manager
protected boolean _initialized
protected String _workflowName
protected int _wfInitialActionId
protected List<Integer> _wfValidateActionIds
protected Map<String,List<String>> _filterContentIdCache
protected Context _environmentContext
protected AmetysObjectResolver _resolver
protected SiteManager _siteManager
protected WorkflowProvider _workflowProvider
protected AutomaticNewsletterExtensionPoint _autoNewsletterEP
protected CategoryProviderExtensionPoint _categoryEP
protected ContentFilterExtensionPoint _contentFilterEP
protected ContentFilterHelper _contentFilterHelper
protected I18nUtils _i18nUtils
public AutomaticNewslettersEngine()
public void initialize(ServiceManager manager, Context context) throws ContextException, ServiceException
manager - the avalon service manager.context - the avalon context.ContextException - if an error occurredServiceException - if an error occurredpublic void configure(Configuration configuration) throws ConfigurationException
configuration - the component configuration.ConfigurationException - if an error occurs in the configuration.protected void checkInitialization()
protected void dispose()
protected void createAutomaticNewsletters()
protected void createAutomaticNewsletters(String siteName, String sitemapName)
siteName - the site name.sitemapName - the sitemap name.protected void createAndValidateAutomaticNewsletter(String siteName, String sitemapName, Category category, CategoryProvider provider, AutomaticNewsletter autoNewsletter)
sitemapName - the sitemap name.siteName - the site name.category - the newsletter category.provider - the category provider.autoNewsletter - the associated automatic newsletter.protected Map<String,AutomaticNewsletterFilterResult> getFilterResults(String siteName, String sitemapName, AutomaticNewsletter autoNewsletter)
siteName - the site name.sitemapName - the sitemap name.autoNewsletter - the automatic newsletter.protected WorkflowAwareContent createNewsletterContent(String siteName, String language, Category category, AutomaticNewsletter autoNewsletter, long newsletterNumber, Map<String,AutomaticNewsletterFilterResult> filterResults) throws com.opensymphony.workflow.WorkflowException
siteName - the site name.language - the language.category - the category.autoNewsletter - the automatic newsletter.newsletterNumber - the newsletter number.filterResults - the filter results (content IDs for each filter).com.opensymphony.workflow.WorkflowException - if a workflow error occurs.protected void validateNewsletter(WorkflowAwareContent newsletterContent) throws com.opensymphony.workflow.WorkflowException
newsletterContent - the newsletter content, must be in draft state.com.opensymphony.workflow.WorkflowException - if a workflow error occurs.protected String getNewsletterTitle(String language, Category category, AutomaticNewsletter autoNewsletter, long newsletterNumber)
language - the language.category - the newsletter category.autoNewsletter - the automatic newsletter.newsletterNumber - the newsletter number.protected long getNextNumber(Category category, CategoryProvider provider, String siteName, String language)
category - the newsletter category.provider - the category provider.siteName - the site name.language - the language.protected boolean hasResults(Collection<AutomaticNewsletterFilterResult> results)
results - a collection of filter results.protected boolean createNow(AutomaticNewsletter autoNewsletter)
autoNewsletter - the automatic newsletter.protected boolean testMonth(Collection<Integer> dayNumbers, DateTime runDate)
dayNumbers - the days in the month on which a newsletter is to be created.runDate - the instant the engine was launched.protected boolean testWeek(Collection<Integer> dayNumbers, DateTime runDate)
dayNumbers - the days in the month on which a newsletter is to be created.runDate - the instant the engine was launched.