Search in sources :

Example 21 with SyndContentImpl

use of com.rometools.rome.feed.synd.SyndContentImpl in project opennms by OpenNMS.

the class AlarmFeed method getFeed.

/**
 * <p>getFeed</p>
 *
 * @return a {@link com.rometools.rome.feed.synd.SyndFeed} object.
 */
@Override
public SyndFeed getFeed() {
    SyndFeed feed = new SyndFeedImpl();
    feed.setTitle("Alarms");
    feed.setDescription("OpenNMS Alarms");
    feed.setLink(getUrlBase() + "alarm/list.htm");
    List<SyndEntry> entries = new ArrayList<>();
    List<Filter> filters = new ArrayList<>();
    if (this.getRequest().getParameter("node") != null) {
        Integer nodeId = WebSecurityUtils.safeParseInt(this.getRequest().getParameter("node"));
        filters.add(new NodeFilter(nodeId, getServletContext()));
    }
    if (this.getRequest().getParameter("severity") != null) {
        String sev = this.getRequest().getParameter("severity");
        for (OnmsSeverity severity : OnmsSeverity.values()) {
            if (severity.getLabel().equalsIgnoreCase(sev)) {
                filters.add(new SeverityFilter(severity));
            }
        }
    }
    OnmsCriteria queryCriteria = AlarmUtil.getOnmsCriteria(new AlarmCriteria(filters.toArray(new Filter[] {}), SortStyle.FIRSTEVENTTIME, AcknowledgeType.BOTH, this.getMaxEntries(), AlarmCriteria.NO_OFFSET));
    OnmsAlarm[] alarms = m_webAlarmRepository.getMatchingAlarms(queryCriteria);
    SyndEntry entry;
    for (OnmsAlarm alarm : alarms) {
        entry = new SyndEntryImpl();
        entry.setPublishedDate(alarm.getFirstEventTime());
        if (alarm.getAckTime() != null) {
            entry.setTitle(sanitizeTitle(alarm.getLogMsg()) + " (acknowledged by " + alarm.getAckUser() + ")");
            entry.setUpdatedDate(alarm.getAckTime());
        } else {
            entry.setTitle(sanitizeTitle(alarm.getLogMsg()));
            entry.setUpdatedDate(alarm.getFirstEventTime());
        }
        entry.setLink(getUrlBase() + "alarm/detail.htm?id=" + alarm.getId());
        entry.setAuthor("OpenNMS");
        SyndContent content = new SyndContentImpl();
        content.setType("text/html");
        content.setValue(alarm.getDescription());
        entry.setDescription(content);
        entries.add(entry);
    }
    feed.setEntries(entries);
    return feed;
}
Also used : SyndEntry(com.rometools.rome.feed.synd.SyndEntry) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) ArrayList(java.util.ArrayList) OnmsCriteria(org.opennms.netmgt.model.OnmsCriteria) SyndFeed(com.rometools.rome.feed.synd.SyndFeed) SeverityFilter(org.opennms.web.alarm.filter.SeverityFilter) OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) SyndContent(com.rometools.rome.feed.synd.SyndContent) SeverityFilter(org.opennms.web.alarm.filter.SeverityFilter) Filter(org.opennms.web.filter.Filter) NodeFilter(org.opennms.web.alarm.filter.NodeFilter) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) SyndFeedImpl(com.rometools.rome.feed.synd.SyndFeedImpl) AlarmCriteria(org.opennms.web.alarm.filter.AlarmCriteria) NodeFilter(org.opennms.web.alarm.filter.NodeFilter)

Example 22 with SyndContentImpl

use of com.rometools.rome.feed.synd.SyndContentImpl in project opennms by OpenNMS.

the class EventFeed method getFeed.

/**
 * <p>getFeed</p>
 *
 * @return a {@link com.rometools.rome.feed.synd.SyndFeed} object.
 */
