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

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

Introduction

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

Prototype

public Company getCompany() 

Source Link

Document

Returns the portal instance bean.

Usage

From source file:com.liferay.site.admin.web.internal.display.context.SiteAdminDisplayContext.java

License:Open Source License

public int getUserGroupsCount(Group group) {
    LinkedHashMap<String, Object> userGroupParams = new LinkedHashMap<>();

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

    Company company = themeDisplay.getCompany();

    userGroupParams.put(UserGroupFinderConstants.PARAM_KEY_USER_GROUPS_GROUPS, group.getGroupId());

    return UserGroupLocalServiceUtil.searchCount(company.getCompanyId(), null, userGroupParams);
}

From source file:com.liferay.site.admin.web.internal.display.context.SiteAdminDisplayContext.java

License:Open Source License

public int getUsersCount(Group group) {
    LinkedHashMap<String, Object> userParams = new LinkedHashMap<>();

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

    Company company = themeDisplay.getCompany();

    userParams.put("inherit", Boolean.TRUE);
    userParams.put("usersGroups", group.getGroupId());

    return UserLocalServiceUtil.searchCount(company.getCompanyId(), null, WorkflowConstants.STATUS_APPROVED,
            userParams);//from  w  w w. j av a2 s .  c o m
}

From source file:com.liferay.site.browser.web.internal.display.context.SiteBrowserDisplayContext.java

License:Open Source License

public GroupSearch getGroupSearch() throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    Company company = themeDisplay.getCompany();

    GroupSearch groupSearch = new GroupSearch(_liferayPortletRequest, getPortletURL());

    GroupSearchTerms groupSearchTerms = (GroupSearchTerms) groupSearch.getSearchTerms();

    List<Group> results = new ArrayList<>();

    int additionalSites = 0;
    int total = 0;

    boolean includeCompany = ParamUtil.getBoolean(_request, "includeCompany");
    boolean includeUserPersonalSite = ParamUtil.getBoolean(_request, "includeUserPersonalSite");

    long[] classNameIds = _CLASS_NAME_IDS;

    if (includeCompany) {
        classNameIds = ArrayUtil.append(classNameIds, PortalUtil.getClassNameId(Company.class));
    }//from w  ww  .  ja va 2  s . com

    if (includeUserPersonalSite) {
        if (groupSearch.getStart() == 0) {
            Group userPersonalSite = GroupLocalServiceUtil.getGroup(company.getCompanyId(),
                    GroupConstants.USER_PERSONAL_SITE);

            results.add(userPersonalSite);
        }

        additionalSites++;
    }

    String type = getType();

    if (type.equals("layoutScopes")) {
        total = GroupLocalServiceUtil.getGroupsCount(themeDisplay.getCompanyId(), Layout.class.getName(),
                getGroupId());
    } else if (type.equals("parent-sites")) {
    } else {
        total = GroupLocalServiceUtil.searchCount(themeDisplay.getCompanyId(), classNameIds,
                groupSearchTerms.getKeywords(), getGroupParams());
    }

    total += additionalSites;

    groupSearch.setTotal(total);

    int start = groupSearch.getStart();

    if (groupSearch.getStart() > additionalSites) {
        start = groupSearch.getStart() - additionalSites;
    }

    List<Group> groups = null;

    if (type.equals("layoutScopes")) {
        groups = GroupLocalServiceUtil.getGroups(company.getCompanyId(), Layout.class.getName(), getGroupId(),
                start, groupSearch.getResultEnd() - additionalSites);

        groups = _filterLayoutGroups(groups, isPrivateLayout());
    } else if (type.equals("parent-sites")) {
        Group group = GroupLocalServiceUtil.getGroup(getGroupId());

        groups = group.getAncestors();

        String filter = getFilter();

        if (Validator.isNotNull(filter)) {
            groups = _filterGroups(groups, filter);
        }

        total = groups.size();

        total += additionalSites;

        groupSearch.setTotal(total);
    } else {
        groups = GroupLocalServiceUtil.search(company.getCompanyId(), classNameIds,
                groupSearchTerms.getKeywords(), getGroupParams(), QueryUtil.ALL_POS, QueryUtil.ALL_POS,
                groupSearch.getOrderByComparator());

        groups = _filterGroups(groups, themeDisplay.getPermissionChecker());

        total = groups.size();

        total += additionalSites;

        groupSearch.setTotal(total);

        groups = groups.subList(start, groupSearch.getResultEnd() - additionalSites);
    }

    results.addAll(groups);

    groupSearch.setResults(results);

    return groupSearch;
}

From source file:com.liferay.site.util.GroupSearchProvider.java

License:Open Source License

