Liferay 7.0-ce-b4

com.liferay.portal.service.impl
Class RoleServiceImpl

java.lang.Object
  extended by com.liferay.portal.service.BaseServiceImpl
      extended by com.liferay.portal.service.base.RoleServiceBaseImpl
          extended by com.liferay.portal.service.impl.RoleServiceImpl
All Implemented Interfaces:
IdentifiableOSGiService, BaseService, RoleService

public class RoleServiceImpl
extends RoleServiceBaseImpl

Provides the remote service for accessing, adding, unassigning, checking, deleting, and updating roles. Its methods include permission checks.


Field Summary
 
Fields inherited from class com.liferay.portal.service.base.RoleServiceBaseImpl
classNameLocalService, classNamePersistence, classNameService, companyLocalService, companyPersistence, companyService, counterLocalService, expandoRowLocalService, expandoRowPersistence, groupFinder, groupLocalService, groupPersistence, groupService, layoutFinder, layoutLocalService, layoutPersistence, layoutService, resourceActionLocalService, resourceActionPersistence, resourceBlockFinder, resourceBlockLocalService, resourceBlockPermissionLocalService, resourceBlockPermissionPersistence, resourceBlockPersistence, resourceBlockService, resourceLocalService, resourcePermissionFinder, resourcePermissionLocalService, resourcePermissionPersistence, resourcePermissionService, resourceTypePermissionFinder, resourceTypePermissionLocalService, resourceTypePermissionPersistence, roleFinder, roleLocalService, rolePersistence, roleService, teamFinder, teamLocalService, teamPersistence, teamService, userFinder, userGroupGroupRoleFinder, userGroupGroupRoleLocalService, userGroupGroupRolePersistence, userGroupGroupRoleService, userGroupRoleFinder, userGroupRoleLocalService, userGroupRolePersistence, userGroupRoleService, userLocalService, userPersistence, userService
 
Fields inherited from class com.liferay.portal.service.BaseServiceImpl
ANONYMOUS_NAMES, JRUN_ANONYMOUS, ORACLE_ANONYMOUS, SUN_ANONYMOUS, WEBLOGIC_ANONYMOUS
 
Constructor Summary
RoleServiceImpl()
           
 
Method Summary
 Role addRole(String className, long classPK, String name, Map<Locale,String> titleMap, Map<Locale,String> descriptionMap, int type, String subtype, ServiceContext serviceContext)
          Adds a role.
 Role addRole(String name, Map<Locale,String> titleMap, Map<Locale,String> descriptionMap, int type)
          Deprecated. As of 6.2.0, replaced by addRole(String, long, String, Map, Map, int, String, ServiceContext)
 void addUserRoles(long userId, long[] roleIds)
          Adds the roles to the user.
protected  void checkUserRolesPermission(long userId, long[] roleIds)
           
 void deleteRole(long roleId)
          Deletes the role with the primary key and its associated permissions.
 Role fetchRole(long roleId)
           
protected  List<Role> filterRoles(List<Role> roles)
           
 List<Role> getGroupRoles(long groupId)
          Returns all the roles associated with the group.
 Role getRole(long roleId)
          Returns the role with the primary key.
 Role getRole(long companyId, String name)
          Returns the role with the name in the company.
 List<Role> getRoles(int type, String subtype)
           
 List<Role> getRoles(long companyId, int[] types)
           
 List<Role> getUserGroupGroupRoles(long userId, long groupId)
          Returns all the user's roles within the user group.
 List<Role> getUserGroupRoles(long userId, long groupId)
          Returns all the user's roles within the user group.
 List<Role> getUserRelatedRoles(long userId, List<Group> groups)
          Returns the union of all the user's roles within the groups.
 List<Role> getUserRoles(long userId)
          Returns all the roles associated with the user.
 boolean hasUserRole(long userId, long companyId, String name, boolean inherited)
          Returns true if the user is associated with the named regular role.
 boolean hasUserRoles(long userId, long companyId, String[] names, boolean inherited)
          Returns true if the user has any one of the named regular roles.
 List<Role> search(long companyId, String keywords, Integer[] types, LinkedHashMap<String,Object> params, int start, int end, OrderByComparator<Role> obc)
           
 int searchCount(long companyId, String keywords, Integer[] types, LinkedHashMap<String,Object> params)
           
 void unsetUserRoles(long userId, long[] roleIds)
          Removes the matching roles associated with the user.
 Role updateRole(long roleId, String name, Map<Locale,String> titleMap, Map<Locale,String> descriptionMap, String subtype, ServiceContext serviceContext)
          Updates the role with the primary key.
 
