use of org.olat.core.commons.services.notifications.NotificationsHandler in project openolat by klemens.
the class NotificationsPortletRunController method getAllPortletEntries.
private List<PortletEntry<Subscriber>> getAllPortletEntries() {
notificationsList = man.getValidSubscribers(getIdentity());
// calc subscriptioninfo for all subscriptions and, if only those with news are to be shown, remove the other ones
for (Iterator<Subscriber> it_subs = notificationsList.iterator(); it_subs.hasNext(); ) {
Subscriber subscriber = it_subs.next();
Publisher pub = subscriber.getPublisher();
NotificationsHandler notifHandler = man.getNotificationsHandler(pub);
if (notifHandler == null) {
it_subs.remove();
} else {
SubscriptionInfo subsInfo = notifHandler.createSubscriptionInfo(subscriber, getLocale(), compareDate);
if (!subsInfo.hasNews()) {
it_subs.remove();
}
}
}
return convertNotificationToPortletEntryList(notificationsList);
}
use of org.olat.core.commons.services.notifications.NotificationsHandler in project openolat by klemens.
the class NotificationsManagerImpl method createSubscriptionItem.
/**
* @param subscriber
* @param locale
* @param mimeType
* @param latestEmailed needs to be given! SubscriptionInfo is collected from then until latestNews of publisher
* @return null if the publisher is not valid anymore (deleted), or if there are no news
*/
@Override
public SubscriptionItem createSubscriptionItem(Subscriber subscriber, Locale locale, String mimeTypeTitle, String mimeTypeContent, Date latestEmailed) {
if (latestEmailed == null)
throw new AssertException("compareDate may not be null, use a date from history");
try {
boolean debug = isLogDebugEnabled();
SubscriptionItem si = null;
Publisher pub = subscriber.getPublisher();
NotificationsHandler notifHandler = getNotificationsHandler(pub);
if (debug)
logDebug("create subscription with handler: " + notifHandler.getClass().getName());
// do not create subscription item when deleted
if (isPublisherValid(pub) && notifHandler != null) {
if (debug)
logDebug("NotifHandler: " + notifHandler.getClass().getName() + " compareDate: " + latestEmailed.toString() + " now: " + new Date().toString(), null);
SubscriptionInfo subsInfo = notifHandler.createSubscriptionInfo(subscriber, locale, latestEmailed);
if (subsInfo.hasNews()) {
si = createSubscriptionItem(subsInfo, subscriber, locale, mimeTypeTitle, mimeTypeContent);
}
}
return si;
} catch (Exception e) {
log.error("Cannot generate a subscription item.", e);
return null;
}
}
Aggregations