use of org.olat.core.commons.services.notifications.model.TitleItem in project OpenOLAT by OpenOLAT.
the class WikiPageChangeOrCreateNotificationHandler method createTitleInfo.
@Override
public String createTitleInfo(Subscriber subscriber, Locale locale) {
try {
Translator translator = Util.createPackageTranslator(WikiPageChangeOrCreateNotificationHandler.class, locale);
TitleItem title = getTitleItem(subscriber.getPublisher(), translator);
return title.getInfoContent("text/plain");
} catch (Exception e) {
log.error("Error while creating assessment notifications for subscriber: " + subscriber.getKey(), e);
checkPublisher(subscriber.getPublisher());
return "-";
}
}
use of org.olat.core.commons.services.notifications.model.TitleItem in project OpenOLAT by OpenOLAT.
the class WikiPageChangeOrCreateNotificationHandler method getTitleItem.
private TitleItem getTitleItem(Publisher p, Translator translator) {
Long resId = p.getResId();
String type = p.getResName();
String title;
if ("BusinessGroup".equals(type)) {
BusinessGroup bg = CoreSpringFactory.getImpl(BusinessGroupService.class).loadBusinessGroup(resId);
title = translator.translate("notifications.header.group", new String[] { bg.getName() });
} else if (CourseModule.getCourseTypeName().equals(type)) {
String displayName = RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(resId);
title = translator.translate("notifications.header.course", new String[] { displayName });
} else {
title = translator.translate("notifications.header");
}
return new TitleItem(title, Wiki.CSS_CLASS_WIKI_ICON);
}
use of org.olat.core.commons.services.notifications.model.TitleItem in project OpenOLAT by OpenOLAT.
the class FeedNotificationsHandler method createSubscriptionInfo.
@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
SubscriptionInfo si;
Publisher p = subscriber.getPublisher();
Date latestNews = p.getLatestNewsDate();
try {
final Translator translator = Util.createPackageTranslator(FeedMainController.class, locale);
if (notificationsManager.isPublisherValid(p) && compareDate.before(latestNews)) {
String title;
try {
RepositoryEntry re = repoManager.lookupRepositoryEntry(OresHelper.createOLATResourceableInstance(p.getResName(), p.getResId()), false);
if (re.getAccess() == RepositoryEntry.DELETED || re.getRepositoryEntryStatus().isClosed() || re.getRepositoryEntryStatus().isUnpublished()) {
return notificationsManager.getNoSubscriptionInfo();
}
String displayName = re.getDisplayname();
if ("CourseModule".equals(p.getResName())) {
ICourse course = CourseFactory.loadCourse(re);
CourseNode node = course.getRunStructure().getNode(p.getSubidentifier());
if (node == null) {
notificationsManager.deactivate(p);
return notificationsManager.getNoSubscriptionInfo();
}
title = translator.translate(NOTIFICATIONS_HEADER_COURSE, new String[] { displayName });
} else {
title = getHeader(translator, displayName);
}
} catch (Exception e) {
log.error("Unknown Exception", e);
return notificationsManager.getNoSubscriptionInfo();
}
OLATResourceable feedOres = OresHelper.createOLATResourceableInstance(p.getType(), new Long(p.getData()));
Feed feed = feedManager.loadFeed(feedOres);
List<Item> listItems = feedManager.loadItems(feed);
List<SubscriptionListItem> items = new ArrayList<>();
for (Item item : listItems) {
if (!item.isDraft()) {
appendSubscriptionItem(item, p, compareDate, translator, items);
}
}
si = new SubscriptionInfo(subscriber.getKey(), p.getType(), new TitleItem(title, getCssClassIcon()), items);
} else {
// no news
si = notificationsManager.getNoSubscriptionInfo();
}
} catch (Exception e) {
log.error("Unknown Exception", e);
si = notificationsManager.getNoSubscriptionInfo();
}
return si;
}
use of org.olat.core.commons.services.notifications.model.TitleItem in project OpenOLAT by OpenOLAT.
the class ForumNotificationsHandler method getTitleItem.
private TitleItem getTitleItem(Publisher p, final Translator translator) {
Long resId = p.getResId();
String type = p.getResName();
String title;
try {
if ("BusinessGroup".equals(type)) {
BusinessGroup bg = CoreSpringFactory.getImpl(BusinessGroupService.class).loadBusinessGroup(resId);
title = translator.translate("notifications.header.group", new String[] { bg.getName() });
} else if ("CourseModule".equals(type)) {
String displayName = RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(resId);
title = translator.translate("notifications.header.course", new String[] { displayName });
} else {
title = translator.translate("notifications.header");
}
} catch (Exception e) {
log.error("Error while creating assessment notifications for publisher: " + p.getKey(), e);
checkPublisher(p);
title = translator.translate("notifications.header");
}
return new TitleItem(title, ForumHelper.CSS_ICON_CLASS_FORUM);
}
use of org.olat.core.commons.services.notifications.model.TitleItem in project OpenOLAT by OpenOLAT.
the class AbstractTaskNotificationHandler method createSubscriptionInfo.
/**
* @see org.olat.core.commons.services.notifications.NotificationsHandler#createSubscriptionInfo(org.olat.core.commons.services.notifications.Subscriber,
* java.util.Locale, java.util.Date)
*/
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
Publisher p = subscriber.getPublisher();
Date latestNews = p.getLatestNewsDate();
SubscriptionInfo si;
// there could be news for me, investigate deeper
try {
if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
String folderRoot = p.getData();
if (isLogDebugEnabled()) {
logDebug("folderRoot=", folderRoot);
}
final List<FileInfo> fInfos = FolderManager.getFileInfos(folderRoot, compareDate);
final Translator translator = Util.createPackageTranslator(AbstractTaskNotificationHandler.class, locale);
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(OresHelper.createOLATResourceableInstance("CourseModule", p.getResId()), false);
if (re == null) {
if (!checkPublisher(p)) {
return NotificationsManager.getInstance().getNoSubscriptionInfo();
}
} else if (re.getRepositoryEntryStatus().isClosed()) {
return NotificationsManager.getInstance().getNoSubscriptionInfo();
}
String displayName = re.getDisplayname();
si = new SubscriptionInfo(subscriber.getKey(), p.getType(), new TitleItem(translator.translate(getNotificationHeaderKey(), new String[] { displayName }), getCssClassIcon()), null);
SubscriptionListItem subListItem;
for (Iterator<FileInfo> it_infos = fInfos.iterator(); it_infos.hasNext(); ) {
FileInfo fi = it_infos.next();
MetaInfo metaInfo = fi.getMetaInfo();
String filePath = fi.getRelPath();
if (isLogDebugEnabled())
logDebug("filePath=", filePath);
String fullUserName = getUserNameFromFilePath(metaInfo, filePath);
Date modDate = fi.getLastModified();
String desc = translator.translate(getNotificationEntryKey(), new String[] { filePath, fullUserName });
String businessPath = p.getBusinessPath();
String urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
String iconCssClass = null;
if (metaInfo != null) {
iconCssClass = metaInfo.getIconCssClass();
}
subListItem = new SubscriptionListItem(desc, urlToSend, businessPath, modDate, iconCssClass);
si.addSubscriptionListItem(subListItem);
}
} else {
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
} catch (Exception e) {
getLogger().error("Cannot create task notifications for subscriber: " + subscriber.getKey(), e);
checkPublisher(p);
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
return si;
}
Aggregations