Methods inherited from class com.liferay.portal.service.base.RoleServiceBaseImpl
afterPropertiesSet, destroy, getClassNameLocalService, getClassNamePersistence, getClassNameService, getCompanyLocalService, getCompanyPersistence, getCompanyService, getCounterLocalService, getExpandoRowLocalService, getExpandoRowPersistence, getGroupFinder, getGroupLocalService, getGroupPersistence, getGroupService, getLayoutFinder, getLayoutLocalService, getLayoutPersistence, getLayoutService, getModelClass, getModelClassName, getOSGiServiceIdentifier, getResourceActionLocalService, getResourceActionPersistence, getResourceBlockFinder, getResourceBlockLocalService, getResourceBlockPermissionLocalService, getResourceBlockPermissionPersistence, getResourceBlockPersistence, getResourceBlockService, getResourceLocalService, getResourcePermissionFinder, getResourcePermissionLocalService, getResourcePermissionPersistence, getResourcePermissionService, getResourceTypePermissionFinder, getResourceTypePermissionLocalService, getResourceTypePermissionPersistence, getRoleFinder, getRoleLocalService, getRolePersistence, getRoleService, getTeamFinder, getTeamLocalService, getTeamPersistence, getTeamService, getUserFinder, getUserGroupGroupRoleFinder, getUserGroupGroupRoleLocalService, getUserGroupGroupRolePersistence, getUserGroupGroupRoleService, getUserGroupRoleFinder, getUserGroupRoleLocalService, getUserGroupRolePersistence, getUserGroupRoleService, getUserLocalService, getUserPersistence, getUserService, runSQL, setClassNameLocalService, setClassNamePersistence, setClassNameService, setCompanyLocalService, setCompanyPersistence, setCompanyService, setCounterLocalService, setExpandoRowLocalService, setExpandoRowPersistence, setGroupFinder, setGroupLocalService, setGroupPersistence, setGroupService, setLayoutFinder, setLayoutLocalService, setLayoutPersistence, setLayoutService, setResourceActionLocalService, setResourceActionPersistence, setResourceBlockFinder, setResourceBlockLocalService, setResourceBlockPermissionLocalService, setResourceBlockPermissionPersistence, setResourceBlockPersistence, setResourceBlockService, setResourceLocalService, setResourcePermissionFinder, setResourcePermissionLocalService, setResourcePermissionPersistence, setResourcePermissionService, setResourceTypePermissionFinder, setResourceTypePermissionLocalService, setResourceTypePermissionPersistence, setRoleFinder, setRoleLocalService, setRolePersistence, setRoleService, setTeamFinder, setTeamLocalService, setTeamPersistence, setTeamService, setUserFinder, setUserGroupGroupRoleFinder, setUserGroupGroupRoleLocalService, setUserGroupGroupRolePersistence, setUserGroupGroupRoleService, setUserGroupRoleFinder, setUserGroupRoleLocalService, setUserGroupRolePersistence, setUserGroupRoleService, setUserLocalService, setUserPersistence, setUserService
 
Methods inherited from class com.liferay.portal.service.BaseServiceImpl
getClassLoader, getGuestOrUser, getGuestOrUserId, getPermissionChecker, getUser, getUserId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RoleServiceImpl

public RoleServiceImpl()
Method Detail

addRole

public Role addRole(String className,
                    long classPK,
                    String name,
                    Map<Locale,String> titleMap,
                    Map<Locale,String> descriptionMap,
                    int type,
                    String subtype,
                    ServiceContext serviceContext)
             throws PortalException
Adds a role. The user is reindexed after role is added.

Parameters:
className - the name of the class for which the role is created
classPK - the primary key of the class for which the role is created (optionally 0)
name - the role's name
titleMap - the role's localized titles (optionally null)
descriptionMap - the role's localized descriptions (optionally null)
type - the role's type (optionally 0)
subtype - the role's subtype (optionally null)
serviceContext - the service context to be applied (optionally null). Can set the expando bridge attributes for the role.
Returns:
the role
Throws:
PortalException

addRole

@Deprecated
public Role addRole(String name,
                               Map<Locale,String> titleMap,
                               Map<Locale,String> descriptionMap,
                               int type)
             throws PortalException
Deprecated. As of 6.2.0, replaced by addRole(String, long, String, Map, Map, int, String, ServiceContext)

Adds a role. The user is reindexed after role is added.

Parameters:
name - the role's name
titleMap - the role's localized titles (optionally null)
descriptionMap - the role's localized descriptions (optionally null)
type - the role's type (optionally 0)
Returns:
the role
Throws:
PortalException

addUserRoles

public void addUserRoles(long userId,
                         long[] roleIds)
                  throws PortalException
Adds the roles to the user. The user is reindexed after the roles are added.

Parameters:
userId - the primary key of the user
roleIds - the primary keys of the roles
Throws:
PortalException

deleteRole

public void deleteRole(long roleId)
                throws PortalException
Deletes the role with the primary key and its associated permissions.

