Search in sources :

Example 1 with FeedExtension

use of org.opencastproject.feed.api.FeedExtension in project opencast by opencast.

the class FeedImplTest method setterGetterTest.

@Test
public void setterGetterTest() {
    instance.setTitle("text");
    logger.info(instance.getTitle().getValue());
    Assert.assertEquals(instance.getTitle().getValue(), "text");
    instance.setLink("http://localhost:8080/feeds/rss/2.0/test");
    Assert.assertEquals(instance.getLink(), "http://localhost:8080/feeds/rss/2.0/test");
    instance.setCopyright("text");
    Assert.assertEquals(instance.getCopyright(), "text");
    List<Person> person = new ArrayList<Person>();
    instance.setAuthors(person);
    Assert.assertEquals(instance.getAuthors(), person);
    instance.setContributors(person);
    Assert.assertEquals(instance.getContributors(), person);
    instance.setUri("http://testuri/");
    Assert.assertEquals(instance.getUri(), "http://testuri/");
    List<Category> category = new ArrayList<Category>();
    instance.setCategories(category);
    Assert.assertEquals(instance.getCategories(), category);
    instance.setDescription("description");
    Assert.assertEquals(instance.getDescription().getValue(), "description");
    Content content = new ContentImpl("desciption");
    instance.setDescription(content);
    Assert.assertEquals(instance.getDescription(), content);
    instance.setEncoding("encode");
    Assert.assertEquals(instance.getEncoding(), "encode");
    List<FeedEntry> feed = new ArrayList<FeedEntry>();
    instance.setEntries(feed);
    Assert.assertEquals(instance.getEntries(), feed);
    Image image = new ImageImpl("http://picture/");
    instance.setImage(image);
    Assert.assertEquals(instance.getImage(), image);
    instance.setLanguage("English");
    Assert.assertEquals(instance.getLanguage(), "English");
    List<Link> link = new ArrayList<Link>();
    instance.setLinks(link);
    Assert.assertEquals(instance.getLinks(), link);
    List<FeedExtension> feedExtension = new ArrayList<FeedExtension>();
    instance.setModules(feedExtension);
    Assert.assertEquals(instance.getModules(), feedExtension);
    Date date = new Date(21091981);
    instance.setPublishedDate(date);
    Assert.assertEquals(instance.getPublishedDate(), date);
    instance.setUpdatedDate(date);
    Assert.assertEquals(instance.getUpdatedDate(), date);
    instance.setTitle(content);
    Assert.assertEquals(instance.getTitle(), content);
}
Also used : FeedExtension(org.opencastproject.feed.api.FeedExtension) Category(org.opencastproject.feed.api.Category) ArrayList(java.util.ArrayList) Image(org.opencastproject.feed.api.Image) Date(java.util.Date) FeedEntry(org.opencastproject.feed.api.FeedEntry) Content(org.opencastproject.feed.api.Content) Person(org.opencastproject.feed.api.Person) Link(org.opencastproject.feed.api.Link) Test(org.junit.Test)

Example 2 with FeedExtension

use of org.opencastproject.feed.api.FeedExtension in project opencast by opencast.

the class FeedImplTest method getModuleByString.

@Test
public void getModuleByString() {
    instance.setModules(null);
    FeedExtension feedext = EasyMock.createNiceMock(FeedExtension.class);
    EasyMock.expect(feedext.getUri()).andReturn("module");
    EasyMock.replay(feedext);
    instance.addModule(feedext);
    Assert.assertEquals(instance.getModule("module"), feedext);
    Assert.assertNotSame(instance.getModule("false"), feedext);
}
Also used : FeedExtension(org.opencastproject.feed.api.FeedExtension) Test(org.junit.Test)

Example 3 with FeedExtension

use of org.opencastproject.feed.api.FeedExtension in project opencast by opencast.

the class AbstractFeedGenerator method addSeries.

/**
 * Adds series information to the feed.
 *
 * @param feed
 *          the feed
 * @param query
 *          the query that results in the feed
 * @param resultItem
 *          the series item
 * @param organization
 *          the organization
 * @return the feed
 */
protected Feed addSeries(Feed feed, String[] query, SearchResultItem resultItem, Organization organization) {
    Date d = resultItem.getDcCreated();
    // find iTunes module
    ITunesFeedExtension iTunesFeed = null;
    for (FeedExtension extension : feed.getModules()) {
        if (extension instanceof ITunesFeedExtension) {
            iTunesFeed = (ITunesFeedExtension) extension;
            break;
        }
    }
    if (!StringUtils.isEmpty(resultItem.getDcTitle()))
        feed.setTitle(resultItem.getDcTitle());
    if (!StringUtils.isEmpty(resultItem.getDcDescription())) {
        feed.setDescription(resultItem.getDcDescription());
        if (iTunesFeed != null)
            iTunesFeed.setSummary(resultItem.getDcDescription());
    }
    if (!StringUtils.isEmpty(resultItem.getDcCreator())) {
        PersonImpl personImpl = new PersonImpl(resultItem.getDcCreator());
        feed.addAuthor(personImpl);
        if (iTunesFeed != null) {
            iTunesFeed.setAuthor(personImpl.getName());
            iTunesFeed.setOwnerName(personImpl.getName());
        }
    }
    if (!StringUtils.isEmpty(resultItem.getDcContributor()))
        feed.addContributor(new PersonImpl(resultItem.getDcContributor()));
    if (!StringUtils.isEmpty(resultItem.getDcAccessRights()))
        feed.setCopyright(resultItem.getDcAccessRights());
    if (!StringUtils.isEmpty(resultItem.getDcLanguage()))
        feed.setLanguage(resultItem.getDcLanguage());
    feed.setUri(resultItem.getId());
    feed.addLink(new LinkImpl(getLinkForEntry(feed, resultItem, organization)));
    if (d != null)
        feed.setPublishedDate(d);
    // Set the cover image
    String coverUrl = null;
    if (!StringUtils.isEmpty(resultItem.getCover())) {
        coverUrl = resultItem.getCover();
        feed.setImage(new ImageImpl(coverUrl, resultItem.getDcTitle()));
        try {
            if (iTunesFeed != null)
                iTunesFeed.setImage(new URL(coverUrl));
        } catch (MalformedURLException e) {
            logger.error("Error creating cover URL: {}", coverUrl, e);
        }
    }
    return feed;
}
Also used : FeedExtension(org.opencastproject.feed.api.FeedExtension) MalformedURLException(java.net.MalformedURLException) Date(java.util.Date) URL(java.net.URL)

Aggregations

FeedExtension (org.opencastproject.feed.api.FeedExtension)3 Date (java.util.Date)2 Test (org.junit.Test)2 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Category (org.opencastproject.feed.api.Category)1 Content (org.opencastproject.feed.api.Content)1 FeedEntry (org.opencastproject.feed.api.FeedEntry)1 Image (org.opencastproject.feed.api.Image)1 Link (org.opencastproject.feed.api.Link)1 Person (org.opencastproject.feed.api.Person)1