Package com.sun.syndication.feed.synd

Examples of com.sun.syndication.feed.synd.SyndFeed


               URL feedUrl = new URL(feed.getRssUrl());
               //System.out.println(feedUrl);
               SyndFeedInput input = new SyndFeedInput();
             
               XmlReader reader = new XmlReader(feedUrl);
               SyndFeed feeder = input.build(reader);
                        
              
               List feederEntries = feeder.getEntries();
               int end = feederEntries.size();
               end = (end < limit) ? end : limit;
             
               List selectedNewsEntries = feederEntries.subList(0, end);
              
View Full Code Here


                // Convert to an RSS feed
                if (feed != null) {
                    response.setContentType("application/rss+xml; charset=utf-8");
                    feed.setFeedType("atom_1.0");
                    SyndFeed syndFeed = new SyndFeedImpl(feed);
                    syndFeed.setFeedType(requestFeedType);
                    syndFeed.setLink(path);
                    SyndFeedOutput syndOutput = new SyndFeedOutput();
                    try {
                        syndOutput.output(syndFeed, getWriter(response));
                    } catch (FeedException e) {
                        throw new ServletException(e);
View Full Code Here

        // Handle an RSS request
        if (path == null || path.length() == 0 || path.equals("/")) {

            // Return an RSS feed containing the entries in the collection
            SyndFeed feed = null;
            if (supportsFeedEntries) {

                // The service implementation supports feed entries, invoke its getFeed operation
                Message requestMessage = messageFactory.createMessage();
                Message responseMessage = getFeedInvoker.invoke(requestMessage);
                if (responseMessage.isFault()) {
                    throw new ServletException((Throwable)responseMessage.getBody());
                }
                feed = (SyndFeed)responseMessage.getBody();
               
            } else {

                // The service implementation does not support feed entries, invoke its
                // getAll operation to get the data item collection. then create feed entries
                // from the data items
                Message requestMessage = messageFactory.createMessage();
                Message responseMessage;
                if (request.getQueryString() != null) {
                    requestMessage.setBody(new Object[] {request.getQueryString()});
                    responseMessage = queryInvoker.invoke(requestMessage);
                } else {
                    responseMessage = getAllInvoker.invoke(requestMessage);
                }
                if (responseMessage.isFault()) {
                    throw new ServletException((Throwable)responseMessage.getBody());
                }
                org.apache.tuscany.sca.implementation.data.collection.Entry<Object, Object>[] collection =
                    (org.apache.tuscany.sca.implementation.data.collection.Entry<Object, Object>[])responseMessage.getBody();
                if (collection != null) {
                    // Create the feed
                    feed = new SyndFeedImpl();
                    feed.setTitle("Feed");
                   
                    for (org.apache.tuscany.sca.implementation.data.collection.Entry<Object, Object> entry: collection) {
                        SyndEntry feedEntry = createFeedEntry(entry);
                        feed.getEntries().add(feedEntry);
                    }
                }
            }

            // Convert to an RSS feed
            if (feed != null) {
                response.setContentType("application/rss+xml; charset=utf-8");
                feed.setFeedType("rss_2.0");
                feed.setLink(path);
                SyndFeedOutput syndOutput = new SyndFeedOutput();
                try {
                    syndOutput.output(feed, getWriter(response));
                } catch (FeedException e) {
                    throw new ServletException(e);
View Full Code Here

        try {
            logger.info(">>> RSSBindingInvoker (" + feedType + ") " + uri);

            // Read an RSS feed into a Synd feed
            SyndFeedInput input = new SyndFeedInput();
            SyndFeed feed = input.build(new XmlReader(new URL(uri)));
           
            //FIXME Support conversion to data-api entries
           
            msg.setBody(feed);
View Full Code Here

                feed = (Feed)input.build(new XmlReader(new URL(uri)));
            } else {

                // Read an RSS feed and convert it to an Atom feed
                SyndFeedInput input = new SyndFeedInput();
                SyndFeed syndFeed = input.build(new XmlReader(new URL(uri)));
                feed = (Feed)syndFeed.createWireFeed("atom_1.0");
            }
           
            //FIXME Support conversion to data-api entries
           
            msg.setBody(feed);
View Full Code Here

     * @return The exchange rate
     */
    public double getExchangeRate(String currency) {
        try {
            System.out.println("Retrieving exchange rate...");
            SyndFeed feed = exchangeRate.getRates();
            SyndEntry entry = (SyndEntry)feed.getEntries().get(0);
            String rateTable = entry.getDescription().getValue();

            Document doc = builder.parse(new ByteArrayInputStream(rateTable.getBytes()));
            Node node = doc.getDocumentElement();
            XPath path = XPathFactory.newInstance().newXPath();
View Full Code Here

    }

    public SyndFeed getFeed() {
        System.out.println(">>> CustomerCollectionImpl.getFeed");

        SyndFeed feed = new SyndFeedImpl();
        feed.setTitle("customers");
        feed.setDescription("This is a sample feed");
        feed.getEntries().addAll(entries.values());
        return feed;
    }
View Full Code Here

    }

    public SyndFeed query(String queryString) {
        System.out.println(">>> CustomerCollectionImpl.query");

        SyndFeed feed = new SyndFeedImpl();
        feed.setTitle("customers");
        feed.setDescription("This is a sample feed");
        feed.getEntries().addAll(entries.values());
        return feed;
    }
View Full Code Here

    public Collection resourceCollection;

    public void testCustomerCollection() throws Exception {

        System.out.println(">>> get collection");
        SyndFeed feed = resourceCollection.getFeed();
        System.out.println("<<< get collection");
        for (Object o : feed.getEntries()) {
            SyndEntry e = (SyndEntry)o;
            System.out.println("id = " + e.getUri() + " entry = " + e.getTitle());
        }
    }
View Full Code Here

        // setup Rome feed fetcher
        FeedFetcher feedFetcher = getRomeFetcher();
       
        // fetch the feed
        log.debug("Fetching feed: "+feedURL);
        SyndFeed feed;
        try {
            feed = feedFetcher.retrieveFeed(new URL(feedURL));
        } catch (Exception ex) {
            throw new FetcherException("Error fetching subscription - "+feedURL, ex);
        }
       
        log.debug("Feed pulled, extracting data into Subscription");
       
        // build planet subscription from fetched feed
        Subscription newSub = new Subscription();
        newSub.setFeedURL(feedURL);
        newSub.setSiteURL(feed.getLink());
        newSub.setTitle(feed.getTitle());
        newSub.setAuthor(feed.getAuthor());
        newSub.setLastUpdated(feed.getPublishedDate());
       
       
        // normalize any data that couldn't be properly extracted
        if(newSub.getSiteURL() == null) {
            // set the site url to the feed url then
            newSub.setSiteURL(newSub.getFeedURL());
        }
        if(newSub.getAuthor() == null) {
            // set the author to the title
            newSub.setAuthor(newSub.getTitle());
        }
        if(newSub.getLastUpdated() == null) {
            // no update time specified in feed, so try consulting feed info cache
            FeedFetcherCache feedCache = getRomeFetcherCache();
            try {
                SyndFeedInfo feedInfo = feedCache.getFeedInfo(new URL(newSub.getFeedURL()));
                if(feedInfo.getLastModified() != null) {
                    long lastUpdatedLong = ((Long)feedInfo.getLastModified()).longValue();
                    if (lastUpdatedLong != 0) {
                        newSub.setLastUpdated(new Date(lastUpdatedLong));
                    }
                }
            } catch (MalformedURLException ex) {
                // should never happen since we check this above
            }
        }
       
        // check if feed is unchanged and bail now if so
        if(lastModified != null && newSub.getLastUpdated() != null &&
                !newSub.getLastUpdated().after(lastModified)) {
            return null;
        }
       
        if(log.isDebugEnabled()) {
            log.debug("Subscription is: "+newSub.toString());
        }
       
       
        // some kludge to deal with feeds w/ no entry dates
        // we assign arbitrary dates chronologically by entry starting either
        // from the current time or the last update time of the subscription
        Calendar cal = Calendar.getInstance();
        if (newSub.getLastUpdated() != null) {
            cal.setTime(newSub.getLastUpdated());
        } else {
            cal.setTime(new Date());
            cal.add(Calendar.DATE, -1);
        }
       
        // add entries
        List<SyndEntry> feedEntries = feed.getEntries();
        for( SyndEntry feedEntry : feedEntries ) {
            SubscriptionEntry newEntry = buildEntry(feedEntry);
           
            // some kludge to handle feeds with no entry dates
            if (newEntry.getPubTime() == null) {
View Full Code Here

TOP

Related Classes of com.sun.syndication.feed.synd.SyndFeed

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.