Search in sources :

Example 6 with FeedImpl

use of org.olat.modules.webFeed.model.FeedImpl in project OpenOLAT by OpenOLAT.

the class FeedDAO method createFeed.

public Feed createFeed(Feed feed) {
    if (feed == null)
        return null;
    FeedImpl feedImpl = (FeedImpl) feed;
    if (feedImpl.getCreationDate() == null) {
        feedImpl.setCreationDate(new Date());
    }
    if (feedImpl.getLastModified() == null) {
        feedImpl.setLastModified(feedImpl.getCreationDate());
    }
    dbInstance.getCurrentEntityManager().persist(feedImpl);
    return feed;
}
Also used : FeedImpl(org.olat.modules.webFeed.model.FeedImpl) Date(java.util.Date)

Example 7 with FeedImpl

use of org.olat.modules.webFeed.model.FeedImpl in project OpenOLAT by OpenOLAT.

the class FeedFileStorgeTest method saveItemAsXML_overwrite.

@Test
public void saveItemAsXML_overwrite() {
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    Item item = new ItemImpl(feed);
    item.setGuid("123");
    item.setAuthor("autor");
    sut.saveItemAsXML(item);
    item.setAuthor("secondAuthor");
    sut.saveItemAsXML(item);
    // check if there is one file in the item container
    assertThat(sut.getOrCreateItemContainer(item).getItems().size()).isEqualTo(1);
    fileResourceManager.deleteFileResource(resource);
}
Also used : Item(org.olat.modules.webFeed.Item) ItemImpl(org.olat.modules.webFeed.model.ItemImpl) FeedImpl(org.olat.modules.webFeed.model.FeedImpl) BlogFileResource(org.olat.fileresource.types.BlogFileResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 8 with FeedImpl

use of org.olat.modules.webFeed.model.FeedImpl in project OpenOLAT by OpenOLAT.

the class FeedFileStorgeTest method getOrCreateItemMediaContainer_create.

@Test
public void getOrCreateItemMediaContainer_create() {
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    Item item = new ItemImpl(feed);
    item.setGuid("guid");
    VFSContainer itemMediaContainer = sut.getOrCreateItemMediaContainer(item);
    assertThat(itemMediaContainer).isNotNull();
    fileResourceManager.deleteFileResource(resource);
}
Also used : Item(org.olat.modules.webFeed.Item) ItemImpl(org.olat.modules.webFeed.model.ItemImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) FeedImpl(org.olat.modules.webFeed.model.FeedImpl) BlogFileResource(org.olat.fileresource.types.BlogFileResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 9 with FeedImpl

use of org.olat.modules.webFeed.model.FeedImpl in project OpenOLAT by OpenOLAT.

the class FeedFileStorgeTest method loadItemsFromXML_empty.

@Test
public void loadItemsFromXML_empty() {
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    List<Item> items = sut.loadItemsFromXML(feed);
    assertThat(items.size()).isEqualTo(0);
    fileResourceManager.deleteFileResource(resource);
}
Also used : Item(org.olat.modules.webFeed.Item) FeedImpl(org.olat.modules.webFeed.model.FeedImpl) BlogFileResource(org.olat.fileresource.types.BlogFileResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 10 with FeedImpl

use of org.olat.modules.webFeed.model.FeedImpl in project OpenOLAT by OpenOLAT.

the class FeedFileStorgeTest method getOrCreateItemContainer_Guid_empty.

@Test
public void getOrCreateItemContainer_Guid_empty() {
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    Item item = new ItemImpl(feed);
    item.setGuid("");
    VFSContainer itemContainer = sut.getOrCreateItemContainer(item);
    assertThat(itemContainer).isNull();
    fileResourceManager.deleteFileResource(resource);
}
Also used : Item(org.olat.modules.webFeed.Item) ItemImpl(org.olat.modules.webFeed.model.ItemImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) FeedImpl(org.olat.modules.webFeed.model.FeedImpl) BlogFileResource(org.olat.fileresource.types.BlogFileResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Aggregations

FeedImpl (org.olat.modules.webFeed.model.FeedImpl)82 Feed (org.olat.modules.webFeed.Feed)76 Test (org.junit.Test)74 BlogFileResource (org.olat.fileresource.types.BlogFileResource)58 Item (org.olat.modules.webFeed.Item)38 ItemImpl (org.olat.modules.webFeed.model.ItemImpl)36 VFSContainer (org.olat.core.util.vfs.VFSContainer)22 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)8 Date (java.util.Date)6 OLATResource (org.olat.resource.OLATResource)4 Path (java.nio.file.Path)2 GregorianCalendar (java.util.GregorianCalendar)2 Before (org.junit.Before)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2