Search in sources :

Example 1 with JournalArticle

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

the class KBArticleAssetEntriesUtil method getURL.

public static String getURL(HttpServletRequest request, ThemeDisplay themeDisplay, AssetRendererFactory assetRendererFactory, AssetRenderer assetRenderer) throws Exception {
    long classPK = assetRenderer.getClassPK();
    String className = assetRendererFactory.getClassName();
    PortletURL portletURL = null;
    if (className.equals(BlogsEntry.class.getName())) {
        portletURL = PortletURLFactoryUtil.create(request, PortletKeys.BLOGS, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
        portletURL.setParameter("struts_action", "/blogs/view_entry");
        portletURL.setParameter("entryId", String.valueOf(classPK));
    } else if (className.equals(JournalArticle.class.getName())) {
        JournalArticle journalArticle = JournalArticleLocalServiceUtil.getLatestArticle(classPK);
        portletURL = PortletURLFactoryUtil.create(request, PortletKeys.JOURNAL_CONTENT, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
        portletURL.setParameter("struts_action", "/journal_content/view");
        portletURL.setParameter("groupId", String.valueOf(journalArticle.getGroupId()));
        portletURL.setParameter("articleId", journalArticle.getArticleId());
    } else if (className.equals(KBArticle.class.getName())) {
        portletURL = PortletURLFactoryUtil.create(request, PortletKeys.KNOWLEDGE_BASE_ARTICLE_DEFAULT_INSTANCE, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
        portletURL.setParameter("mvcPath", "/article/view_article.jsp");
        portletURL.setParameter("resourcePrimKey", String.valueOf(classPK));
    } else if (className.equals(MBMessage.class.getName())) {
        portletURL = PortletURLFactoryUtil.create(request, PortletKeys.MESSAGE_BOARDS, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
        portletURL.setParameter("struts_action", "/message_boards/view_message");
        portletURL.setParameter("messageId", String.valueOf(classPK));
    } else if (className.equals(WikiPage.class.getName())) {
        WikiPage wikiPage = WikiPageLocalServiceUtil.getPage(classPK);
        portletURL = PortletURLFactoryUtil.create(request, PortletKeys.WIKI, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
        portletURL.setParameter("struts_action", "/wiki/view");
        portletURL.setParameter("nodeId", String.valueOf(wikiPage.getNodeId()));
        portletURL.setParameter("title", wikiPage.getTitle());
    }
    String currentURL = PortalUtil.getCurrentURL(request);
    if (portletURL == null) {
        return currentURL;
    }
    portletURL.setWindowState(WindowState.MAXIMIZED);
    portletURL.setPortletMode(PortletMode.VIEW);
    portletURL.setParameter("returnToFullPageURL", currentURL);
    return portletURL.toString();
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) WikiPage(com.liferay.portlet.wiki.model.WikiPage) PortletURL(javax.portlet.PortletURL) BlogsEntry(com.liferay.portlet.blogs.model.BlogsEntry) JournalArticle(com.liferay.portlet.journal.model.JournalArticle)

Example 2 with JournalArticle

use of com.liferay.portlet.journal.model.JournalArticle 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

JournalArticle (com.liferay.portlet.journal.model.JournalArticle)2 KBArticle (com.liferay.knowledgebase.model.KBArticle)1 BlogsEntry (com.liferay.portlet.blogs.model.BlogsEntry)1 NoSuchArticleException (com.liferay.portlet.journal.NoSuchArticleException)1 JournalArticleResource (com.liferay.portlet.journal.model.JournalArticleResource)1 WikiPage (com.liferay.portlet.wiki.model.WikiPage)1 PortletURL (javax.portlet.PortletURL)1