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

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

Introduction

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

Prototype

public Group getScopeGroup() 

Source Link

Document

Returns the scoped or sub-scoped active group (e.g.

Usage

From source file:com.liferay.site.teams.web.internal.display.context.SiteTeamsDisplayContext.java

License:Open Source License

public boolean isShowAddButton() throws PortalException {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    if (GroupPermissionUtil.contains(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroup(),
            ActionKeys.MANAGE_TEAMS)) {/*  ww  w  .  j a  v a2s  .  co  m*/

        return true;
    }

    return false;
}

From source file:com.liferay.site.teams.web.internal.display.context.SiteTeamsDisplayContext.java

License:Open Source License

protected void addBreadcrumbEntries() throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    Group group = themeDisplay.getScopeGroup();

    if (group.isOrganization()) {
        Organization organization = OrganizationLocalServiceUtil.getOrganization(group.getOrganizationId());

        UsersAdminUtil.addPortletBreadcrumbEntries(organization, _request, _renderResponse);
    } else {// w w  w  .  ja va  2 s .co  m
        PortalUtil.addPortletBreadcrumbEntry(_request, group.getDescriptiveName(themeDisplay.getLocale()),
                null);
    }

    PortalUtil.addPortletBreadcrumbEntry(_request, LanguageUtil.get(_request, "manage-teams"),
            themeDisplay.getURLCurrent());
}

From source file:com.liferay.social.activities.web.internal.portlet.display.context.util.SocialActivitiesRequestHelper.java

License:Open Source License

public Group getScopeGroup() {
    if (_scopeGroup == null) {
        ThemeDisplay themeDisplay = getThemeDisplay();

        _scopeGroup = themeDisplay.getScopeGroup();
    }//from www . j av  a  2  s.c  om

    return _scopeGroup;
}

From source file:com.liferay.staging.bar.web.internal.theme.contributor.StagingBarTemplateContextContributor.java

License:Open Source License

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

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

    try {/*w  w  w . j  av a  2s. co  m*/
        if (_stagingProductNavigationControlMenuEntry.isShow(request)) {
            StringBuilder sb = new StringBuilder();

            sb.append(GetterUtil.getString(contextObjects.get("bodyCssClass")));
            sb.append(StringPool.SPACE);
            sb.append("has-staging-bar");

            Group group = themeDisplay.getScopeGroup();

            if (group.isStagingGroup()) {
                sb.append(StringPool.SPACE);
                sb.append("staging local-staging");
            } else if (themeDisplay.isShowStagingIcon() && group.hasStagingGroup()) {

                sb.append(StringPool.SPACE);
                sb.append("live-view");
            } else if (themeDisplay.isShowStagingIcon() && group.isStagedRemotely()) {

                sb.append(StringPool.SPACE);
                sb.append("staging remote-staging");
            }

            contextObjects.put("bodyCssClass", sb.toString());
        }
    } catch (PortalException pe) {
        _log.error(pe, pe);
    }

    contextObjects.put("show_staging", themeDisplay.isShowStagingIcon());

    if (themeDisplay.isShowStagingIcon()) {
        contextObjects.put("staging_text", LanguageUtil.get(request, "staging"));
    }
}

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;
    }//from w w  w . ja v  a2  s  .  com

    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.staging.processes.web.internal.portlet.configuration.icon.PublishTemplatesConfigurationIcon.java

License:Open Source License

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

    Group scopeGroup = themeDisplay.getScopeGroup();

    if ((scopeGroup != null) && (scopeGroup.hasStagingGroup()
            || (scopeGroup.hasRemoteStagingGroup() && !scopeGroup.isStagedRemotely())
            || (!scopeGroup.isStaged() && !scopeGroup.isStagingGroup()))) {

        return false;
    }/* w  w w .  ja  v a2 s.c  o  m*/

    User user = themeDisplay.getUser();

    if (user.isDefaultUser()) {
        return false;
    }

    return true;
}

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

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    boolean showStagingConfiguration = GetterUtil
            .getBoolean(portletRequest.getParameter("showStagingConfiguration"));

    if (showStagingConfiguration) {
        return false;
    }//from   w  w  w . ja  v a 2 s.com

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

    Group group = themeDisplay.getScopeGroup();

    if (!group.isStaged()) {
        return false;
    }

    User user = themeDisplay.getUser();

    if (user.isDefaultUser()) {
        return false;
    }

    Group liveGroup = StagingUtil.getLiveGroup(group.getGroupId());

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

        // LPS-52675

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

        return false;
    }
}

