Search in sources :

Example 6 with SyndEntryImpl

use of com.sun.syndication.feed.synd.SyndEntryImpl in project opennms by OpenNMS.

the class OutageFeed method getFeed.

/**
     * <p>getFeed</p>
     *
     * @return a {@link com.sun.syndication.feed.synd.SyndFeed} object.
     */
@Override
public SyndFeed getFeed() {
    SyndFeed feed = new SyndFeedImpl();
    feed.setTitle("Nodes with Outages");
    feed.setDescription("OpenNMS Nodes with Outages");
    feed.setLink(getUrlBase() + "outage/list.htm");
    List<SyndEntry> entries = new ArrayList<SyndEntry>();
    try {
        Date date = new Date();
        date.setTime(date.getTime() - (1000 * 60 * 60 * 24));
        OutageSummary[] summaries = OutageModel.getAllOutageSummaries(date);
        SyndEntry entry;
        int count = 0;
        for (OutageSummary summary : summaries) {
            if (count++ == this.getMaxEntries()) {
                break;
            }
            String link = getUrlBase() + "element/node.jsp?node=" + summary.getNodeId();
            entry = new SyndEntryImpl();
            entry.setPublishedDate(summary.getTimeDown());
            if (summary.getTimeUp() == null) {
                entry.setTitle(sanitizeTitle(summary.getNodeLabel()));
                entry.setUpdatedDate(summary.getTimeDown());
            } else {
                entry.setTitle(sanitizeTitle(summary.getNodeLabel()) + " (Resolved)");
                entry.setUpdatedDate(summary.getTimeUp());
            }
            entry.setLink(link);
            entry.setAuthor("OpenNMS");
            entries.add(entry);
        }
    } catch (SQLException e) {
        LOG.warn("unable to get current outages", e);
    }
    feed.setEntries(entries);
    return feed;
}
Also used : SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SQLException(java.sql.SQLException) SyndEntry(com.sun.syndication.feed.synd.SyndEntry) OutageSummary(org.opennms.netmgt.model.outage.OutageSummary) SyndEntryImpl(com.sun.syndication.feed.synd.SyndEntryImpl) ArrayList(java.util.ArrayList) SyndFeedImpl(com.sun.syndication.feed.synd.SyndFeedImpl) Date(java.util.Date)

Example 7 with SyndEntryImpl

use of com.sun.syndication.feed.synd.SyndEntryImpl in project asterixdb by apache.

the class FetcherEventListenerImpl method next.

@Override
public IRawRecord<SyndEntryImpl> next() throws IOException {
    if (done) {
        return null;
    }
    try {
        SyndEntryImpl feedEntry;
        feedEntry = getNextRSSFeed();
        if (feedEntry == null) {
            return null;
        }
        record.set(feedEntry);
        return record;
    } catch (Exception e) {
        throw new IOException(e);
    }
}
Also used : SyndEntryImpl(com.sun.syndication.feed.synd.SyndEntryImpl) IOException(java.io.IOException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) FeedException(com.sun.syndication.io.FeedException) FetcherException(com.sun.syndication.fetcher.FetcherException)

Example 8 with SyndEntryImpl

use of com.sun.syndication.feed.synd.SyndEntryImpl in project asterixdb by apache.

the class RSSParser method parse.

@Override
public void parse(IRawRecord<? extends SyndEntryImpl> record, DataOutput out) throws HyracksDataException {
    SyndEntryImpl entry = record.get();
    tupleFieldValues[0] = idPrefix + ":" + id;
    tupleFieldValues[1] = entry.getTitle();
    tupleFieldValues[2] = entry.getDescription().getValue();
    tupleFieldValues[3] = entry.getLink();
    for (int i = 0; i < numFields; i++) {
        mutableFields[i].setValue(tupleFieldValues[i]);
        mutableRecord.setValueAtPos(i, mutableFields[i]);
    }
    recordBuilder.reset(mutableRecord.getType());
    recordBuilder.init();
    IDataParser.writeRecord(mutableRecord, out, recordBuilder);
    id++;
}
Also used : SyndEntryImpl(com.sun.syndication.feed.synd.SyndEntryImpl)

Example 9 with SyndEntryImpl

use of com.sun.syndication.feed.synd.SyndEntryImpl in project gitblit by gitblit.

the class SyndicationUtils method readFeed.

/**
	 * Reads a Gitblit RSS feed.
	 *
	 * @param url
	 *            the url of the Gitblit server
	 * @param parameters
	 *            the list of RSS parameters
	 * @param repository
	 *            the repository name
	 * @param username
	 * @param password
	 * @return a list of SyndicationModel entries
	 * @throws {@link IOException}
	 */
