Example usage for com.liferay.portal.kernel.service RoleLocalServiceUtil getUserRoles

List of usage examples for com.liferay.portal.kernel.service RoleLocalServiceUtil getUserRoles

Introduction

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

Prototype

public static java.util.List<com.liferay.portal.kernel.model.Role> getUserRoles(long userId) 

Source Link

Usage

From source file:com.liferay.exportimport.lar.LayoutCache.java

License:Open Source License

protected List<Role> getUserRoles(long userId) {
    List<Role> userRoles = userRolesMap.get(userId);

    if (userRoles == null) {
        userRoles = RoleLocalServiceUtil.getUserRoles(userId);

        userRolesMap.put(userId, userRoles);
    }//  ww  w  .  j  av  a  2s  . co  m

    return userRoles;
}

From source file:com.liferay.faces.portal.context.internal.LiferayPortletHelperImpl.java

License:Open Source License

@Override
public List<Role> getUserRoles() throws SystemException {
    return RoleLocalServiceUtil.getUserRoles(getUserId());
}

From source file:eu.gerhards.liferay.services.angular.service.impl.AngularRoleServiceImpl.java

License:Open Source License

public long[] checkRoles(long userId, long[] roleIds) throws PortalException {

    long[] oldRoleIds = null;

    PermissionChecker permissionChecker = getPermissionChecker();

    if (userId != CompanyConstants.SYSTEM) {

        // Add back any mandatory roles or roles that the administrator does
        // not have the rights to remove and check that he has the
        // permission to add a new role

        List<Role> oldRoles = RoleLocalServiceUtil.getUserRoles(userId);

        oldRoleIds = new long[oldRoles.size()];

        for (int i = 0; i < oldRoles.size(); i++) {
            Role role = oldRoles.get(i);

            if (!ArrayUtil.contains(roleIds, role.getRoleId()) && (!RolePermissionUtil
                    .contains(permissionChecker, role.getRoleId(), ActionKeys.ASSIGN_MEMBERS)
                    || RoleMembershipPolicyUtil.isRoleRequired(userId, role.getRoleId()))) {

                roleIds = ArrayUtil.append(roleIds, role.getRoleId());
            }//from   w w  w  .j  ava  2  s  .  com

            oldRoleIds[i] = role.getRoleId();
        }
    }

    // Check that the administrator has the permission to add a new role and
    // that the role membership is allowed

    for (long roleId : roleIds) {
        if ((oldRoleIds != null) && ArrayUtil.contains(oldRoleIds, roleId)) {

            continue;
        }

        RolePermissionUtil.check(permissionChecker, roleId, ActionKeys.ASSIGN_MEMBERS);
    }

    if (userId != CompanyConstants.SYSTEM) {
        return UsersAdminUtil.addRequiredRoles(userId, roleIds);
    }

    return roleIds;
}

From source file:eu.gerhards.liferay.services.angular.service.impl.AngularUserServiceImpl.java

License:Open Source License

@Override
public User getUser(long userId) throws PortalException {

    _log.info("getting user with id: " + String.valueOf(userId));

    _log.debug("    ... security check ...");

    PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.VIEW);

    _log.debug("    ... getting information");

    User user = UserLocalServiceUtil.getUser(userId);
    Contact userContact = ContactLocalServiceUtil.getContact(user.getContactId());

    List<Role> userRoles = RoleLocalServiceUtil.getUserRoles(user.getUserId());
    List<Group> userGroups = GroupLocalServiceUtil.getUserGroups(user.getUserId());
    List<Organization> userOrganizations = OrganizationLocalServiceUtil.getUserOrganizations(user.getUserId());
    List<UserGroup> userUserGroups = UserGroupLocalServiceUtil.getUserUserGroups(user.getUserId());

    return user;// w  w  w  . j  a va  2 s  .c  o  m
}