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

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

Introduction

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

Prototype

public Group getSiteGroup() 

Source Link

Usage

From source file:com.liferay.exportimport.web.internal.portlet.action.ActionUtil.java

License:Open Source License

public static Group getGroup(HttpServletRequest request) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    String cmd = ParamUtil.getString(request, Constants.CMD);

    long groupId = ParamUtil.getLong(request, "groupId");

    Group group = null;/*from w  ww.  j  av  a2  s .c o  m*/

    if (groupId > 0) {
        group = GroupLocalServiceUtil.getGroup(groupId);
    } else if (!cmd.equals(Constants.ADD)) {
        group = themeDisplay.getSiteGroup();
    }

    request.setAttribute(WebKeys.GROUP, group);

    return group;
}

From source file:com.liferay.layout.admin.web.internal.portlet.GroupPagesPortlet.java

License:Open Source License

protected Group getGroup(PortletRequest portletRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Group group = themeDisplay.getSiteGroup();

    portletRequest.setAttribute(WebKeys.GROUP, group);

    return group;
}

From source file:com.liferay.staging.configuration.web.internal.portlet.configuration.icon.StagingPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Group group = themeDisplay.getSiteGroup();

    if (group.isStagedRemotely() || group.hasLocalOrRemoteStagingGroup()) {
        return false;
    }// w w w .  j ava  2 s  .  c o  m

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    String rootPortletId = portletDisplay.getRootPortletId();

    if (rootPortletId.equals(ExportImportPortletKeys.EXPORT)
            || rootPortletId.equals(ExportImportPortletKeys.EXPORT_IMPORT)
            || rootPortletId.equals(ExportImportPortletKeys.IMPORT)
            || rootPortletId.equals(StagingConfigurationPortletKeys.STAGING_CONFIGURATION)
            || rootPortletId.equals(StagingProcessesPortletKeys.STAGING_PROCESSES)) {

        return false;
    }

    if (!portletDisplay.isShowStagingIcon()) {
        return false;
    }

    try {
        return GroupPermissionUtil.contains(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroup(),
                ActionKeys.PUBLISH_PORTLET_INFO);
    } catch (PortalException pe) {

        // LPS-52675

        if (_log.isDebugEnabled()) {
            _log.debug(pe, pe);
        }

        return false;
    }
}

From source file:com.liferay.users.admin.web.internal.theme.contributor.UsersTemplateContextContributor.java

License:Open Source License

@Override
public void prepare(Map<String, Object> contextObjects, HttpServletRequest request) {

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

    User user = themeDisplay.getUser();//ww  w  . j  av a  2  s  . c  o m

    contextObjects.put("is_default_user", user.isDefaultUser());

    try {
        Contact contact = user.getContact();

        contextObjects.put("is_female", !contact.isMale());
        contextObjects.put("is_male", contact.isMale());
        contextObjects.put("user_birthday", contact.getBirthday());
    } catch (PortalException pe) {
        _log.error(pe, pe);
    }

    contextObjects.put("is_setup_complete", user.isSetupComplete());
    contextObjects.put("language", themeDisplay.getLanguageId());
    contextObjects.put("language_id", user.getLanguageId());
    contextObjects.put("user_comments", user.getComments());
    contextObjects.put("user_email_address", user.getEmailAddress());
    contextObjects.put("user_first_name", user.getFirstName());
    contextObjects.put("user_greeting", HtmlUtil.escape(user.getGreeting()));
    contextObjects.put("user_id", user.getUserId());
    contextObjects.put("user_initialized", true);
    contextObjects.put("user_last_login_ip", user.getLastLoginIP());
    contextObjects.put("user_last_name", user.getLastName());
    contextObjects.put("user_login_ip", user.getLoginIP());
    contextObjects.put("user_middle_name", user.getMiddleName());
    contextObjects.put("user_name", user.getFullName());

    Group group = themeDisplay.getSiteGroup();

    if (group.isUser()) {
        try {
            User user2 = _userLocalService.getUserById(group.getClassPK());

            contextObjects.put("user2", user2);
        } catch (PortalException pe) {
            _log.error(pe, pe);
        }
    }

    contextObjects.put("w3c_language_id", LocaleUtil.toW3cLanguageId(themeDisplay.getLanguageId()));
}