From source file:com.liferay.staging.taglib.servlet.taglib.DefineObjectsTag.java

License:Open Source License

@Override
public int doStartTag() {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

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

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

    Group group = GroupLocalServiceUtil.fetchGroup(groupId);

    if (group == null) {
        group = (Group) request.getAttribute(WebKeys.GROUP);
    }/* ww  w . ja  v  a 2  s .  c  om*/

    if (group == null) {
        group = themeDisplay.getScopeGroup();
    }

    if (group == null) {
        return SKIP_BODY;
    }

    pageContext.setAttribute("group", group);
    pageContext.setAttribute("groupId", group.getGroupId());
    pageContext.setAttribute("liveGroup", null);
    pageContext.setAttribute("liveGroupId", 0L);

    Layout layout = themeDisplay.getLayout();

    String privateLayoutString = request.getParameter("privateLayout");

    if (Validator.isNull(privateLayoutString)) {
        privateLayoutString = GetterUtil.getString(request.getAttribute(WebKeys.PRIVATE_LAYOUT), null);
    }

    boolean privateLayout = GetterUtil.getBoolean(privateLayoutString, layout.isPrivateLayout());

    pageContext.setAttribute("privateLayout", privateLayout);

    pageContext.setAttribute("stagingGroup", null);
    pageContext.setAttribute("stagingGroupId", 0L);

    if (!group.isStaged() && !group.isStagedRemotely() && !group.hasLocalOrRemoteStagingGroup()) {

        return SKIP_BODY;
    }

    Group liveGroup = StagingUtil.getLiveGroup(group.getGroupId());

    pageContext.setAttribute("liveGroup", liveGroup);
    pageContext.setAttribute("liveGroupId", liveGroup.getGroupId());

    Group stagingGroup = null;

    if (!group.hasRemoteStagingGroup() || group.isStagedRemotely()) {
        stagingGroup = StagingUtil.getStagingGroup(group.getGroupId());
    }

    if (stagingGroup != null) {
        pageContext.setAttribute("stagingGroup", stagingGroup);
        pageContext.setAttribute("stagingGroupId", stagingGroup.getGroupId());
    }

    if (Validator.isNotNull(_portletId)) {
        boolean stagedPortlet = liveGroup.isStagedPortlet(_portletId);

        if (group.isStagedRemotely()) {
            stagedPortlet = stagingGroup.isStagedPortlet(_portletId);
        }

        if (stagedPortlet) {
            pageContext.setAttribute("group", stagingGroup);
            pageContext.setAttribute("groupId", stagingGroup.getGroupId());
            pageContext.setAttribute("scopeGroup", stagingGroup);
            pageContext.setAttribute("scopeGroupId", stagingGroup.getGroupId());
        }
    }

    return SKIP_BODY;
}

From source file:com.liferay.users.admin.web.internal.portlet.action.EditUserMVCActionCommand.java

License:Open Source License