public GroupSearch getGroupSearch(PortletRequest portletRequest, PortletURL portletURL) throws PortalException {

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

    GroupSearch groupSearch = new GroupSearch(portletRequest, portletURL);

    GroupSearchTerms searchTerms = (GroupSearchTerms) groupSearch.getSearchTerms();

    if (!searchTerms.isSearch()) {
        groupSearch.setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
    } else {/*from ww  w  .j a v a2 s.  c om*/
        groupSearch.setSearch(true);
    }

    long parentGroupId = getParentGroupId(portletRequest);

    Company company = themeDisplay.getCompany();

    List results = null;

    if (!searchTerms.hasSearchTerms() && isFilterManageableGroups(portletRequest) && (parentGroupId <= 0)) {

        List<Group> groups = getAllGroups(portletRequest);

        groupSearch.setTotal(groups.size());

        results = ListUtil.subList(groups, groupSearch.getStart(), groupSearch.getEnd());
    } else if (searchTerms.hasSearchTerms()) {
        int total = _groupLocalService.searchCount(company.getCompanyId(), _classNameIds,
                searchTerms.getKeywords(), getGroupParams(portletRequest, searchTerms, parentGroupId));

        groupSearch.setTotal(total);

        results = _groupLocalService.search(company.getCompanyId(), _classNameIds, searchTerms.getKeywords(),
                getGroupParams(portletRequest, searchTerms, parentGroupId), groupSearch.getStart(),
                groupSearch.getEnd(), groupSearch.getOrderByComparator());
    } else {
        long groupId = ParamUtil.getLong(portletRequest, "groupId", GroupConstants.DEFAULT_PARENT_GROUP_ID);

        int total = _groupLocalService.searchCount(company.getCompanyId(), _classNameIds, groupId,
                searchTerms.getKeywords(), getGroupParams(portletRequest, searchTerms, parentGroupId));

        groupSearch.setTotal(total);

        results = _groupLocalService.search(company.getCompanyId(), _classNameIds, groupId,
                searchTerms.getKeywords(), getGroupParams(portletRequest, searchTerms, parentGroupId),
                groupSearch.getStart(), groupSearch.getEnd(), groupSearch.getOrderByComparator());
    }

    groupSearch.setResults(results);

    return groupSearch;
}

From source file:com.slemarchand.quick.sign.up.web.portlet.QuickSignUpPortlet.java

License:Open Source License

protected User addUser(ActionRequest actionRequest, ActionResponse actionResponse, String password)
        throws SystemException, PortalException {

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

    Company company = themeDisplay.getCompany();

    String authType = company.getAuthType();

    boolean autoPassword = false;
    String password1 = null;//from w w w  . ja  v  a 2s  . c om
    String password2 = null;
    boolean autoScreenName = !authType.equals(CompanyConstants.AUTH_TYPE_SN);
    String screenName = ParamUtil.getString(actionRequest, "screenName");
    String emailAddress = ParamUtil.getString(actionRequest, "emailAddress");
    long facebookId = 0;
    String openId = StringPool.BLANK;
    String firstName = ParamUtil.getString(actionRequest, "firstName");
    String middleName = StringPool.BLANK;
    String lastName = ParamUtil.getString(actionRequest, "lastName");
    int prefixId = 0;
    int suffixId = 0;
    boolean male = ParamUtil.getBoolean(actionRequest, "male", true);
    int birthdayMonth = 1;
    int birthdayDay = 1;
    int birthdayYear = 1970;
    String jobTitle = StringPool.BLANK;
    long[] groupIds = null;
    long[] organizationIds = null;
    long[] roleIds = null;
    long[] userGroupIds = null;
    boolean sendEmail = true;

    ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest);

    password1 = password;
    password2 = password;

    User user = UserServiceUtil.addUser(company.getCompanyId(), autoPassword, password1, password2,
            autoScreenName, screenName, emailAddress, facebookId, openId, themeDisplay.getLocale(), firstName,
            middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle,
            groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext);

    long userId = user.getUserId();

    user = UserLocalServiceUtil.updatePasswordReset(userId, false);

    PasswordPolicy passwordPolicy = PasswordPolicyLocalServiceUtil.getPasswordPolicyByUserId(userId);
    passwordPolicy.setChangeRequired(false);
    PasswordPolicyLocalServiceUtil.updatePasswordPolicy(passwordPolicy);

    if (_USERS_REMINDER_QUERIES_ENABLED) {
        user = UserLocalServiceUtil.updateReminderQuery(userId, StringPool.DASH, UUID.randomUUID().toString());
    }

    user = UserLocalServiceUtil.updateAgreedToTermsOfUse(userId, true);

    return user;
}

From source file:com.slemarchand.quick.sign.up.web.portlet.QuickSignUpPortlet.java

License:Open Source License

protected String getLogin(ThemeDisplay themeDisplay, ActionRequest actionRequest, User user)
        throws SystemException {

    Company company = themeDisplay.getCompany();

    String authType = company.getAuthType();

    String login;//w w  w. j  a  va2  s .c  o  m

    if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
        login = user.getEmailAddress();
    } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
        login = user.getScreenName();
    } else {
        login = Long.toString(user.getUserId());
    }

    return login;
}

From source file:com.slemarchand.quick.sign.up.web.portlet.QuickSignUpPortlet.java

License:Open Source License

protected void login(ThemeDisplay themeDisplay, ActionRequest actionRequest, ActionResponse actionResponse,
        User user, String password, String redirect) throws Exception {

    HttpServletRequest request = PortalUtil
            .getOriginalServletRequest(PortalUtil.getHttpServletRequest(actionRequest));
    HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse);

    String login = getLogin(themeDisplay, actionRequest, user);

    boolean rememberMe = false;

    String authType = themeDisplay.getCompany().getAuthType();

    AuthenticatedSessionManagerUtil.login(request, response, login, password, rememberMe, authType);

    actionResponse.sendRedirect(redirect);
}