Search in sources :

Example 6 with SyndEntry

use of com.rometools.rome.feed.synd.SyndEntry in project BIMserver by opensourceBIM.

the class SyndicationServlet method writeCheckoutsFeed.

private void writeCheckoutsFeed(HttpServletRequest request, HttpServletResponse response, ServiceMap serviceMap) throws ServiceException, IOException, FeedException, PublicInterfaceNotFoundException {
    long poid = Long.parseLong(request.getParameter("poid"));
    SProject sProject = serviceMap.getServiceInterface().getProjectByPoid(poid);
    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType(FEED_TYPE);
    feed.setTitle("BIMserver.org checkouts feed for project '" + sProject.getName() + "'");
    feed.setLink(request.getContextPath());
    feed.setDescription("This feed represents all the checkouts of project '" + sProject.getName() + "'");
    List<SyndEntry> entries = new ArrayList<SyndEntry>();
    try {
        List<SCheckout> allCheckoutsOfProject = serviceMap.getServiceInterface().getAllCheckoutsOfProjectAndSubProjects(poid);
        for (SCheckout sCheckout : allCheckoutsOfProject) {
            SRevision revision = serviceMap.getServiceInterface().getRevision(sCheckout.getRevision().getOid());
            SProject project = serviceMap.getServiceInterface().getProjectByPoid(sCheckout.getProjectId());
            SUser user = serviceMap.getServiceInterface().getUserByUoid(sCheckout.getUserId());
            SyndEntry entry = new SyndEntryImpl();
            entry.setTitle("Checkout on " + project.getName() + ", revision " + revision.getId());
            entry.setLink(request.getContextPath() + "/project.jsp?poid=" + sProject.getOid());
            entry.setPublishedDate(sCheckout.getDate());
            SyndContent description = new SyndContentImpl();
            description.setType("text/plain");
            description.setValue("<table><tr><td>User</td><td>" + user.getUsername() + "</td></tr><tr><td>Revision</td><td>" + sCheckout.getRevision().getOid() + "</td></tr></table>");
            entry.setDescription(description);
            entries.add(entry);
        }
    } catch (UserException e) {
        LOGGER.error("", e);
    }
    feed.setEntries(entries);
    SyndFeedOutput output = new SyndFeedOutput();
    output.output(feed, response.getWriter());
}
Also used : SyndEntry(com.rometools.rome.feed.synd.SyndEntry) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) SUser(org.bimserver.interfaces.objects.SUser) ArrayList(java.util.ArrayList) SyndFeedOutput(com.rometools.rome.io.SyndFeedOutput) SProject(org.bimserver.interfaces.objects.SProject) SyndFeed(com.rometools.rome.feed.synd.SyndFeed) SRevision(org.bimserver.interfaces.objects.SRevision) SyndContent(com.rometools.rome.feed.synd.SyndContent) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) SyndFeedImpl(com.rometools.rome.feed.synd.SyndFeedImpl) UserException(org.bimserver.shared.exceptions.UserException) SCheckout(org.bimserver.interfaces.objects.SCheckout)

Example 7 with SyndEntry

use of com.rometools.rome.feed.synd.SyndEntry in project spring-integration-samples by spring-projects.

the class FeedInboundChannelAdapterSample method runDemo.

@SuppressWarnings("unchecked")
@Test
public void runDemo() {
    ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext("META-INF/spring/integration/FeedInboundChannelAdapterSample-context.xml");
    PollableChannel feedChannel = ac.getBean("feedChannel", PollableChannel.class);
    for (int i = 0; i < 10; i++) {
        Message<SyndEntry> message = (Message<SyndEntry>) feedChannel.receive(1000);
        if (message != null) {
            SyndEntry entry = message.getPayload();
            System.out.println(entry.getPublishedDate() + " - " + entry.getTitle());
        } else {
            break;
        }
    }
    ac.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) Message(org.springframework.messaging.Message) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) PollableChannel(org.springframework.messaging.PollableChannel) Test(org.junit.Test)

Example 8 with SyndEntry

use of com.rometools.rome.feed.synd.SyndEntry in project rubia-forums by flashboss.

the class FeedsServlet method createCategoryFeed.

