@Override public ActionForward render( ActionMapping mapping, ActionForm form, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { PortletPreferences preferences = renderRequest.getPreferences(); ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); long groupId = ParamUtil.getLong(renderRequest, "groupId"); if (groupId <= 0) { groupId = GetterUtil.getLong(preferences.getValue("groupId", StringPool.BLANK)); } String articleId = ParamUtil.getString(renderRequest, "articleId"); String templateId = ParamUtil.getString(renderRequest, "templateId"); if (Validator.isNull(articleId)) { articleId = GetterUtil.getString(preferences.getValue("articleId", StringPool.BLANK)); templateId = GetterUtil.getString(preferences.getValue("templateId", StringPool.BLANK)); } String viewMode = ParamUtil.getString(renderRequest, "viewMode"); String languageId = LanguageUtil.getLanguageId(renderRequest); int page = ParamUtil.getInteger(renderRequest, "page", 1); String xmlRequest = PortletRequestUtil.toXML(renderRequest, renderResponse); JournalArticle article = null; JournalArticleDisplay articleDisplay = null; if ((groupId > 0) && Validator.isNotNull(articleId)) { try { article = JournalArticleLocalServiceUtil.getLatestArticle( groupId, articleId, WorkflowConstants.STATUS_ANY); double version = article.getVersion(); articleDisplay = JournalContentUtil.getDisplay( groupId, articleId, version, templateId, viewMode, languageId, themeDisplay, page, xmlRequest); } catch (Exception e) { renderRequest.removeAttribute(WebKeys.JOURNAL_ARTICLE); articleDisplay = JournalContentUtil.getDisplay( groupId, articleId, templateId, viewMode, languageId, themeDisplay, page, xmlRequest); } } if (article != null) { renderRequest.setAttribute(WebKeys.JOURNAL_ARTICLE, article); } if (articleDisplay != null) { renderRequest.setAttribute(WebKeys.JOURNAL_ARTICLE_DISPLAY, articleDisplay); } else { renderRequest.removeAttribute(WebKeys.JOURNAL_ARTICLE_DISPLAY); } return mapping.findForward("portlet.journal_content.view"); }
protected String processContent( JournalFeed feed, JournalArticle article, String languageId, ThemeDisplay themeDisplay, SyndEntry syndEntry, SyndContent syndContent) throws Exception { String content = article.getDescription(languageId); String contentField = feed.getContentField(); if (contentField.equals(JournalFeedConstants.RENDERED_WEB_CONTENT)) { String rendererTemplateId = article.getTemplateId(); if (Validator.isNotNull(feed.getRendererTemplateId())) { rendererTemplateId = feed.getRendererTemplateId(); } JournalArticleDisplay articleDisplay = JournalContentUtil.getDisplay( feed.getGroupId(), article.getArticleId(), rendererTemplateId, null, languageId, themeDisplay, 1, _XML_REQUUEST); if (articleDisplay != null) { content = articleDisplay.getContent(); } } else if (!contentField.equals(JournalFeedConstants.WEB_CONTENT_DESCRIPTION)) { Document document = SAXReaderUtil.read(article.getContentByLocale(languageId)); contentField = HtmlUtil.escapeXPathAttribute(contentField); XPath xPathSelector = SAXReaderUtil.createXPath("//dynamic-element[@name=" + contentField + "]"); List<Node> results = xPathSelector.selectNodes(document); if (results.size() == 0) { return content; } Element element = (Element) results.get(0); String elType = element.attributeValue("type"); if (elType.equals("document_library")) { String url = element.elementText("dynamic-content"); url = processURL(feed, url, themeDisplay, syndEntry); } else if (elType.equals("image") || elType.equals("image_gallery")) { String url = element.elementText("dynamic-content"); url = processURL(feed, url, themeDisplay, syndEntry); content = content + "<br /><br /><img alt='' src='" + themeDisplay.getURLPortal() + url + "' />"; } else if (elType.equals("text_box")) { syndContent.setType("text"); content = element.elementText("dynamic-content"); } else { content = element.elementText("dynamic-content"); } } return content; }