Examples of SyndFeedInput


Examples of com.sun.syndication.io.SyndFeedInput

            Thread.currentThread().setContextClassLoader(getClass()
                    .getClassLoader());
            c = getGmailConnection();
            c.setUrl(gmailFeedUrl);
            final URLConnection con = c.openConnection();
            final SyndFeedInput feedInput = new SyndFeedInput();
            final SyndFeed gmail = feedInput.build(new XmlReader(con));
            for (final Object entry : gmail.getEntries()) {
                if (entry instanceof SyndEntry) {
                    messages.add(new RssGmailMessage((SyndEntry) entry));
                }
            }
View Full Code Here

Examples of com.sun.syndication.io.SyndFeedInput

     */
    public SyndFeedRepresentation(Representation feedRepresentation) {
        super(null);

        try {
            this.feed = new SyndFeedInput().build(feedRepresentation
                    .getReader());
            setMediaType(getMediaType(this.feed.getFeedType()));
        } catch (Exception e) {
            Context.getCurrentLogger().log(Level.WARNING,
                    "Unable to parse feed", e);
View Full Code Here

Examples of com.sun.syndication.io.SyndFeedInput

  }

  private static SyndFeed getFeed(String xmlUri) throws PortalException {
    SyndFeed feed;
    try {
      final SyndFeedInput input = new SyndFeedInput();
      if (xmlUri.substring(0, 7).equalsIgnoreCase("http://") ||
          xmlUri.substring(0, 8).equalsIgnoreCase("https://")) {
        final HttpClient client = HttpClientManager.getNewHTTPClient();
        final GetMethod get = new GetMethod(xmlUri);
        try {
          get.setFollowRedirects(true);
          final int rc = client.executeMethod(get);
          if (rc != HttpStatus.SC_OK) {
            throw new PortalException("HttpStatus:"+ rc+" url: " + xmlUri);
          }
          final InputStream in = get.getResponseBodyAsStream();
          feed = input.build(new XmlReader(in));
        } finally {
          get.releaseConnection();
        }
      } else {
      URL feedUrl;
      feedUrl = new URL(xmlUri);
      feed = input.build(new XmlReader(feedUrl));
      }
    } catch (MalformedURLException e) {
      throw new PortalException(e);
    } catch (IllegalArgumentException e) {
      throw new PortalException(e);
View Full Code Here

Examples of com.sun.syndication.io.SyndFeedInput

    }

    @Override
    protected Object doTransform(Object src, String outputEncoding) throws TransformerException
    {
        SyndFeedInput feedInput = new SyndFeedInput();
        SyndFeed feed = null;
        try
        {
            if (src instanceof String)
            {
                feed = feedInput.build(new StringReader(src.toString()));

            }
            else if (src instanceof InputStream)
            {
                feed = feedInput.build(new XmlReader((InputStream) src));

            }
            else if (src instanceof byte[])
            {
                feed = feedInput.build(new XmlReader(new ByteArrayInputStream((byte[]) src)));

            }
            else if (src instanceof Document)
            {
                feed = feedInput.build((Document) src);

            }
            else if (src instanceof InputSource)
            {
                feed = feedInput.build((InputSource) src);

            }
            else if (src instanceof File)
            {
                feed = feedInput.build((File) src);

            }
            return feed;
        }
        catch (Exception e)
View Full Code Here

Examples of com.sun.syndication.io.SyndFeedInput

        if (method.getResponseHeader("Content-Type") != null) {
            reader = new XmlReader(stream, method.getResponseHeader("Content-Type").getValue(), true);
        } else {
            reader = new XmlReader(stream, true);
        }
      return new SyndFeedInput().build(reader);
    } finally {
        if (stream != null) {
            stream.close();
        }
    }
View Full Code Here

Examples of com.sun.syndication.io.SyndFeedInput

                if (feed == null)
                {
                    try
                    {
                        // Parse the feed
                        SyndFeedInput feedInput = new SyndFeedInput();
                        feed = feedInput.build(new InputStreamReader(
                                new URL(feedUrl).openStream()));
                    }
                    catch (Exception e1)
                    {
                        mLogger.info("Error parsing RSS: " + feedUrl);
                    }
                }
                // Store parsed feed in the cache
                mCache.put(feedUrl, feed);
                mLogger.debug("Newsfeed: not in Cache");
            }
            else
            {
                if (mLogger.isDebugEnabled())
                {
                    mLogger.debug("Newsfeed: not using Cache for " + feedUrl);
                }
                try
                {
                        // charset fix from Jason Rumney (see ROL-766)
                        URLConnection connection = new URL(feedUrl).openConnection();
                        connection.connect();
                        String contentType = connection.getContentType();
                        // Default charset to UTF-8, since we are expecting XML
                        String charset = "UTF-8";
                        if (contentType != null) {
                            int charsetStart = contentType.indexOf("charset=");
                            if (charsetStart >= 0) {
                                int charsetEnd = contentType.indexOf(";", charsetStart);
                                if (charsetEnd == -1) charsetEnd = contentType.length();
                                charsetStart += "charset=".length();
                                charset = contentType.substring(charsetStart, charsetEnd);
                                // Check that charset is recognized by Java
                                try {
                                    byte[] test = "test".getBytes(charset);
                                }
                                catch (UnsupportedEncodingException codingEx) {
                                    // default to UTF-8
                                    charset = "UTF-8";
                                }
                            }
                        }
                        // Parse the feed
                        SyndFeedInput feedInput = new SyndFeedInput();
                        feed = feedInput.build(new InputStreamReader(
                        connection.getInputStream(), charset));
                }
                catch (Exception e1)
                {
                    mLogger.info("Error parsing RSS: " + feedUrl);
View Full Code Here

Examples of com.sun.syndication.io.SyndFeedInput

          //read the body data and convert it to an InputStream
          InputStream in= request.getInputStream();
         
          //create the new SyndFeed object
          try {
            SyndFeedInput input = new SyndFeedInput();
                  SyndFeed feed = input.build(new XmlReader(in));
                       
                  List<SyndLinkImpl> linkList = feed.getLinks();
                 
                  for (SyndLinkImpl link : linkList) {
                   
View Full Code Here

Examples of com.sun.syndication.io.SyndFeedInput

    XmlReader reader = null;

    try {

      reader = new XmlReader(url);
      SyndFeed feed = new SyndFeedInput().build(reader);
      System.out.println("Feed Title: " + feed.getAuthor());

      for (Iterator i = feed.getEntries().iterator(); i.hasNext();) {
        SyndEntry entry = (SyndEntry) i.next();
        System.out.println(entry.getTitle());
View Full Code Here

Examples of com.sun.syndication.io.SyndFeedInput

            // Turn the date into something we can process.
            DateFormat dateFormatter = DateFormat.getDateTimeInstance();
            Date timestamp = dateFormatter.parse(lastchecktimestamp);
           
            // get the feed data from the supplied address           
            SyndFeedInput input = new SyndFeedInput();
            SyndFeed feed = input.build(new XmlReader(new URL(rssaddress)));
            //System.out.println(feed);
           
            // check all the items to see if we have seen them before
            List entries = feed.getEntries();
            for(Object entry: entries){
View Full Code Here

Examples of com.sun.syndication.io.SyndFeedInput

            } else {
                feedURL = new URL(uri);
            }

            // Read the configured feed into a Feed object
            SyndFeedInput input = new SyndFeedInput();
            SyndFeed feed = input.build(new XmlReader(feedURL));
            msg.setBody(feed);

            System.out.println(">>> FeedBindingInvoker (" + feed.getFeedType() + ") " + uri);
           
        } catch (MalformedURLException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.