projects
/
pnews.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
improved
[pnews.git]
/
war
/
src
/
main
/
java
/
pnews
/
servlet
/
ArticleProvider.java
diff --git
a/war/src/main/java/pnews/servlet/ArticleProvider.java
b/war/src/main/java/pnews/servlet/ArticleProvider.java
index
010317a
..
ddec874
100644
(file)
--- a/
war/src/main/java/pnews/servlet/ArticleProvider.java
+++ b/
war/src/main/java/pnews/servlet/ArticleProvider.java
@@
-37,7
+37,7
@@
public class ArticleProvider {
private ArticleProvider() {
for (Category cat:Category.values())
private ArticleProvider() {
for (Category cat:Category.values())
- scheduler.scheduleAtFixedRate(new Refresher(cat), 2,
12
0, TimeUnit.SECONDS);
+ scheduler.scheduleAtFixedRate(new Refresher(cat), 2,
60
0, TimeUnit.SECONDS);
}
private static SyndFeed getSyndFeed(String u) throws IllegalArgumentException, FeedException, MalformedURLException, IOException {
}
private static SyndFeed getSyndFeed(String u) throws IllegalArgumentException, FeedException, MalformedURLException, IOException {
@@
-56,10
+56,12
@@
public class ArticleProvider {
result.put(Category.TOP,
new String[] {
"http://www.francetvinfo.fr/titres.rss",
result.put(Category.TOP,
new String[] {
"http://www.francetvinfo.fr/titres.rss",
- "http://www.france24.com/fr/actualites/rss",
- //"https://www.franceinter.fr/rss/a-la-une.xml",
+ "http://www.france24.com/fr/actualites/rss",
"http://www.rfi.fr/general/rss",
"http://www.cnews.fr/rss/une",
"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/"
});
"http://www.bfmtv.com/rss/info/flux-rss/flux-toutes-les-actualites/"
});
@@
-96,12
+98,14
@@
public class ArticleProvider {
private void addArticles(Category cat, SyndFeed feed) {
String thumbnail;
private void addArticles(Category cat, SyndFeed feed) {
String thumbnail;
- String desc, link, title;
+ String desc, link, title
, feedTitle
;
Date date;
List<Article> articles;
boolean exist;
Date date;
List<Article> articles;
boolean exist;
- LOG.info("addArticles" + cat.getId());
+ feedTitle = feed.getTitle().trim();
+
+ LOG.info("addArticles " + cat.getId() + " " + feedTitle + " number of articles: " + feed.getEntries().size());
for (SyndEntry entry: feed.getEntries()) {
thumbnail = null;
for (SyndEntry entry: feed.getEntries()) {
thumbnail = null;
@@
-111,20
+115,26
@@
public class ArticleProvider {
break;
}
break;
}
+ title = entry.getTitle().trim();
+
if (entry.getDescription() != null) {
desc = Jsoup.parse(entry.getDescription().getValue()).text();
} else {
desc = null;
if (entry.getDescription() != null) {
desc = Jsoup.parse(entry.getDescription().getValue()).text();
} else {
desc = null;
- LOG.severe("No description for " + feed
.getTitle() + " - " + entry.getTitle()
);
+ LOG.severe("No description for " + feed
Title + " - " + title
);
}
date = entry.getPublishedDate();
if (date == null)
date = entry.getUpdatedDate();
}
date = entry.getPublishedDate();
if (date == null)
date = entry.getUpdatedDate();
+ if (date == null) {
+ LOG.severe("The article " + feedTitle + " - " + title + " does not have a date");
+ continue;
+ }
synchronized(articlesByCategory) {
link = entry.getLink().trim();
synchronized(articlesByCategory) {
link = entry.getLink().trim();
- title = entry.getTitle().trim();
+
articles = articlesByCategory.get(cat);
exist = false;
if (articles == null) {
articles = articlesByCategory.get(cat);
exist = false;
if (articles == null) {
@@
-133,13
+143,13
@@
public class ArticleProvider {
} else {
for (Article a: articles)
if (a.link.equals(link)) {
} else {
for (Article a: articles)
if (a.link.equals(link)) {
- LOG.
finest(
link + " already present");
+ LOG.
info("addArticles " +
link + " already present");
exist = true;
}
}
if (!exist) {
exist = true;
}
}
if (!exist) {
- LOG.
info("add " + cat.getId() + " " + feed.getTitle()
+ " " + title);
+ LOG.
fine("add " + cat.getId() + " " + feedTitle
+ " " + title);
articles.add(new Article(link, cat, title, desc, thumbnail, date,
feed.getTitle()));
articles.add(new Article(link, cat, title, desc, thumbnail, date,
feed.getTitle()));
@@
-151,9
+161,13
@@
public class ArticleProvider {
}
});
}
});
+ } else {
+ LOG.finest("addArticles already exist: " + title);
}
}
}
}
- }
+ }
+
+ LOG.info("addArticles done " + cat.getId());
}
private void retrieveArticles(Category cat) throws IllegalArgumentException, MalformedURLException, FeedException, IOException {
}
private void retrieveArticles(Category cat) throws IllegalArgumentException, MalformedURLException, FeedException, IOException {
@@
-165,8
+179,10
@@
public class ArticleProvider {
for (String str: feeds)
try {
addArticles(cat, getSyndFeed(str));
for (String str: feeds)
try {
addArticles(cat, getSyndFeed(str));
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "retrieveArticles failure " + cat.getId(), e);
+ } catch (Throwable e) {
+ LOG.log(Level.SEVERE,
+ "retrieveArticles failure " + cat.getId() + " " + str,
+ e);
}
else
LOG.severe("No feed for category " + cat);
}
else
LOG.severe("No feed for category " + cat);
@@
-202,6
+218,7
@@
public class ArticleProvider {
articles.subList(0, 100));
}
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);
}
} catch (IllegalArgumentException | FeedException | IOException e) {
LOG.log(Level.SEVERE, "refresher failure", e);