Search in sources :

Example 1 with NotificationConfiguration

use of org.xwiki.notifications.NotificationConfiguration in project xwiki-platform by xwiki.

the class NotificationEmailJob method executeJob.

@Override
protected void executeJob(JobExecutionContext jobContext) throws JobExecutionException {
    NotificationConfiguration configuration = Utils.getComponent(NotificationConfiguration.class);
    if (!configuration.isEnabled() || !configuration.areEmailsEnabled()) {
        // do nothing
        return;
    }
    DocumentReference schedulerJobDocument = getSchedulerJobDocument(jobContext);
    BaseObjectReference emailJobObjectReference = getNotificationEmailJobObjectReference(schedulerJobDocument);
    NotificationUserIterator userIterator = Utils.getComponent(NotificationUserIterator.class);
    userIterator.initialize(getJobInterval(schedulerJobDocument));
    NotificationEmailSender mailSender = Utils.getComponent(NotificationEmailSender.class);
    mailSender.sendEmails(getPreviousFireTime(emailJobObjectReference), userIterator);
    setPreviousFireTime(emailJobObjectReference);
}
Also used : BaseObjectReference(com.xpn.xwiki.objects.BaseObjectReference) NotificationConfiguration(org.xwiki.notifications.NotificationConfiguration) DocumentReference(org.xwiki.model.reference.DocumentReference)

Aggregations

BaseObjectReference (com.xpn.xwiki.objects.BaseObjectReference)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 NotificationConfiguration (org.xwiki.notifications.NotificationConfiguration)1