*/
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 {
SubscriptionItem si = null;
Publisher pub = subscriber.getPublisher();
NotificationsHandler notifHandler = getNotificationsHandler(pub);
// do not create subscription item when deleted
if (isPublisherValid(pub)) {
if (isLogDebugEnabled()) logDebug("NotifHandler: " + notifHandler.getClass().getName() + " compareDate: " + latestEmailed.toString() + " now: " + new Date().toString(), null);
SubscriptionInfo subsInfo = notifHandler.createSubscriptionInfo(subscriber, locale, latestEmailed);
if (subsInfo.hasNews()) {
String title = getFormatedTitle(subsInfo, subscriber, locale, mimeTypeTitle);
String itemLink = null;
if(subsInfo.getCustomUrl() != null) {
itemLink = subsInfo.getCustomUrl();
}
if(itemLink == null && pub.getBusinessPath() != null) {
itemLink = NotificationHelper.getURLFromBusinessPathString(pub, pub.getBusinessPath());
}
String description = subsInfo.getSpecificInfo(mimeTypeContent, locale);
si = new SubscriptionItem(title, itemLink, description);
}
}
return si;
} catch (Exception e) {
log.error("Cannot generate a subscription item.", e);