@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    actionRequest = _wrapActionRequest(actionRequest);

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

    try {/*  ww  w.j av a  2 s.  c om*/
        User user = null;
        String oldScreenName = StringPool.BLANK;
        boolean updateLanguageId = false;

        if (cmd.equals(Constants.ADD)) {
            user = addUser(actionRequest);
        } else if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.DELETE)
                || cmd.equals(Constants.RESTORE)) {

            deleteUsers(actionRequest);
        } else if (cmd.equals("deleteRole")) {
            deleteRole(actionRequest);
        } else if (cmd.equals(Constants.UPDATE)) {
            Object[] returnValue = updateUser(actionRequest, actionResponse);

            user = (User) returnValue[0];
            oldScreenName = (String) returnValue[1];
            updateLanguageId = (Boolean) returnValue[2];
        } else if (cmd.equals("unlock")) {
            user = updateLockout(actionRequest);
        }

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

        String redirect = ParamUtil.getString(actionRequest, "redirect");

        if (user != null) {
            if (Validator.isNotNull(oldScreenName)) {

                // This will fix the redirect if the user is on his personal
                // my account page and changes his screen name. A redirect
                // that references the old screen name no longer points to a
                // valid screen name and therefore needs to be updated.

                Group group = user.getGroup();

                if (group.getGroupId() == themeDisplay.getScopeGroupId()) {
                    Layout layout = themeDisplay.getLayout();

                    String friendlyURLPath = group.getPathFriendlyURL(layout.isPrivateLayout(), themeDisplay);

                    String oldPath = friendlyURLPath + StringPool.SLASH + oldScreenName;
                    String newPath = friendlyURLPath + StringPool.SLASH + user.getScreenName();

                    redirect = StringUtil.replace(redirect, oldPath, newPath);

                    redirect = StringUtil.replace(redirect, URLCodec.encodeURL(oldPath),
                            URLCodec.encodeURL(newPath));
                }
            }

            if (updateLanguageId && themeDisplay.isI18n()) {
                String i18nLanguageId = user.getLanguageId();

                int pos = i18nLanguageId.indexOf(CharPool.UNDERLINE);

                if (pos != -1) {
                    i18nLanguageId = i18nLanguageId.substring(0, pos);
                }

                String i18nPath = StringPool.SLASH + i18nLanguageId;

                redirect = StringUtil.replace(redirect, themeDisplay.getI18nPath(), i18nPath);
            }

            redirect = http.setParameter(redirect, actionResponse.getNamespace() + "p_u_i_d", user.getUserId());
        }

        Group scopeGroup = themeDisplay.getScopeGroup();

        if (scopeGroup.isUser() && (userLocalService.fetchUserById(scopeGroup.getClassPK()) == null)) {

            redirect = http.setParameter(redirect, "doAsGroupId", 0);
            redirect = http.setParameter(redirect, "refererPlid", 0);
        }

        sendRedirect(actionRequest, actionResponse, redirect);
    } catch (Exception e) {
        String mvcPath = "/edit_user.jsp";

        if (e instanceof NoSuchUserException || e instanceof PrincipalException) {

            SessionErrors.add(actionRequest, e.getClass());

            mvcPath = "/error.jsp";
        } else if (e instanceof AssetCategoryException || e instanceof AssetTagException
                || e instanceof CompanyMaxUsersException || e instanceof ContactBirthdayException
                || e instanceof ContactNameException || e instanceof GroupFriendlyURLException
                || e instanceof MembershipPolicyException || e instanceof NoSuchListTypeException
                || e instanceof RequiredUserException || e instanceof UserEmailAddressException
                || e instanceof UserFieldException || e instanceof UserIdException
                || e instanceof UserReminderQueryException || e instanceof UserScreenNameException) {

            if (e instanceof NoSuchListTypeException) {
                NoSuchListTypeException nslte = (NoSuchListTypeException) e;

                Class<?> clazz = e.getClass();

                SessionErrors.add(actionRequest, clazz.getName() + nslte.getType());
            } else {
                SessionErrors.add(actionRequest, e.getClass(), e);
            }

            if (e instanceof CompanyMaxUsersException || e instanceof RequiredUserException) {

                String redirect = portal.escapeRedirect(ParamUtil.getString(actionRequest, "redirect"));

                if (Validator.isNotNull(redirect)) {
                    sendRedirect(actionRequest, actionResponse, redirect);

                    return;
                }
            }
        } else {
            throw e;
        }

        actionResponse.setRenderParameter("mvcPath", mvcPath);
    }
}

From source file:se.vgregion.portal.innovationsslussen.settings.controller.IdeaSettingsViewController.java

License:Open Source License

/**
 * This method saves the settings for the settings portlet.
 * //from  w w w  .java  2  s .c om
 * @param request
 *            the request
 * @param response
 *            the response
 */
@ActionMapping(params = "action=save")
public void save(ActionRequest request, ActionResponse response) {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    long companyId = themeDisplay.getCompanyId();
    long groupId = themeDisplay.getScopeGroup().getGroupId();

    for (String expando : textExpandos) {
        String value = ParamUtil.getString(request, expando, "");
        ideaSettingsService.setSetting(value, expando, companyId, groupId);
    }

    for (String expando : booleanExpandos) {
        Boolean value = ParamUtil.getBoolean(request, expando, false);
        ideaSettingsService.setSettingBoolean(value, expando, companyId, groupId);
    }
}