Example usage for com.liferay.portal.kernel.theme ThemeDisplay getLayoutSet

List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getLayoutSet

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme ThemeDisplay getLayoutSet.

Prototype

public LayoutSet getLayoutSet() 

Source Link

Document

Returns the current layout set, being either a public layout set or a private layout set.

Usage

From source file:com.liferay.journal.util.impl.JournalContentImpl.java

License:Open Source License

@Override
public JournalArticleDisplay getDisplay(JournalArticle article, String ddmTemplateKey, String viewMode,
        String languageId, int page, PortletRequestModel portletRequestModel, ThemeDisplay themeDisplay) {

    StopWatch stopWatch = new StopWatch();

    stopWatch.start();/*from  ww  w .  j  a  va2 s .  c  o m*/

    long groupId = article.getGroupId();
    String articleId = article.getArticleId();
    double version = article.getVersion();

    articleId = StringUtil.toUpperCase(GetterUtil.getString(articleId));
    ddmTemplateKey = StringUtil.toUpperCase(GetterUtil.getString(ddmTemplateKey));

    long layoutSetId = 0;
    boolean secure = false;

    if (themeDisplay != null) {
        try {
            if (!JournalArticlePermission.contains(themeDisplay.getPermissionChecker(), article,
                    ActionKeys.VIEW)) {

                return null;
            }
        } catch (Exception e) {
        }

        LayoutSet layoutSet = themeDisplay.getLayoutSet();

        layoutSetId = layoutSet.getLayoutSetId();

        secure = themeDisplay.isSecure();
    }

    JournalContentKey journalContentKey = new JournalContentKey(groupId, articleId, version, ddmTemplateKey,
            layoutSetId, viewMode, languageId, page, secure);

    JournalArticleDisplay articleDisplay = _portalCache.get(journalContentKey);

    boolean lifecycleRender = false;

    if (portletRequestModel != null) {
        lifecycleRender = RenderRequest.RENDER_PHASE.equals(portletRequestModel.getLifecycle());
    }

    if ((articleDisplay == null) || !lifecycleRender) {
        articleDisplay = getArticleDisplay(article, ddmTemplateKey, viewMode, languageId, page,
                portletRequestModel, themeDisplay);

        if ((articleDisplay != null) && articleDisplay.isCacheable() && lifecycleRender) {

            _portalCache.put(journalContentKey, articleDisplay);
        }
    }

    if (_log.isDebugEnabled()) {
        _log.debug("getDisplay for {" + groupId + ", " + articleId + ", " + ddmTemplateKey + ", " + viewMode
                + ", " + languageId + ", " + page + "} takes " + stopWatch.getTime() + " ms");
    }

    return articleDisplay;
}