Search in sources :

Example 1 with JournalArticleResource

use of com.liferay.portlet.journal.model.JournalArticleResource in project liferay-ide by liferay.

the class JournalArticleAssetRendererFactory method getAssetRenderer.

@Override
public AssetRenderer getAssetRenderer(long classPK, int type) throws PortalException, SystemException {
    JournalArticle article = null;
    try {
        article = JournalArticleLocalServiceUtil.getArticle(classPK);
    } catch (NoSuchArticleException nsae1) {
        JournalArticleResource articleResource = JournalArticleResourceLocalServiceUtil.getArticleResource(classPK);
        boolean approvedArticleAvailable = true;
        if (type == TYPE_LATEST_APPROVED) {
            try {
                article = JournalArticleLocalServiceUtil.getDisplayArticle(articleResource.getGroupId(), articleResource.getArticleId());
            } catch (NoSuchArticleException nsae2) {
                approvedArticleAvailable = false;
            }
        }
        if ((type != TYPE_LATEST_APPROVED) || !approvedArticleAvailable) {
            article = JournalArticleLocalServiceUtil.getLatestArticle(articleResource.getGroupId(), articleResource.getArticleId(), WorkflowConstants.STATUS_ANY);
        }
    }
    JournalArticleAssetRenderer journalArticleAssetRenderer = new JournalArticleAssetRenderer(article);
    journalArticleAssetRenderer.setAssetRendererType(type);
    return journalArticleAssetRenderer;
}
Also used : JournalArticleResource(com.liferay.portlet.journal.model.JournalArticleResource) NoSuchArticleException(com.liferay.portlet.journal.NoSuchArticleException) JournalArticle(com.liferay.portlet.journal.model.JournalArticle)

Aggregations

NoSuchArticleException (com.liferay.portlet.journal.NoSuchArticleException)1 JournalArticle (com.liferay.portlet.journal.model.JournalArticle)1 JournalArticleResource (com.liferay.portlet.journal.model.JournalArticleResource)1