Parameters:
roleId - the primary key of the role
Throws:
PortalException

fetchRole

public Role fetchRole(long roleId)
               throws PortalException
Throws:
PortalException

getGroupRoles

public List<Role> getGroupRoles(long groupId)
                         throws PortalException
Returns all the roles associated with the group.

Parameters:
groupId - the primary key of the group
Returns:
the roles associated with the group
Throws:
PortalException

getRole

public Role getRole(long roleId)
             throws PortalException
Returns the role with the primary key.

Parameters:
roleId - the primary key of the role
Returns:
the role with the primary key
Throws:
PortalException

getRole

public Role getRole(long companyId,
                    String name)
             throws PortalException
Returns the role with the name in the company.

The method searches the system roles map first for default roles. If a role with the name is not found, then the method will query the database.

Parameters:
companyId - the primary key of the company
name - the role's name
Returns:
the role with the name
Throws:
PortalException

getRoles

public List<Role> getRoles(int type,
                           String subtype)
                    throws PortalException
Throws:
PortalException

getRoles

public List<Role> getRoles(long companyId,
                           int[] types)
                    throws PortalException
Throws:
PortalException

getUserGroupGroupRoles

public List<Role> getUserGroupGroupRoles(long userId,
                                         long groupId)
                                  throws PortalException
Returns all the user's roles within the user group.

Parameters:
userId - the primary key of the user
groupId - the primary key of the group
Returns:
the user's roles within the user group
Throws:
PortalException

getUserGroupRoles

public List<Role> getUserGroupRoles(long userId,
                                    long groupId)
                             throws PortalException
Returns all the user's roles within the user group.

Parameters:
userId - the primary key of the user
groupId - the primary key of the group
Returns:
the user's roles within the user group
Throws:
PortalException

getUserRelatedRoles

public List<Role> getUserRelatedRoles(long userId,
                                      List<Group> groups)
                               throws PortalException
Returns the union of all the user's roles within the groups.

Parameters:
userId - the primary key of the user
groups - the groups (optionally null)
Returns:
the union of all the user's roles within the groups
Throws:
PortalException

getUserRoles

public List<Role> getUserRoles(long userId)
                        throws PortalException
Returns all the roles associated with the user.

Parameters:
userId - the primary key of the user
Returns:
the roles associated with the user
Throws:
PortalException

hasUserRole

public boolean hasUserRole(long userId,
                           long companyId,
                           String name,
                           boolean inherited)
                    throws PortalException
Returns true if the user is associated with the named regular role.

Parameters:
userId - the primary key of the user
companyId - the primary key of the company
name - the name of the role
inherited - whether to include the user's inherited roles in the search
Returns:
true if the user is associated with the regular role; false otherwise
Throws:
PortalException

hasUserRoles

public boolean hasUserRoles(long userId,
                            long companyId,
                            String[] names,
                            boolean inherited)
                     throws PortalException
Returns true if the user has any one of the named regular roles.

Parameters:
userId - the primary key of the user
companyId - the primary key of the company
names - the names of the roles
inherited - whether to include the user's inherited roles in the search
Returns:
true if the user has any one of the regular roles; false otherwise
Throws:
PortalException

search

public List<Role> search(long companyId,
                         String keywords,
                         Integer[] types,
                         LinkedHashMap<String,Object> params,
                         int start,
                         int end,
                         OrderByComparator<Role> obc)

searchCount

public int searchCount(long companyId,
                       String keywords,
                       Integer[] types,
                       LinkedHashMap<String,Object> params)

unsetUserRoles

public void unsetUserRoles(long userId,
                           long[] roleIds)
                    throws PortalException
Removes the matching roles associated with the user. The user is reindexed after the roles are removed.

Parameters:
userId - the primary key of the user
roleIds - the primary keys of the roles
Throws:
PortalException

updateRole

public Role updateRole(long roleId,
                       String name,
                       Map<Locale,String> titleMap,
                       Map<Locale,String> descriptionMap,
                       String subtype,
                       ServiceContext serviceContext)
                throws PortalException
Updates the role with the primary key.

Parameters:
roleId - the primary key of the role
name - the role's new name
titleMap - the new localized titles (optionally null) to replace those existing for the role
descriptionMap - the new localized descriptions (optionally null) to replace those existing for the role
subtype - the role's new subtype (optionally null)
serviceContext - the service context to be applied (optionally null). Can set the expando bridge attributes for the role.
Returns:
the role with the primary key
Throws:
PortalException

checkUserRolesPermission

protected void checkUserRolesPermission(long userId,
                                        long[] roleIds)
                                 throws PortalException
Throws:
PortalException

filterRoles

protected List<Role> filterRoles(List<Role> roles)
                          throws PortalException
Throws:
PortalException

Liferay 7.0-ce-b4