Example usage for com.liferay.portal.kernel.portlet PortletRequestModel PortletRequestModel

List of usage examples for com.liferay.portal.kernel.portlet PortletRequestModel PortletRequestModel

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.portlet PortletRequestModel PortletRequestModel.

Prototype

protected PortletRequestModel() 

Source Link

Usage

From source file:com.liferay.journal.web.util.JournalRSSUtil.java

License:Open Source License

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 ddmRendererTemplateKey = article.getDDMTemplateKey();

        if (Validator.isNotNull(feed.getDDMRendererTemplateKey())) {
            ddmRendererTemplateKey = feed.getDDMRendererTemplateKey();
        }// w  w  w .j  a  v  a 2s  .  c  om

        JournalArticleDisplay articleDisplay = _journalContent.getDisplay(feed.getGroupId(),
                article.getArticleId(), ddmRendererTemplateKey, null, languageId, 1, new PortletRequestModel() {

                    @Override
                    public String toXML() {
                        return _XML_REQUUEST;
                    }

                }, themeDisplay);

        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.isEmpty()) {
            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;
}