Example usage for com.liferay.portal.kernel.util PortalUtil addPreservedParameters

List of usage examples for com.liferay.portal.kernel.util PortalUtil addPreservedParameters

Introduction

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

Prototype

public static String addPreservedParameters(ThemeDisplay themeDisplay, String url) 

Source Link

Document

Adds the preserved parameters doAsUserId, doAsUserLanguageId, doAsGroupId, and refererPlid to the URL.

Usage

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

License:Open Source License

@Override
public String getURLViewInContext(LiferayPortletRequest liferayPortletRequest,
        LiferayPortletResponse liferayPortletResponse, String noSuchEntryRedirect) throws Exception {

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

    Layout layout = _article.getLayout();

    if (layout == null) {
        layout = themeDisplay.getLayout();
    }/*from  www.j a  v  a2  s . co  m*/

    String portletId = (String) liferayPortletRequest.getAttribute(WebKeys.PORTLET_ID);

    PortletPreferences portletSetup = PortletPreferencesFactoryUtil.getStrictLayoutPortletSetup(layout,
            portletId);

    String linkToLayoutUuid = GetterUtil.getString(portletSetup.getValue("portletSetupLinkToLayoutUuid", null));

    if (Validator.isNotNull(_article.getLayoutUuid()) && Validator.isNull(linkToLayoutUuid)) {

        Group group = themeDisplay.getScopeGroup();

        if (group.getGroupId() != _article.getGroupId()) {
            group = GroupLocalServiceUtil.getGroup(_article.getGroupId());
        }

        String groupFriendlyURL = PortalUtil.getGroupFriendlyURL(
                LayoutSetLocalServiceUtil.getLayoutSet(group.getGroupId(), layout.isPrivateLayout()),
                themeDisplay);

        return PortalUtil.addPreservedParameters(themeDisplay, groupFriendlyURL
                .concat(JournalArticleConstants.CANONICAL_URL_SEPARATOR).concat(_article.getUrlTitle()));
    }

    String hitLayoutURL = getHitLayoutURL(layout.isPrivateLayout(), noSuchEntryRedirect, themeDisplay);

    if (hitLayoutURL.equals(noSuchEntryRedirect)) {
        hitLayoutURL = getHitLayoutURL(!layout.isPrivateLayout(), noSuchEntryRedirect, themeDisplay);
    }

    return hitLayoutURL;
}