return new SyndFeedInput().build(r);
}
- private static Map<Category, String[]> getFeeds() {
- Map<Category, String[]> result;
-
- result = new HashMap<>();
-
- result.put(Category.TOP,
- new String[] {
- "http://www.francetvinfo.fr/titres.rss",
- "http://www.rfi.fr/general/rss",
- "http://www.cnews.fr/rss/une",
- "http://www.ladepeche.fr/rss/a-la-une.rss",
- "https://www.franceinter.fr/rss/a-la-une.xml",
- "https://www.francebleu.fr/rss/a-la-une.xml",
- "http://www.bfmtv.com/rss/info/flux-rss/flux-toutes-les-actualites/"
- });
-
- result.put(Category.SPORT,
- new String[] { "http://www.france24.com/fr/sports/rss" });
-
- result.put(Category.FRANCE,
- new String[] { "http://www.france24.com/fr/france/rss",
- "http://www.rfi.fr/france/rss"});
-
- result.put(Category.EUROPE,
- new String[] { "http://www.france24.com/fr/europe/rss" });
-
- result.put(Category.MONDE,
- new String[] { "http://www.france24.com/fr/actualites/rss" });
-
-
- result.put(Category.ECO,
- new String[] { "http://www.france24.com/fr/economie/rss",
- "http://www.rfi.fr/economie/rss" });
-
- result.put(Category.ESSONNE,
- new String[] { "http://www.tourisme-essonne.com/rss/actus/",
- "http://www.ville-palaiseau.fr/rss/actualites.htm" });
-
- result.put(Category.PEOPLE,
- new String[] { "http://www.premiere.fr/rss/actu-live",
- "http://www.purepeople.com/rss/news_t0.xml"
- });
-
- result.put(Category.TECHNOLOGIE,
- new String[] { "http://feeds.feedburner.com/lesnumeriques/news",
- "http://www.zdnet.fr/feeds/rss/actualites/"});
-
- return result;
- }
+
private List<Article> getArticlesForUpdate(Category cat) {
List<Article> result;
private void retrieveArticles(Category cat) throws IllegalArgumentException, MalformedURLException, FeedException, IOException {
String[] feeds;
- feeds = getFeeds().get(cat);
+ feeds = Config.getFeedsByCategory().get(cat);
if (feeds != null)
for (String str: feeds)
}
@Override
- public void run() {
- List<Article> articles;
-
+ public void run() {
LOG.info("refresher "+ category.getId());
try {
retrieveArticles(category);
-
- synchronized (articlesByCategory) {
- articles = articlesByCategory.get(category);
- if (articles != null && articles.size() > 100) {
- articlesByCategory.put(category,
- articles.subList(0, 100));
-
- }
- LOG.info("refresher " + category.getId() + " number of articles: " + articles.size());
- }
} catch (IllegalArgumentException | FeedException | IOException e) {
LOG.log(Level.SEVERE, "refresher failure", e);
}