use of com.celements.blog.plugin.EmptyArticleException in project celements-blog by celements.
the class ArticleEngineHQL method getArticlesFromDocs.
private void getArticlesFromDocs(List<Article> articles, List<Object> articleDocNames, String blogArticleSpace) throws XWikiException {
LOGGER.debug("Matching articles found: " + articleDocNames.size());
for (Object articleFullNameObj : articleDocNames) {
String articleFullName = articleFullNameObj.toString();
XWikiDocument articleDoc = getContext().getWiki().getDocument(articleFullName, getContext());
Article article = null;
try {
article = new Article(articleDoc.newDocument(getContext()), getContext());
} catch (EmptyArticleException e) {
LOGGER.info(e);
}
if ((article != null) && (blogArticleSpace.equals(articleDoc.getSpace()) || (article.isSubscribable() == Boolean.TRUE))) {
articles.add(article);
}
}
}
use of com.celements.blog.plugin.EmptyArticleException in project celements-blog by celements.
the class ArticleEngineLucene method getArticles.
@Override
public List<Article> getArticles(ArticleLoadParameter param) throws ArticleLoadException {
try {
List<Article> articles = new ArrayList<>();
LuceneQuery query = queryBuilder.build(param);
if (query != null) {
LuceneSearchResult result = searchService.searchWithoutChecks(query, param.getSortFields(), Arrays.asList("default", param.getLanguage()));
result.setOffset(param.getOffset()).setLimit(param.getLimit());
for (EntityReference ref : result.getResults()) {
if (ref instanceof DocumentReference) {
XWikiDocument doc = getContext().getWiki().getDocument((DocumentReference) ref, getContext());
try {
articles.add(new Article(doc, getContext()));
} catch (EmptyArticleException exc) {
LOGGER.warn("getArticles: empty article '{}'", exc, doc);
}
} else {
LOGGER.warn("getArticles: not expecting Attachment as search result '{}' " + "for search '{}'", ref, param);
}
}
} else {
LOGGER.warn("got null from query builder for '" + param + "'");
}
return articles;
} catch (LuceneSearchException lse) {
throw new ArticleLoadException(lse);
} catch (XWikiException xwe) {
throw new ArticleLoadException(xwe);
}
}
Aggregations