Example usage for com.liferay.portal.kernel.util WebKeys JOURNAL_ARTICLE

List of usage examples for com.liferay.portal.kernel.util WebKeys JOURNAL_ARTICLE

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util WebKeys JOURNAL_ARTICLE.

Prototype

String JOURNAL_ARTICLE

To view the source code for com.liferay.portal.kernel.util WebKeys JOURNAL_ARTICLE.

Click Source Link

Usage

From source file:com.liferay.journal.content.web.internal.display.context.JournalContentDisplayContext.java

License:Open Source License

public JournalArticle getArticle() {
    if (_article != null) {
        return _article;
    }//from   w w w.ja v  a  2s . c  o m

    _article = (JournalArticle) _portletRequest.getAttribute(WebKeys.JOURNAL_ARTICLE);

    if (_article != null) {
        return _article;
    }

    long articleResourcePrimKey = ParamUtil.getLong(_portletRequest, "articleResourcePrimKey");

    if (articleResourcePrimKey > 0) {
        _article = JournalArticleLocalServiceUtil.fetchLatestArticle(articleResourcePrimKey,
                WorkflowConstants.STATUS_ANY, true);
    } else {
        _article = JournalArticleLocalServiceUtil.fetchLatestArticle(getArticleGroupId(), getArticleId(),
                WorkflowConstants.STATUS_ANY);
    }

    return _article;
}

From source file:com.liferay.journal.content.web.internal.display.context.JournalContentDisplayContext.java

License:Open Source License

public List<ContentMetadataAssetAddonEntry> getSelectedContentMetadataAssetAddonEntries() {

    if (_contentMetadataAssetAddonEntries != null) {
        return _contentMetadataAssetAddonEntries;
    }/* w w  w .  j av a2s.c om*/

    _contentMetadataAssetAddonEntries = new ArrayList<>();

    String contentMetadataAssetAddonEntryKeysKeysString = _journalContentPortletInstanceConfiguration
            .contentMetadataAssetAddonEntryKeys();

    if (Validator.isNull(contentMetadataAssetAddonEntryKeysKeysString)) {
        return _contentMetadataAssetAddonEntries;
    }

    String[] contentMetadataAssetAddonEntryKeys = StringUtil
            .split(contentMetadataAssetAddonEntryKeysKeysString);

    for (String contentMetadataAssetAddonEntryKey : contentMetadataAssetAddonEntryKeys) {

        ContentMetadataAssetAddonEntry contentMetadataAssetAddonEntry = ContentMetadataAssetAddonEntryTracker
                .getContentMetadataAssetAddonEntry(contentMetadataAssetAddonEntryKey);

        if (contentMetadataAssetAddonEntry != null) {
            _contentMetadataAssetAddonEntries.add(contentMetadataAssetAddonEntry);
        }
    }

    _portletRequest.setAttribute(WebKeys.JOURNAL_ARTICLE, getArticle());
    _portletRequest.setAttribute(WebKeys.JOURNAL_ARTICLE_DISPLAY, getArticleDisplay());

    return _contentMetadataAssetAddonEntries;
}

From source file:com.liferay.journal.content.web.internal.display.context.JournalContentDisplayContext.java

License:Open Source License

public List<UserToolAssetAddonEntry> getSelectedUserToolAssetAddonEntries() {

    if (_userToolAssetAddonEntries != null) {
        return _userToolAssetAddonEntries;
    }/*w  w w . j  a  va2  s  .co  m*/

    _userToolAssetAddonEntries = new ArrayList<>();

    String userToolAssetAddonEntryKeysString = _journalContentPortletInstanceConfiguration
            .userToolAssetAddonEntryKeys();

    if (Validator.isNull(userToolAssetAddonEntryKeysString)) {
        return _userToolAssetAddonEntries;
    }

    String[] userToolAssetAddonEntryKeys = StringUtil.split(userToolAssetAddonEntryKeysString);

    for (String userToolAssetAddonEntryKey : userToolAssetAddonEntryKeys) {
        UserToolAssetAddonEntry userToolAssetAddonEntry = UserToolAssetAddonEntryTracker
                .getUserToolAssetAddonEntry(userToolAssetAddonEntryKey);

        if (userToolAssetAddonEntry != null) {
            _userToolAssetAddonEntries.add(userToolAssetAddonEntry);
        }
    }

    _portletRequest.setAttribute(WebKeys.JOURNAL_ARTICLE, getArticle());
    _portletRequest.setAttribute(WebKeys.JOURNAL_ARTICLE_DISPLAY, getArticleDisplay());

    return _userToolAssetAddonEntries;
}

From source file:com.liferay.journal.content.web.internal.portlet.JournalContentPortlet.java

License:Open Source License

@Override
public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
        throws IOException, PortletException {

    PortletPreferences portletPreferences = renderRequest.getPreferences();

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long articleGroupId = PrefsParamUtil.getLong(portletPreferences, renderRequest, "groupId",
            themeDisplay.getScopeGroupId());

    String articleId = PrefsParamUtil.getString(portletPreferences, renderRequest, "articleId");
    String ddmTemplateKey = PrefsParamUtil.getString(portletPreferences, renderRequest, "ddmTemplateKey");

    JournalArticle article = null;/*ww w. j  av a 2  s . c  o  m*/
    JournalArticleDisplay articleDisplay = null;

    if ((articleGroupId > 0) && Validator.isNotNull(articleId)) {
        String viewMode = ParamUtil.getString(renderRequest, "viewMode");
        String languageId = LanguageUtil.getLanguageId(renderRequest);
        int page = ParamUtil.getInteger(renderRequest, "page", 1);

        article = _journalArticleLocalService.fetchLatestArticle(articleGroupId, articleId,
                WorkflowConstants.STATUS_APPROVED);

        try {
            if (article == null) {
                article = _journalArticleLocalService.getLatestArticle(articleGroupId, articleId,
                        WorkflowConstants.STATUS_ANY);
            }

            if (Validator.isNull(ddmTemplateKey)) {
                ddmTemplateKey = article.getDDMTemplateKey();
            }

            articleDisplay = _journalContent.getDisplay(article, ddmTemplateKey, viewMode, languageId, page,
                    new PortletRequestModel(renderRequest, renderResponse), themeDisplay);
        } catch (Exception e) {
            renderRequest.removeAttribute(WebKeys.JOURNAL_ARTICLE);
        }
    }

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

    super.doView(renderRequest, renderResponse);
}

From source file:com.liferay.journal.web.asset.JournalArticleAssetRenderer.java

License:Open Source License

@Override
public boolean include(HttpServletRequest request, HttpServletResponse response, String template)
        throws Exception {

    request.setAttribute(WebKeys.JOURNAL_ARTICLE, _article);

    request.setAttribute(WebKeys.JOURNAL_ARTICLE_DISPLAY, getArticleDisplay(request, response));

    return super.include(request, response, template);
}