private void createCategoryFeed(SyndFeed feed, Integer id, String url, String urlType) throws ModuleException {
    Category category = forumsModule.findCategoryById(id);
    feed.setTitle("Rubia Forums Category Feed: " + category.getTitle());
    feed.setLink(categoryLink(id.toString(), url, urlType));
    feed.setDescription("Messages posted in category " + category.getTitle());
    List<SyndEntry> entries = new ArrayList<SyndEntry>();
    List<Post> posts = forumsModule.findPostsFromCategoryDesc(category, POST_LIMIT);
    for (int i = 0; i < posts.size(); i++) {
        entries.add(getEntry(posts.get(i), url, urlType));
    }
    feed.setEntries(entries);
}
Also used : Category(it.vige.rubia.model.Category) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) Post(it.vige.rubia.model.Post) ArrayList(java.util.ArrayList)

Example 9 with SyndEntry

use of com.rometools.rome.feed.synd.SyndEntry in project rubia-forums by flashboss.

the class FeedsServlet method createTopicFeed.

private void createTopicFeed(SyndFeed feed, Integer id, String url, String urlType) throws ModuleException {
    Topic topic = forumsModule.findTopicById(id);
    feed.setTitle("Rubia Forums Topic Feed: " + topic.getSubject());
    feed.setLink(topicLink(id.toString(), url, urlType));
    feed.setDescription("Messages posted in topic " + topic.getSubject() + " in forum " + topic.getForum().getName() + " in category " + topic.getForum().getCategory().getTitle());
    List<SyndEntry> entries = new ArrayList<SyndEntry>();
    List<Post> posts = forumsModule.findPostsByTopicId(topic);
    for (int i = 0; i < posts.size(); i++) {
        entries.add(getEntry(posts.get(i), url, urlType));
    }
    feed.setEntries(entries);
}
Also used : SyndEntry(com.rometools.rome.feed.synd.SyndEntry) Post(it.vige.rubia.model.Post) ArrayList(java.util.ArrayList) Topic(it.vige.rubia.model.Topic)

Example 10 with SyndEntry

use of com.rometools.rome.feed.synd.SyndEntry in project rubia-forums by flashboss.

the class FeedsServlet method createForumFeed.

private void createForumFeed(SyndFeed feed, Integer id, String url, String urlType) throws ModuleException {
    Forum forum = forumsModule.findForumById(id);
    feed.setTitle("Rubia Forums Forum Feed: " + forum.getName());
    feed.setLink(forumLink(id.toString(), url, urlType));
    feed.setDescription("Messages posted in forum " + forum.getName() + " in category " + forum.getCategory().getTitle());
    List<SyndEntry> entries = new ArrayList<SyndEntry>();
    List<Post> posts = forumsModule.findPostsFromForumDesc(forum, POST_LIMIT);
    for (int i = 0; i < posts.size(); i++) {
        entries.add(getEntry(posts.get(i), url, urlType));
    }
    feed.setEntries(entries);
}
Also used : SyndEntry(com.rometools.rome.feed.synd.SyndEntry) Post(it.vige.rubia.model.Post) ArrayList(java.util.ArrayList) Forum(it.vige.rubia.model.Forum)

Aggregations

SyndEntry (com.rometools.rome.feed.synd.SyndEntry)45 ArrayList (java.util.ArrayList)23 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)22 SyndEntryImpl (com.rometools.rome.feed.synd.SyndEntryImpl)18 SyndContent (com.rometools.rome.feed.synd.SyndContent)15 SyndFeedImpl (com.rometools.rome.feed.synd.SyndFeedImpl)14 SyndContentImpl (com.rometools.rome.feed.synd.SyndContentImpl)13 SyndFeedInput (com.rometools.rome.io.SyndFeedInput)9 FeedException (com.rometools.rome.io.FeedException)7 Test (org.junit.Test)7 XmlReader (com.rometools.rome.io.XmlReader)6 URL (java.net.URL)6 Date (java.util.Date)5 StatusGroup (org.onebusaway.enterprise.webapp.actions.status.model.StatusGroup)5 StatusItem (org.onebusaway.enterprise.webapp.actions.status.model.StatusItem)5 IOException (java.io.IOException)4 BeanFactory (org.springframework.beans.factory.BeanFactory)4 ClassPathResource (org.springframework.core.io.ClassPathResource)4 SyndFeedOutput (com.rometools.rome.io.SyndFeedOutput)3 Post (it.vige.rubia.model.Post)3