Search in sources :

Example 1 with UserIterator

use of com.xpn.xwiki.internal.plugin.rightsmanager.UserIterator in project xwiki-platform by xwiki.

the class WatchListEventMimeMessageFactory method createMessage.

@Override
public Iterator<MimeMessage> createMessage(Object sourceObject, Map<String, Object> parameters) throws MessagingException {
    Map<String, Object> source = getTypedSource(sourceObject, Map.class);
    validateParameters(parameters, HINT_PARAMETER, TEMPLATE_PARAMETER, PARAMETERS_PARAMETER);
    // Extract from the passed parameters the MimeMessageFactory to use to create a single mail
    String factoryHint = (String) parameters.get(HINT_PARAMETER);
    // TODO: is this configurable or should we always use "template" instead?
    MimeMessageFactory factory = getInternalMimeMessageFactory(factoryHint);
    // Parse the source.
    EventsAndSubscribersSource sourceData = EventsAndSubscribersSource.parse(source);
    // UserDataExtractor to be used for each subscriber.
    WatchListMessageDataExtractor userDataExtractor = new WatchListMessageDataExtractor(sourceData, parameters, eventMatcher, execution, explicitDocumentReferenceResolver);
    // The iterator that will be checking each subscriber and that will extract the WatchListMessageData.
    UserIterator<WatchListMessageData> userIterator = new UserIterator<WatchListMessageData>(EventsAndSubscribersSource.parse(source).getSubscribers(), null, userDataExtractor, explicitDocumentReferenceResolver, execution);
    // The iterator that will be producing a MimeMessage for each WatchListMessageData produced by the userIterator.
    WatchListEventMimeMessageIterator messageIterator = new WatchListEventMimeMessageIterator(userIterator, factory, parameters, avatarExtractor, serializer, sessionFactory);
    return messageIterator;
}
Also used : MimeMessageFactory(org.xwiki.mail.MimeMessageFactory) AbstractIteratorMimeMessageFactory(org.xwiki.mail.internal.factory.AbstractIteratorMimeMessageFactory) UserIterator(com.xpn.xwiki.internal.plugin.rightsmanager.UserIterator)

Aggregations

UserIterator (com.xpn.xwiki.internal.plugin.rightsmanager.UserIterator)1 MimeMessageFactory (org.xwiki.mail.MimeMessageFactory)1 AbstractIteratorMimeMessageFactory (org.xwiki.mail.internal.factory.AbstractIteratorMimeMessageFactory)1