private static List<FeedEntryModel> readFeed(String url, List<String> parameters, String repository, String branch, String username, char[] password) throws IOException {
    // build url
    StringBuilder sb = new StringBuilder();
    sb.append(MessageFormat.format("{0}" + Constants.SYNDICATION_PATH + "{1}", url, repository));
    if (parameters.size() > 0) {
        boolean first = true;
        for (String parameter : parameters) {
            if (first) {
                sb.append('?');
                first = false;
            } else {
                sb.append('&');
            }
            sb.append(parameter);
        }
    }
    String feedUrl = sb.toString();
    URLConnection conn = ConnectionUtils.openReadConnection(feedUrl, username, password);
    InputStream is = conn.getInputStream();
    SyndFeedInput input = new SyndFeedInput();
    SyndFeed feed = null;
    try {
        feed = input.build(new XmlReader(is));
    } catch (FeedException f) {
        throw new GitBlitException(f);
    }
    is.close();
    List<FeedEntryModel> entries = new ArrayList<FeedEntryModel>();
    for (Object o : feed.getEntries()) {
        SyndEntryImpl entry = (SyndEntryImpl) o;
        FeedEntryModel model = new FeedEntryModel();
        model.repository = repository;
        model.branch = branch;
        model.title = entry.getTitle();
        model.author = entry.getAuthor();
        model.published = entry.getPublishedDate();
        model.link = entry.getLink();
        model.content = entry.getDescription().getValue();
        model.contentType = entry.getDescription().getType();
        if (entry.getCategories() != null && entry.getCategories().size() > 0) {
            List<String> tags = new ArrayList<String>();
            for (Object p : entry.getCategories()) {
                SyndCategory cat = (SyndCategory) p;
                tags.add(cat.getName());
            }
            model.tags = tags;
        }
        entries.add(model);
    }
    return entries;
}
Also used : SyndCategory(com.sun.syndication.feed.synd.SyndCategory) FeedEntryModel(com.gitblit.models.FeedEntryModel) InputStream(java.io.InputStream) FeedException(com.sun.syndication.io.FeedException) ArrayList(java.util.ArrayList) GitBlitException(com.gitblit.GitBlitException) XmlReader(com.sun.syndication.io.XmlReader) URLConnection(java.net.URLConnection) SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SyndFeedInput(com.sun.syndication.io.SyndFeedInput) SyndEntryImpl(com.sun.syndication.feed.synd.SyndEntryImpl)

Example 10 with SyndEntryImpl

use of com.sun.syndication.feed.synd.SyndEntryImpl in project jersey by jersey.

the class FeedEntriesAtomBodyWriter method writeTo.

@Override
public void writeTo(List<FeedEntry> entries, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
    List<SyndEntry> syndEntries = entries.parallelStream().map(entry -> {
        SyndContent description = new SyndContentImpl();
        description.setType(MediaType.TEXT_PLAIN);
        description.setValue(entry.getDescription());
        SyndEntry syndEntry = new SyndEntryImpl();
        syndEntry.setTitle(entry.getTitle());
        syndEntry.setLink(entry.getLink());
        syndEntry.setPublishedDate(entry.getPublishDate());
        syndEntry.setDescription(description);
        return syndEntry;
    }).collect(Collectors.toList());
    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType("atom_1.0");
    feed.setTitle("Combined Feed");
    feed.setDescription("Combined Feed created by a feed-combiner application");
    feed.setPublishedDate(new Date());
    feed.setEntries(syndEntries);
    writeSyndFeed(entityStream, feed);
}
Also used : SyndEntry(com.sun.syndication.feed.synd.SyndEntry) Produces(javax.ws.rs.Produces) Provider(javax.ws.rs.ext.Provider) FeedEntry(org.glassfish.jersey.examples.feedcombiner.model.FeedEntry) Date(java.util.Date) SyndFeedImpl(com.sun.syndication.feed.synd.SyndFeedImpl) LoggerFactory(org.slf4j.LoggerFactory) MessageBodyWriter(javax.ws.rs.ext.MessageBodyWriter) FeedException(com.sun.syndication.io.FeedException) MediaType(javax.ws.rs.core.MediaType) SyndContentImpl(com.sun.syndication.feed.synd.SyndContentImpl) OutputStreamWriter(java.io.OutputStreamWriter) OutputStream(java.io.OutputStream) Logger(org.slf4j.Logger) Collection(java.util.Collection) IOException(java.io.IOException) SyndFeedOutput(com.sun.syndication.io.SyndFeedOutput) Collectors(java.util.stream.Collectors) SyndContent(com.sun.syndication.feed.synd.SyndContent) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) List(java.util.List) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) SyndEntryImpl(com.sun.syndication.feed.synd.SyndEntryImpl) Annotation(java.lang.annotation.Annotation) WebApplicationException(javax.ws.rs.WebApplicationException) SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SyndContent(com.sun.syndication.feed.synd.SyndContent) SyndContentImpl(com.sun.syndication.feed.synd.SyndContentImpl) SyndEntry(com.sun.syndication.feed.synd.SyndEntry) SyndEntryImpl(com.sun.syndication.feed.synd.SyndEntryImpl) SyndFeedImpl(com.sun.syndication.feed.synd.SyndFeedImpl) Date(java.util.Date)

Aggregations

SyndEntryImpl (com.sun.syndication.feed.synd.SyndEntryImpl)17 SyndEntry (com.sun.syndication.feed.synd.SyndEntry)12 SyndFeed (com.sun.syndication.feed.synd.SyndFeed)10 ArrayList (java.util.ArrayList)10 SyndFeedImpl (com.sun.syndication.feed.synd.SyndFeedImpl)9 SyndContentImpl (com.sun.syndication.feed.synd.SyndContentImpl)8 SyndContent (com.sun.syndication.feed.synd.SyndContent)7 FeedException (com.sun.syndication.io.FeedException)4 Date (java.util.Date)4 SyndFeedOutput (com.sun.syndication.io.SyndFeedOutput)3 IOException (java.io.IOException)3 SQLException (java.sql.SQLException)3 FeedEntryModel (com.gitblit.models.FeedEntryModel)2 SyndCategory (com.sun.syndication.feed.synd.SyndCategory)2 OutputStreamWriter (java.io.OutputStreamWriter)2 OnmsSeverity (org.opennms.netmgt.model.OnmsSeverity)2 Filter (org.opennms.web.filter.Filter)2 Post (com.erudika.scoold.core.Post)1 Question (com.erudika.scoold.core.Question)1 GitBlitException (com.gitblit.GitBlitException)1