Example usage for com.liferay.portal.kernel.util PropsKeys DEFAULT_LANDING_PAGE_PATH

List of usage examples for com.liferay.portal.kernel.util PropsKeys DEFAULT_LANDING_PAGE_PATH

Introduction

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

Prototype

String DEFAULT_LANDING_PAGE_PATH

To view the source code for com.liferay.portal.kernel.util PropsKeys DEFAULT_LANDING_PAGE_PATH.

Click Source Link

Usage

From source file:org.lsp.liferay.portlet.advertising.events.AdvertisingLandingPageAction.java

License:Open Source License

public void run(HttpServletRequest request, HttpServletResponse response) {

    long userId = PortalUtil.getUserId(request);
    long companyId = PortalUtil.getCompanyId(request);

    String path;//from  w  w w .  ja v a2 s .c o  m
    try {
        path = PrefsPropsUtil.getString(companyId, PropsKeys.DEFAULT_LANDING_PAGE_PATH);

        if (_log.isDebugEnabled()) {
            _log.debug(PropsKeys.DEFAULT_LANDING_PAGE_PATH + StringPool.EQUAL + path);
        }

        long campaignIdToDisplay = CampaignLocalServiceUtil.getCampaignIdToDisplay(companyId, userId);

        _log.debug("Redirecting User to: " + path);
        LastPath lastPath = new LastPath(request.getContextPath(), path);
        if (_log.isDebugEnabled()) {
            _log.debug("lastPath = " + lastPath.toString());
        }
        HttpSession session = request.getSession();
        session.setAttribute(WebKeys.LAST_PATH, lastPath);

        if (campaignIdToDisplay > 0) {
            session.setAttribute(CampaignConstants.CAMPAIGN_HEADER,
                    CampaignLocalServiceUtil.getCampaign(campaignIdToDisplay).getJournalArticlePrimaryKey());
            CampaignLogLocalServiceUtil.markDisplayed(campaignIdToDisplay, userId);
        }

    } catch (SystemException e) {
        _log.error(e.getMessage(), e);
    } catch (PortalException e) {
        _log.error(e.getMessage(), e);
    }

}

From source file:org.opencps.hook.events.DefaultLandingPageAction.java

License:Open Source License

protected void doRun(HttpServletRequest request, HttpServletResponse response) throws Exception {
    HttpSession session = request.getSession();

    User user = (User) session.getAttribute(org.opencps.util.WebKeys.USER);

    long companyId = PortalUtil.getCompanyId(request);

    String path = StringPool.BLANK;

    for (UserGroup userGroup : user.getUserGroups()) {
        if (userGroup.getName().equalsIgnoreCase(PortletPropsValues.USERMGT_USERGROUP_NAME_CITIZEN)) {
            path = com.liferay.portal.kernel.util.PrefsPropsUtil.getString(companyId,
                    "default.landing.page.path.citizen");
        } else if (userGroup.getName().equalsIgnoreCase(PortletPropsValues.USERMGT_USERGROUP_NAME_BUSINESS)) {
            path = com.liferay.portal.kernel.util.PrefsPropsUtil.getString(companyId,
                    "default.landing.page.path.business");
        } else if (userGroup.getName().equalsIgnoreCase(PortletPropsValues.USERMGT_USERGROUP_NAME_EMPLOYEE)) {
            path = com.liferay.portal.kernel.util.PrefsPropsUtil.getString(companyId,
                    "default.landing.page.path.employee");
        } else {//from  ww  w  .  j  a v a2s  . c  o  m
            path = com.liferay.portal.kernel.util.PrefsPropsUtil.getString(companyId,
                    PropsKeys.DEFAULT_LANDING_PAGE_PATH);
        }
    }

    if (_log.isInfoEnabled()) {
        _log.info("Pathhh" + PropsKeys.DEFAULT_LANDING_PAGE_PATH + StringPool.EQUAL + path);
    }

    if (Validator.isNull(path)) {
        return;
    }

    if (path.contains("${liferay:screenName}") || path.contains("${liferay:userId}")) {

        if (user == null) {
            return;
        }

        path = StringUtil.replace(path, new String[] { "${liferay:screenName}", "${liferay:userId}" },
                new String[] { HtmlUtil.escapeURL(user.getScreenName()), String.valueOf(user.getUserId()) });
    }

    LastPath lastPath = new LastPath(StringPool.BLANK, path);

    session.setAttribute(org.opencps.util.WebKeys.LAST_PATH, lastPath);
}