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();
}
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;
}
Aggregations