use of org.olat.modules.webFeed.Item in project openolat by klemens.
the class ItemDAOTest method createItem_Feed_Null.
@Test
public void createItem_Feed_Null() {
Item tempItem = new ItemImpl(null);
Item item = itemDao.createItem(null, tempItem);
dbInstance.commitAndCloseSession();
// check values
assertThat(item).isNull();
}
use of org.olat.modules.webFeed.Item in project openolat by klemens.
the class RomeFeedFetcherTest method convertEntry.
@Test
public void convertEntry() {
// prepare the mock
String author = "author";
when(syndEntryMock.getAuthor()).thenReturn(author);
String description = "description";
when(syndEntryMock.getDescription().getValue()).thenReturn(description);
String link = "link";
when(syndEntryMock.getLink()).thenReturn(link);
String title = "title";
when(syndEntryMock.getTitle()).thenReturn(title);
String uri = "uri";
when(syndEntryMock.getUri()).thenReturn(uri);
Date publishedDate = new Date();
when(syndEntryMock.getPublishedDate()).thenReturn(publishedDate);
Date updatedDate = new Date();
when(syndEntryMock.getUpdatedDate()).thenReturn(updatedDate);
List<SyndContent> contents = Arrays.asList(syndContentMock);
when(syndEntryMock.getContents()).thenReturn(contents);
when(syndEnclosureMock.getUrl()).thenReturn("URL");
List<SyndEnclosure> enclosures = Arrays.asList(syndEnclosureMock);
when(syndEntryMock.getEnclosures()).thenReturn(enclosures);
// call the method
Item item = sut.convertEntry(feedMock, syndEntryMock);
// test
assertThat(item.getFeed()).isEqualTo(feedMock);
assertThat(item.getAuthor()).isEqualTo(author);
assertThat(item.getContent()).isNotNull();
assertThat(item.getDescription()).isEqualTo(description);
assertThat(item.getEnclosure()).isNotNull();
assertThat(item.getExternalLink()).isEqualTo(link);
assertThat(item.getTitle()).isEqualTo(title);
assertThat(item.getGuid()).isEqualTo(uri);
assertThat(item.getLastModified()).isEqualTo(updatedDate);
assertThat(item.getPublishDate()).isEqualTo(publishedDate);
}
use of org.olat.modules.webFeed.Item in project openolat by klemens.
the class FeedManagerImpl method importFeedFromXML.
@Override
public void importFeedFromXML(OLATResource ores, boolean removeIdentityKeys) {
Feed feedFromXml = feedFileStorage.loadFeedFromXML(ores);
if (feedFromXml == null)
return;
// Check if the feed already exits or create it. The feed exists
// possibly, if a previous migration from an XML feed was not
// successful.
Feed feed = feedDAO.loadFeed(ores);
if (feed == null) {
feedFromXml.setResourceableId(ores.getResourceableId());
// Use the display name instead of the username
if (!removeIdentityKeys && feedFromXml.getAuthor() != null) {
String authorName = UserManager.getInstance().getUserDisplayName(feedFromXml.getAuthor());
if (authorName != null) {
feedFromXml.setAuthor(authorName);
}
}
feed = feedDAO.createFeed(feedFromXml);
log.info("Feed imported " + "(" + ores.getResourceableTypeName() + "): " + ores.getResourceableId());
}
List<Item> itemsFromXml = feedFileStorage.loadItemsFromXML(ores);
itemsFromXml = fixFeedVersionIssues(feedFromXml, itemsFromXml);
for (Item itemFromXml : itemsFromXml) {
// Check if the item already exits or create it.
Item item = itemDAO.loadItemByGuid(feed.getKey(), itemFromXml.getGuid());
if (item == null) {
if (removeIdentityKeys) {
itemFromXml.setAuthorKey(null);
itemFromXml.setModifierKey(null);
} else {
// Check if the identity exists
if (itemFromXml.getAuthorKey() != null && securityManager.loadIdentityShortByKey(itemFromXml.getAuthorKey()) == null) {
itemFromXml.setAuthorKey(null);
}
if (itemFromXml.getModifierKey() != null && securityManager.loadIdentityShortByKey(itemFromXml.getModifierKey()) == null) {
itemFromXml.setModifierKey(null);
}
}
itemDAO.createItem(feed, itemFromXml);
log.info("Item imported: " + itemFromXml.getGuid());
}
feedFileStorage.deleteItemXML(itemFromXml);
}
if (feed.isExternal()) {
saveExternalItems(feed);
saveExternalFeed(feed);
}
feedFileStorage.deleteFeedXML(feed);
}
use of org.olat.modules.webFeed.Item in project openolat by klemens.
the class FeedManagerImpl method updateItem.
@Override
public Item updateItem(Item item, FileElement file) {
if (item == null)
return null;
Item updatedItem = itemDAO.loadItem(item.getKey());
if (updatedItem != null) {
Enclosure enclosure = replaceEnclosure(item, file);
item.setEnclosure(enclosure);
updatedItem = itemDAO.updateItem(item);
markPublisherNews(updatedItem.getFeed());
}
return updatedItem;
}
use of org.olat.modules.webFeed.Item in project openolat by klemens.
the class BlogEntryMediaHandler method getInformations.
@Override
public MediaInformations getInformations(Object mediaObject) {
BlogEntryMedia entry = (BlogEntryMedia) mediaObject;
Item item = entry.getItem();
return new Informations(item.getTitle(), item.getDescription());
}
Aggregations