Search in sources :

Example 1 with GenericEntityNotFoundException

use of org.summerb.approaches.jdbccrud.api.exceptions.GenericEntityNotFoundException in project summerb by skarpushin.

the class ArticleRenderingContext method getReferencedArticle.

protected Article getReferencedArticle(String articleKey) throws GenericEntityNotFoundException {
    if (referencedArticles.containsKey(articleKey)) {
        return referencedArticles.get(articleKey);
    }
    try {
        Article ret = articleService.findArticleByKeyAndLocale(articleKey, locale);
        if (ret == null) {
            throw new GenericEntityNotFoundException("article", articleKey);
        }
        referencedArticles.put(articleKey, ret);
        registerReferencedArticle(ret.getId());
        return ret;
    } catch (Throwable e) {
        Throwables.throwIfInstanceOf(e, GenericEntityNotFoundException.class);
        throw new RuntimeException("Failed to find effective referenced article permutation " + articleKey, e);
    }
}
Also used : RenderedArticle(org.summerb.microservices.articles.api.dto.consuming.RenderedArticle) Article(org.summerb.microservices.articles.api.dto.Article) GenericEntityNotFoundException(org.summerb.approaches.jdbccrud.api.exceptions.GenericEntityNotFoundException)

Aggregations

GenericEntityNotFoundException (org.summerb.approaches.jdbccrud.api.exceptions.GenericEntityNotFoundException)1 Article (org.summerb.microservices.articles.api.dto.Article)1 RenderedArticle (org.summerb.microservices.articles.api.dto.consuming.RenderedArticle)1