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;
}
Aggregations