@Override
public SyndFeed getFeed() {
    SyndFeed feed = new SyndFeedImpl();
    feed.setTitle("Events");
    feed.setDescription("OpenNMS Events");
    feed.setLink(getUrlBase() + "event/list.htm");
    List<SyndEntry> entries = new ArrayList<>();
    try {
        Event[] events;
        ArrayList<Filter> filters = new ArrayList<>();
        if (this.getRequest().getParameter("node") != null) {
            Integer nodeId = WebSecurityUtils.safeParseInt(this.getRequest().getParameter("node"));
            filters.add(new NodeFilter(nodeId, getServletContext()));
        }
        if (this.getRequest().getParameter("severity") != null) {
            String parameter = this.getRequest().getParameter("severity");
            try {
                Integer severityId = WebSecurityUtils.safeParseInt(parameter);
                filters.add(new SeverityFilter(severityId));
            } catch (NumberFormatException e) {
                for (OnmsSeverity sev : OnmsSeverity.values()) {
                    if (sev.getLabel().equalsIgnoreCase(parameter)) {
                        filters.add(new SeverityFilter(sev));
                        break;
                    }
                }
            }
        }
        events = EventFactory.getEvents(SortStyle.TIME, AcknowledgeType.BOTH, filters.toArray(new Filter[] {}), this.getMaxEntries(), 0);
        SyndEntry entry;
        for (Event event : events) {
            entry = new SyndEntryImpl();
            entry.setPublishedDate(event.getTime());
            if (event.getAcknowledgeTime() != null) {
                entry.setTitle(sanitizeTitle(event.getLogMessage()) + " (Acknowledged by " + event.getAcknowledgeUser() + ")");
                entry.setUpdatedDate(event.getAcknowledgeTime());
            } else {
                entry.setTitle(sanitizeTitle(event.getLogMessage()));
                entry.setUpdatedDate(event.getTime());
            }
            entry.setLink(getUrlBase() + "event/detail.jsp?id=" + event.getId());
            entry.setAuthor("OpenNMS");
            SyndContent content = new SyndContentImpl();
            content.setType("text/html");
            content.setValue(event.getDescription());
            entry.setDescription(content);
            entries.add(entry);
        }
    } catch (SQLException e) {
        LOG.warn("unable to get event(s)", e);
    }
    feed.setEntries(entries);
    return feed;
}
Also used : SQLException(java.sql.SQLException) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) ArrayList(java.util.ArrayList) SyndFeed(com.rometools.rome.feed.synd.SyndFeed) SeverityFilter(org.opennms.web.event.filter.SeverityFilter) OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) SyndContent(com.rometools.rome.feed.synd.SyndContent) SeverityFilter(org.opennms.web.event.filter.SeverityFilter) Filter(org.opennms.web.filter.Filter) NodeFilter(org.opennms.web.event.filter.NodeFilter) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) Event(org.opennms.web.event.Event) SyndFeedImpl(com.rometools.rome.feed.synd.SyndFeedImpl) NodeFilter(org.opennms.web.event.filter.NodeFilter)

Example 23 with SyndContentImpl

use of com.rometools.rome.feed.synd.SyndContentImpl in project coffeenet-frontpage-plugin-rss by coffeenet.

the class BlogParserTest method parseBlog.

@Test
public void parseBlog() throws FeedException, IOException {
    SyndContentImpl description = new SyndContentImpl();
    description.setValue("description");
    SyndEntryImpl syndEntry = new SyndEntryImpl();
    syndEntry.setDescription(description);
    syndEntry.setLink("link");
    syndEntry.setAuthor("author");
    syndEntry.setTitle("title");
    syndEntry.setPublishedDate(Date.from(Instant.parse("2014-12-03T10:15:30.00Z")));
    SyndFeed result = new SyndFeedImpl();
    result.setEntries(singletonList(syndEntry));
    when(feedFactory.build(any(URL.class))).thenReturn(result);
    List<BlogEntry> blogEntries = sut.parse("http://blog/feed/", 10, 150);
    assertThat(blogEntries, hasSize(1));
    assertThat(blogEntries.get(0).getDescription(), is("description"));
    assertThat(blogEntries.get(0).getLink(), is("link"));
    assertThat(blogEntries.get(0).getPublishDate(), is("3. December 2014"));
    assertThat(blogEntries.get(0).getAuthor(), is("author"));
    assertThat(blogEntries.get(0).getTitle(), is("title"));
}
Also used : SyndFeed(com.rometools.rome.feed.synd.SyndFeed) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) SyndFeedImpl(com.rometools.rome.feed.synd.SyndFeedImpl) URL(java.net.URL) Test(org.junit.Test)

