001
014
015 package com.liferay.portlet.journalcontent.action;
016
017 import com.liferay.portal.kernel.language.LanguageUtil;
018 import com.liferay.portal.kernel.util.GetterUtil;
019 import com.liferay.portal.kernel.util.ParamUtil;
020 import com.liferay.portal.kernel.util.StringPool;
021 import com.liferay.portal.kernel.util.Validator;
022 import com.liferay.portal.theme.ThemeDisplay;
023 import com.liferay.portal.util.WebKeys;
024 import com.liferay.portlet.journal.model.JournalArticleDisplay;
025 import com.liferay.portlet.journalcontent.util.JournalContentUtil;
026 import com.liferay.util.portlet.PortletRequestUtil;
027
028 import javax.portlet.PortletConfig;
029 import javax.portlet.PortletPreferences;
030 import javax.portlet.RenderRequest;
031 import javax.portlet.RenderResponse;
032
033 import org.apache.struts.action.ActionForm;
034 import org.apache.struts.action.ActionForward;
035 import org.apache.struts.action.ActionMapping;
036
037
041 public class ViewAction extends WebContentAction {
042
043 public ActionForward render(
044 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
045 RenderRequest renderRequest, RenderResponse renderResponse)
046 throws Exception {
047
048 PortletPreferences preferences = renderRequest.getPreferences();
049
050 ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest.getAttribute(
051 WebKeys.THEME_DISPLAY);
052
053 long groupId = ParamUtil.getLong(renderRequest, "groupId");
054
055 if (groupId < 1) {
056 groupId = GetterUtil.getLong(
057 preferences.getValue("group-id", StringPool.BLANK));
058 }
059
060 String articleId = ParamUtil.getString(renderRequest, "articleId");
061 String templateId = ParamUtil.getString(renderRequest, "templateId");
062
063 if (Validator.isNull(articleId)) {
064 articleId = GetterUtil.getString(
065 preferences.getValue("article-id", StringPool.BLANK));
066 templateId = GetterUtil.getString(
067 preferences.getValue("template-id", StringPool.BLANK));
068 }
069
070 String viewMode = ParamUtil.getString(renderRequest, "viewMode");
071 String languageId = LanguageUtil.getLanguageId(renderRequest);
072 int page = ParamUtil.getInteger(renderRequest, "page", 1);
073 String xmlRequest = PortletRequestUtil.toXML(
074 renderRequest, renderResponse);
075
076 JournalArticleDisplay articleDisplay = null;
077
078 if ((groupId > 0) && Validator.isNotNull(articleId)) {
079 articleDisplay = JournalContentUtil.getDisplay(
080 groupId, articleId, templateId, viewMode, languageId,
081 themeDisplay, page, xmlRequest);
082 }
083
084 if (articleDisplay != null) {
085 renderRequest.setAttribute(
086 WebKeys.JOURNAL_ARTICLE_DISPLAY, articleDisplay);
087 }
088 else {
089 renderRequest.removeAttribute(WebKeys.JOURNAL_ARTICLE_DISPLAY);
090 }
091
092 return mapping.findForward("portlet.journal_content.view");
093 }
094
095 }