Search in sources :

Example 36 with BlogFileResource

use of org.olat.fileresource.types.BlogFileResource in project openolat by klemens.

the class FeedFileStorgeTest method getOrCreateFeedItemsContainer_get.

@Test
public void getOrCreateFeedItemsContainer_get() {
    FeedFileResource ores = new BlogFileResource();
    sut.getOrCreateFeedItemsContainer(ores);
    VFSContainer feedItemsContainer = sut.getOrCreateFeedItemsContainer(ores);
    assertThat(feedItemsContainer).isNotNull();
    fileResourceManager.deleteFileResource(ores);
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) FeedFileResource(org.olat.fileresource.types.FeedFileResource) BlogFileResource(org.olat.fileresource.types.BlogFileResource) Test(org.junit.Test)

Example 37 with BlogFileResource

use of org.olat.fileresource.types.BlogFileResource in project OpenOLAT by OpenOLAT.

the class BlogHandler method importResource.

@Override
public RepositoryEntry importResource(Identity initialAuthor, String initialAuthorAlt, String displayname, String description, boolean withReferences, Locale locale, File file, String filename) {
    OLATResource resource = OLATResourceManager.getInstance().createAndPersistOLATResourceInstance(new BlogFileResource());
    File fResourceFileroot = FileResourceManager.getInstance().getFileResourceRootImpl(resource).getBasefile();
    File blogRoot = new File(fResourceFileroot, FeedManager.getInstance().getFeedKind(resource));
    FileResource.copyResource(file, filename, blogRoot);
    FeedManager.getInstance().importFeedFromXML(resource, true);
    RepositoryEntry re = CoreSpringFactory.getImpl(RepositoryService.class).create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
    DBFactory.getInstance().commit();
    return re;
}
Also used : OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) BlogFileResource(org.olat.fileresource.types.BlogFileResource) File(java.io.File) RepositoryService(org.olat.repository.RepositoryService)

Example 38 with BlogFileResource

use of org.olat.fileresource.types.BlogFileResource in project OpenOLAT by OpenOLAT.

the class FeedFileStorgeTest method getOrCreateFeedContainer_create.

@Test
public void getOrCreateFeedContainer_create() {
    FeedFileResource ores = new BlogFileResource();
    VFSContainer feedContainer = sut.getOrCreateFeedContainer(ores);
    assertThat(feedContainer).isNotNull();
    fileResourceManager.deleteFileResource(ores);
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) FeedFileResource(org.olat.fileresource.types.FeedFileResource) BlogFileResource(org.olat.fileresource.types.BlogFileResource) Test(org.junit.Test)

Example 39 with BlogFileResource

use of org.olat.fileresource.types.BlogFileResource in project OpenOLAT by OpenOLAT.

the class FeedFileStorgeTest method loadFeedFromXML_shortening_values.

@Test
public void loadFeedFromXML_shortening_values() {
    StringBuffer sb = new StringBuffer(5000);
    for (int i = 0; i < 5000; i++) {
        sb.append("A");
    }
    String stringWith5000Chars = sb.toString();
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    feed.setAuthor(stringWith5000Chars);
    feed.setDescription(stringWith5000Chars);
    feed.setTitle(stringWith5000Chars);
    feed.setExternalFeedUrl(stringWith5000Chars);
    feed.setExternalImageURL(stringWith5000Chars);
    sut.saveFeedAsXML(feed);
    Feed reloaded = sut.loadFeedFromXML(resource);
    assertThat(reloaded).isNotNull();
    assertThat(reloaded.getAuthor()).hasSize(255);
    assertThat(reloaded.getTitle()).hasSize(1024);
    assertThat(reloaded.getDescription()).hasSize(4000);
    assertThat(reloaded.getExternalFeedUrl()).isNull();
    assertThat(reloaded.getExternalImageURL()).isNull();
    assertThat(reloaded.getImageName()).isNull();
    fileResourceManager.deleteFileResource(resource);
}
Also used : FeedImpl(org.olat.modules.webFeed.model.FeedImpl) BlogFileResource(org.olat.fileresource.types.BlogFileResource) Feed(org.olat.modules.webFeed.Feed) Test(org.junit.Test)

Example 40 with BlogFileResource

use of org.olat.fileresource.types.BlogFileResource in project OpenOLAT by OpenOLAT.

the class FeedFileStorgeTest method loadItemsFromXML_shortening.

@Test
public void loadItemsFromXML_shortening() {
    StringBuffer sb = new StringBuffer(5000);
    for (int i = 0; i < 5000; i++) {
        sb.append("A");
    }
    String stringWith5000Chars = sb.toString();
    BlogFileResource resource = new BlogFileResource();
    Feed feed = new FeedImpl(resource);
    Item item = new ItemImpl(feed);
    String guid1 = "guid 1";
    item.setGuid(guid1);
    item.setAuthor(stringWith5000Chars);
    item.setExternalLink(stringWith5000Chars);
    item.setTitle(stringWith5000Chars);
    sut.saveItemAsXML(item);
    List<Item> items = sut.loadItemsFromXML(feed);
    Item reloadedItem = items.get(0);
    assertThat(reloadedItem.getAuthor()).hasSize(255);
    assertThat(reloadedItem.getExternalLink()).isNull();
    assertThat(reloadedItem.getTitle()).hasSize(1024);
    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)

Aggregations

BlogFileResource (org.olat.fileresource.types.BlogFileResource)74 Test (org.junit.Test)72 Feed (org.olat.modules.webFeed.Feed)60 FeedImpl (org.olat.modules.webFeed.model.FeedImpl)58 Item (org.olat.modules.webFeed.Item)38 ItemImpl (org.olat.modules.webFeed.model.ItemImpl)36 VFSContainer (org.olat.core.util.vfs.VFSContainer)34 FeedFileResource (org.olat.fileresource.types.FeedFileResource)12 File (java.io.File)2 Path (java.nio.file.Path)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 RepositoryService (org.olat.repository.RepositoryService)2 OLATResource (org.olat.resource.OLATResource)2