Example usage for com.liferay.portal.kernel.model Group getDefaultPublicPlid

List of usage examples for com.liferay.portal.kernel.model Group getDefaultPublicPlid

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model Group getDefaultPublicPlid.

Prototype

public long getDefaultPublicPlid();

Source Link

Usage

From source file:com.liferay.calendar.notification.impl.NotificationTemplateContextFactory.java

License:Open Source License

private static String _getCalendarBookingURL(User user, long calendarBookingId) throws PortalException {

    Group group = GroupLocalServiceUtil.getGroup(user.getCompanyId(), GroupConstants.GUEST);

    Layout layout = LayoutLocalServiceUtil.fetchLayout(group.getDefaultPublicPlid());

    String portalURL = _getPortalURL(group.getCompanyId(), group.getGroupId());

    String layoutActualURL = PortalUtil.getLayoutActualURL(layout);

    String url = portalURL + layoutActualURL;

    String namespace = PortalUtil.getPortletNamespace(CalendarPortletKeys.CALENDAR);

    url = HttpUtil.addParameter(url, namespace + "mvcPath", "/view_calendar_booking.jsp");

    url = HttpUtil.addParameter(url, "p_p_id", CalendarPortletKeys.CALENDAR);
    url = HttpUtil.addParameter(url, "p_p_lifecycle", "0");
    url = HttpUtil.addParameter(url, "p_p_state", WindowState.MAXIMIZED.toString());
    url = HttpUtil.addParameter(url, namespace + "calendarBookingId", calendarBookingId);

    return url;/*from   ww  w  .  j a  v a2 s. c o m*/
}

From source file:com.liferay.mobile.device.rules.rule.group.action.SiteRedirectActionHandler.java

License:Open Source License

@Override
protected String getURL(MDRAction mdrAction, HttpServletRequest request, HttpServletResponse response)
        throws PortalException {

    UnicodeProperties typeSettingsProperties = mdrAction.getTypeSettingsProperties();

    long plid = GetterUtil.getLong(typeSettingsProperties.getProperty("plid"));

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

    Layout themeDisplayLayout = themeDisplay.getLayout();

    if (plid == themeDisplayLayout.getPlid()) {
        return null;
    }/*from ww w .  j  a v  a 2 s. c  o m*/

    Layout layout = _layoutLocalService.fetchLayout(plid);

    long groupId = GetterUtil.getLong(typeSettingsProperties.getProperty("groupId"));

    if ((layout != null) && (layout.getGroupId() != groupId)) {
        if (_log.isWarnEnabled()) {
            _log.warn(StringBundler.concat("Layout ", String.valueOf(layout.getPlid()),
                    " does not belong to group ", String.valueOf(groupId)));
        }

        layout = null;
    }

    if (layout == null) {
        if (_log.isWarnEnabled()) {
            _log.warn("Using default public layout");
        }

        Group group = null;

        if (groupId != themeDisplayLayout.getGroupId()) {
            group = _groupLocalService.fetchGroup(groupId);
        }

        if (group == null) {
            if (_log.isWarnEnabled()) {
                _log.warn("No group found with group ID " + groupId);
            }

            return null;
        }

        layout = _layoutLocalService.fetchLayout(group.getDefaultPublicPlid());
    }

    if (layout != null) {
        return _portal.getLayoutURL(layout, themeDisplay);
    }

    if (_log.isWarnEnabled()) {
        _log.warn("Unable to resolve default layout");
    }

    return null;
}