use of org.olat.modules.webFeed.Feed in project OpenOLAT by OpenOLAT.
the class FeedManagerImpl method deleteItem.
@Override
public Feed deleteItem(Item item) {
Feed feed = item.getFeed();
// delete the item from the database
itemDAO.removeItem(item);
// delete the item container from the file system
feedFileStorage.deleteItemContainer(item);
// delete comments and ratings
CommentAndRatingService commentAndRatingService = CoreSpringFactory.getImpl(CommentAndRatingService.class);
commentAndRatingService.deleteAll(feed, item.getGuid());
// reload the Feed
Feed reloadedFeed = feedDAO.loadFeed(feed.getKey());
// or from an external source.
if (!hasItems(reloadedFeed)) {
// set undefined
reloadedFeed.setExternal(null);
}
reloadedFeed.setLastModified(new Date());
reloadedFeed = feedDAO.updateFeed(reloadedFeed);
return reloadedFeed;
}
use of org.olat.modules.webFeed.Feed in project OpenOLAT by OpenOLAT.
the class FeedManagerImpl method copy.
@Override
public boolean copy(OLATResource sourceResource, OLATResource targetResource) {
// copy the folders and files
File sourceFileroot = fileResourceManager.getFileResourceRootImpl(sourceResource).getBasefile();
File sourceFeedRoot = new File(sourceFileroot, getFeedKind(sourceResource));
File targetFileroot = fileResourceManager.getFileResourceRootImpl(targetResource).getBasefile();
FileUtils.copyFileToDir(sourceFeedRoot, targetFileroot, "add file resource");
// load the feed and the items from the database
Feed sourceFeed = feedDAO.loadFeed(sourceResource);
List<Item> items = itemDAO.loadItems(sourceFeed);
// copy the feed in the database
Feed targetFeed = feedDAO.copyFeed(sourceResource, targetResource);
// copy the items in the database
for (Item item : items) {
itemDAO.copyItem(targetFeed, item);
}
return true;
}
use of org.olat.modules.webFeed.Feed 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.modules.webFeed.Feed in project OpenOLAT by OpenOLAT.
the class BlogHandler method onDescriptionChanged.
@Override
public void onDescriptionChanged(RepositoryEntry entry) {
Feed feed = FeedManager.getInstance().updateFeedWithRepositoryEntry(entry);
DBFactory.getInstance().commitAndCloseSession();
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new FeedChangedEvent(feed.getKey()), feed);
}
use of org.olat.modules.webFeed.Feed in project OpenOLAT by OpenOLAT.
the class PodcastHandler method onDescriptionChanged.
@Override
public void onDescriptionChanged(RepositoryEntry entry) {
Feed feed = FeedManager.getInstance().updateFeedWithRepositoryEntry(entry);
DBFactory.getInstance().commitAndCloseSession();
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new FeedChangedEvent(feed.getKey()), feed);
}
Aggregations