Example 24 with SyndContentImpl

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

the class FeedsServlet method getEntry.

private SyndEntry getEntry(Post post, String url, String urlType) {
    SyndEntry entry;
    SyndContent description;
    entry = new SyndEntryImpl();
    entry.setTitle(post.getMessage().getSubject() + BY + post.getPoster().getUserId());
    entry.setLink(postLink(post.getId().toString(), url, urlType));
    entry.setPublishedDate(post.getCreateDate());
    description = new SyndContentImpl();
    description.setType("text/html");
    String text = post.getMessage().getText();
    description.setValue(post.getMessage().getHTMLEnabled() ? escapeHtml(text) : text);
    entry.setDescription(description);
    return entry;
}
Also used : SyndContent(com.rometools.rome.feed.synd.SyndContent) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl)

Example 25 with SyndContentImpl

use of com.rometools.rome.feed.synd.SyndContentImpl in project archiva by apache.

the class RssFeedGenerator method getEntries.

private List<SyndEntry> getEntries(List<RssFeedEntry> dataEntries) {
    List<SyndEntry> entries = new ArrayList<>();
    SyndEntry entry;
    SyndContent description;
    for (RssFeedEntry dataEntry : dataEntries) {
        entry = new SyndEntryImpl();
        entry.setTitle(dataEntry.getTitle());
        entry.setPublishedDate(dataEntry.getPublishedDate());
        description = new SyndContentImpl();
        description.setType("text/plain");
        description.setValue(dataEntry.getDescription());
        entry.setDescription(description);
        entries.add(entry);
    }
    return entries;
}
Also used : SyndContent(com.rometools.rome.feed.synd.SyndContent) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) ArrayList(java.util.ArrayList)

Aggregations

SyndContentImpl (com.rometools.rome.feed.synd.SyndContentImpl)32 SyndEntryImpl (com.rometools.rome.feed.synd.SyndEntryImpl)28 SyndEntry (com.rometools.rome.feed.synd.SyndEntry)26 SyndContent (com.rometools.rome.feed.synd.SyndContent)24 SyndFeedImpl (com.rometools.rome.feed.synd.SyndFeedImpl)15 ArrayList (java.util.ArrayList)14 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)13 SyndFeedOutput (com.rometools.rome.io.SyndFeedOutput)5 StatusGroup (org.onebusaway.enterprise.webapp.actions.status.model.StatusGroup)4 StatusItem (org.onebusaway.enterprise.webapp.actions.status.model.StatusItem)4 SyndCategory (com.rometools.rome.feed.synd.SyndCategory)3 SyndImageImpl (com.rometools.rome.feed.synd.SyndImageImpl)3 SProject (org.bimserver.interfaces.objects.SProject)3 Preconditions (com.google.common.base.Preconditions)2 Hashing (com.google.common.hash.Hashing)2 MediaType (com.google.common.net.MediaType)2 SyndCategoryImpl (com.rometools.rome.feed.synd.SyndCategoryImpl)2 SyndImage (com.rometools.rome.feed.synd.SyndImage)2 SyndPerson (com.rometools.rome.feed.synd.SyndPerson)2 SyndPersonImpl (com.rometools.rome.feed.synd.SyndPersonImpl)2