Example usage for com.liferay.portal.kernel.service OrganizationLocalServiceUtil getOrganization

List of usage examples for com.liferay.portal.kernel.service OrganizationLocalServiceUtil getOrganization

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service OrganizationLocalServiceUtil getOrganization.

Prototype

public static com.liferay.portal.kernel.model.Organization getOrganization(long companyId, String name)
        throws com.liferay.portal.kernel.exception.PortalException 

Source Link

Document

Returns the organization with the name.

Usage

From source file:com.liferay.message.boards.web.internal.util.MBUserRankUtil.java

License:Open Source License

private static boolean _isEntityRank(long companyId, MBStatsUser statsUser, String entityType,
        String entityValue) throws Exception {

    long groupId = statsUser.getGroupId();
    long userId = statsUser.getUserId();

    if (entityType.equals("organization-role") || entityType.equals("site-role")) {

        Role role = RoleLocalServiceUtil.getRole(companyId, entityValue);

        if (UserGroupRoleLocalServiceUtil.hasUserGroupRole(userId, groupId, role.getRoleId(), true)) {

            return true;
        }/*from ww  w . j ava  2s. c om*/
    } else if (entityType.equals("organization")) {
        Organization organization = OrganizationLocalServiceUtil.getOrganization(companyId, entityValue);

        if (OrganizationLocalServiceUtil.hasUserOrganization(userId, organization.getOrganizationId(), false,
                false)) {

            return true;
        }
    } else if (entityType.equals("regular-role")) {
        if (RoleLocalServiceUtil.hasUserRole(userId, companyId, entityValue, true)) {

            return true;
        }
    } else if (entityType.equals("user-group")) {
        UserGroup userGroup = UserGroupLocalServiceUtil.getUserGroup(companyId, entityValue);

        if (UserLocalServiceUtil.hasUserGroupUser(userGroup.getUserGroupId(), userId)) {

            return true;
        }
    }

    return false;
}