INT-3518: Upgrade versions and some cleanup
JIRA: https://jira.spring.io/browse/INT-3518
This commit is contained in:
committed by
Gary Russell
parent
30b58836e5
commit
2587ed6bd0
@@ -36,13 +36,13 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.sun.syndication.feed.synd.SyndEntry;
|
||||
import com.sun.syndication.feed.synd.SyndFeed;
|
||||
import com.sun.syndication.fetcher.FeedFetcher;
|
||||
import com.sun.syndication.fetcher.FetcherEvent;
|
||||
import com.sun.syndication.fetcher.FetcherListener;
|
||||
import com.sun.syndication.fetcher.impl.HashMapFeedInfoCache;
|
||||
import com.sun.syndication.fetcher.impl.HttpURLFeedFetcher;
|
||||
import com.rometools.fetcher.FeedFetcher;
|
||||
import com.rometools.fetcher.FetcherEvent;
|
||||
import com.rometools.fetcher.FetcherListener;
|
||||
import com.rometools.fetcher.impl.HashMapFeedInfoCache;
|
||||
import com.rometools.fetcher.impl.HttpURLFeedFetcher;
|
||||
import com.rometools.rome.feed.synd.SyndEntry;
|
||||
import com.rometools.rome.feed.synd.SyndFeed;
|
||||
|
||||
/**
|
||||
* This implementation of {@link MessageSource} will produce individual
|
||||
@@ -81,7 +81,6 @@ public class FeedEntryMessageSource extends IntegrationObjectSupport implements
|
||||
* Creates a FeedEntryMessageSource that will use a HttpURLFeedFetcher to read feeds from the given URL.
|
||||
* If the feed URL has a protocol other than http*, consider providing a custom implementation of the
|
||||
* {@link FeedFetcher} via the alternate constructor.
|
||||
*
|
||||
* @param feedUrl The URL.
|
||||
* @param metadataKey The metadata key.
|
||||
*/
|
||||
@@ -91,7 +90,6 @@ public class FeedEntryMessageSource extends IntegrationObjectSupport implements
|
||||
|
||||
/**
|
||||
* Creates a FeedEntryMessageSource that will use the provided FeedFetcher to read from the given feed URL.
|
||||
*
|
||||
* @param feedUrl The URL.
|
||||
* @param metadataKey The metadata key.
|
||||
* @param feedFetcher The feed fetcher.
|
||||
@@ -118,7 +116,8 @@ public class FeedEntryMessageSource extends IntegrationObjectSupport implements
|
||||
|
||||
@Override
|
||||
public Message<SyndEntry> receive() {
|
||||
Assert.isTrue(this.initialized, "'FeedEntryReaderMessageSource' must be initialized before it can produce Messages.");
|
||||
Assert.isTrue(this.initialized,
|
||||
"'FeedEntryReaderMessageSource' must be initialized before it can produce Messages.");
|
||||
SyndEntry entry = doReceive();
|
||||
if (entry == null) {
|
||||
return null;
|
||||
@@ -176,7 +175,6 @@ public class FeedEntryMessageSource extends IntegrationObjectSupport implements
|
||||
return next;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void populateEntryList() {
|
||||
SyndFeed syndFeed = this.getFeed();
|
||||
if (syndFeed != null) {
|
||||
@@ -244,7 +242,7 @@ public class FeedEntryMessageSource extends IntegrationObjectSupport implements
|
||||
private class FeedQueueUpdatingFetcherListener implements FetcherListener {
|
||||
|
||||
/**
|
||||
* @see com.sun.syndication.fetcher.FetcherListener#fetcherEvent(com.sun.syndication.fetcher.FetcherEvent)
|
||||
* @see FetcherListener#fetcherEvent(FetcherEvent)
|
||||
*/
|
||||
@Override
|
||||
public void fetcherEvent(final FetcherEvent event) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,20 +36,20 @@ import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
import org.springframework.integration.feed.inbound.FeedEntryMessageSource;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.metadata.MetadataStore;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
|
||||
import com.sun.syndication.feed.synd.SyndEntry;
|
||||
import com.sun.syndication.fetcher.impl.AbstractFeedFetcher;
|
||||
import com.sun.syndication.fetcher.impl.HttpURLFeedFetcher;
|
||||
import com.rometools.fetcher.impl.AbstractFeedFetcher;
|
||||
import com.rometools.fetcher.impl.HttpURLFeedFetcher;
|
||||
import com.rometools.rome.feed.synd.SyndEntry;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
@@ -175,6 +175,7 @@ public class FeedInboundChannelAdapterParserTests {
|
||||
public void receiveFeedEntry(SyndEntry entry) {
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -191,6 +192,7 @@ public class FeedInboundChannelAdapterParserTests {
|
||||
public String remove(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.integration.metadata.PropertiesPersistingMetadataStore;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
import com.sun.syndication.feed.synd.SyndEntry;
|
||||
import com.sun.syndication.fetcher.FeedFetcher;
|
||||
import com.rometools.fetcher.FeedFetcher;
|
||||
import com.rometools.rome.feed.synd.SyndEntry;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
@@ -47,7 +47,8 @@ public class FeedEntryMessageSourceTests {
|
||||
|
||||
@Before
|
||||
public void prepare() {
|
||||
File metadataStoreFile = new File(System.getProperty("java.io.tmpdir") + "/spring-integration/", "metadata-store.properties");
|
||||
File metadataStoreFile = new File(System.getProperty("java.io.tmpdir") + "/spring-integration/",
|
||||
"metadata-store.properties");
|
||||
if (metadataStoreFile.exists()) {
|
||||
metadataStoreFile.delete();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,26 +25,29 @@ import java.util.zip.GZIPInputStream;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.sun.syndication.feed.synd.SyndFeed;
|
||||
import com.sun.syndication.fetcher.FetcherEvent;
|
||||
import com.sun.syndication.fetcher.FetcherException;
|
||||
import com.sun.syndication.fetcher.impl.AbstractFeedFetcher;
|
||||
import com.sun.syndication.fetcher.impl.SyndFeedInfo;
|
||||
import com.sun.syndication.io.FeedException;
|
||||
import com.sun.syndication.io.SyndFeedInput;
|
||||
import com.sun.syndication.io.XmlReader;
|
||||
import com.rometools.fetcher.FeedFetcher;
|
||||
import com.rometools.fetcher.FetcherEvent;
|
||||
import com.rometools.fetcher.FetcherException;
|
||||
import com.rometools.fetcher.impl.AbstractFeedFetcher;
|
||||
import com.rometools.fetcher.impl.SyndFeedInfo;
|
||||
import com.rometools.rome.feed.synd.SyndFeed;
|
||||
import com.rometools.rome.io.FeedException;
|
||||
import com.rometools.rome.io.SyndFeedInput;
|
||||
import com.rometools.rome.io.XmlReader;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
* @since 2.0
|
||||
*/
|
||||
class FileUrlFeedFetcher extends AbstractFeedFetcher {
|
||||
|
||||
/**
|
||||
* Retrieve a SyndFeed for the given URL.
|
||||
* @see com.sun.syndication.fetcher.FeedFetcher#retrieveFeed(java.net.URL)
|
||||
* @see FeedFetcher#retrieveFeed(java.net.URL)
|
||||
*/
|
||||
@Override
|
||||
public SyndFeed retrieveFeed(URL feedUrl) throws IOException, FeedException, FetcherException {
|
||||
Assert.notNull(feedUrl, "feedUrl must not be null");
|
||||
URLConnection connection = feedUrl.openConnection();
|
||||
@@ -53,7 +56,14 @@ class FileUrlFeedFetcher extends AbstractFeedFetcher {
|
||||
return syndFeedInfo.getSyndFeed();
|
||||
}
|
||||
|
||||
private void refreshFeedInfo(URL feedUrl, SyndFeedInfo syndFeedInfo, URLConnection connection) throws IOException, FeedException {
|
||||
@Override
|
||||
public SyndFeed retrieveFeed(String userAgent, URL url)
|
||||
throws IllegalArgumentException, IOException, FeedException, FetcherException {
|
||||
return retrieveFeed(url);
|
||||
}
|
||||
|
||||
private void refreshFeedInfo(URL feedUrl, SyndFeedInfo syndFeedInfo, URLConnection connection)
|
||||
throws IOException, FeedException {
|
||||
// need to always set the URL because this may have changed due to 3xx redirects
|
||||
syndFeedInfo.setUrl(connection.getURL());
|
||||
|
||||
@@ -62,7 +72,7 @@ class FileUrlFeedFetcher extends AbstractFeedFetcher {
|
||||
syndFeedInfo.setId(feedUrl.toString());
|
||||
|
||||
// This will be 0 if the server doesn't support or isn't setting the last modified header
|
||||
syndFeedInfo.setLastModified(new Long(connection.getLastModified()));
|
||||
syndFeedInfo.setLastModified(connection.getLastModified());
|
||||
|
||||
// get the contents
|
||||
InputStream inputStream = null;
|
||||
@@ -81,7 +91,8 @@ class FileUrlFeedFetcher extends AbstractFeedFetcher {
|
||||
}
|
||||
}
|
||||
|
||||
private SyndFeed readFeedFromStream(InputStream inputStream, URLConnection connection) throws IOException, FeedException {
|
||||
private SyndFeed readFeedFromStream(InputStream inputStream, URLConnection connection)
|
||||
throws IOException, FeedException {
|
||||
BufferedInputStream bufferedInputStream;
|
||||
if ("gzip".equalsIgnoreCase(connection.getContentEncoding())) {
|
||||
// handle gzip encoded content
|
||||
|
||||
Reference in New Issue
Block a user