/**
* Returns a copy.
*/
- public List<Article> getArticles(Category cat)
+ public List<Article> getArticles(Category cat, String entity)
throws IllegalArgumentException, MalformedURLException, FeedException, IOException {
- List<Article> articles;
+ List<Article> articles, result;
synchronized (articlesByCategory) {
articles = getArticlesForUpdate(cat);
}
- synchronized (articles) {
- return new ArrayList<>(articles);
+ synchronized (articles) {
+ if (entity == null)
+ return new ArrayList<>(articles);
+
+ result = new ArrayList<>(articles.size());
+ for (Article a: articles)
+ if (a.hasEntity(entity))
+ result.add(a);
+
+ return result;
}
}
LOG.entering(CLASS_NAME, FUNCTION_NAME, cat);
- articles = getArticles(cat);
+ articles = getArticles(cat, null);
entities = new HashMap<>();
for (Article a: articles)