1
22
23 package com.liferay.portal.service.impl;
24
25 import com.liferay.portal.PortalException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.security.permission.ActionKeys;
28 import com.liferay.portal.model.Role;
29 import com.liferay.portal.model.User;
30 import com.liferay.portal.service.RoleLocalServiceUtil;
31 import com.liferay.portal.service.RoleService;
32 import com.liferay.portal.service.permission.PortalPermissionUtil;
33 import com.liferay.portal.service.permission.RolePermissionUtil;
34
35 import java.util.List;
36
37
43 public class RoleServiceImpl extends PrincipalBean implements RoleService {
44
45 public Role addRole(String name, int type)
46 throws PortalException, SystemException {
47
48 User user = getUser();
49
50 PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_ROLE);
51
52 return RoleLocalServiceUtil.addRole(
53 user.getUserId(), user.getCompanyId(), name, type);
54 }
55
56 public void deleteRole(long roleId)
57 throws PortalException, SystemException {
58
59 RolePermissionUtil.check(
60 getPermissionChecker(), roleId, ActionKeys.DELETE);
61
62 RoleLocalServiceUtil.deleteRole(roleId);
63 }
64
65 public Role getGroupRole(long companyId, long groupId)
66 throws PortalException, SystemException {
67
68 return RoleLocalServiceUtil.getGroupRole(companyId, groupId);
69 }
70
71 public List getGroupRoles(long groupId)
72 throws PortalException, SystemException {
73
74 return RoleLocalServiceUtil.getGroupRoles(groupId);
75 }
76
77 public Role getRole(long roleId)
78 throws PortalException, SystemException {
79
80 return RoleLocalServiceUtil.getRole(roleId);
81 }
82
83 public Role getRole(long companyId, String name)
84 throws PortalException, SystemException {
85
86 return RoleLocalServiceUtil.getRole(companyId, name);
87 }
88
89 public List getUserGroupRoles(long userId, long groupId)
90 throws PortalException, SystemException {
91
92 return RoleLocalServiceUtil.getUserGroupRoles(userId, groupId);
93 }
94
95 public List getUserRelatedRoles(long userId, List groups)
96 throws PortalException, SystemException {
97
98 return RoleLocalServiceUtil.getUserRelatedRoles(userId, groups);
99 }
100
101 public List getUserRoles(long userId)
102 throws PortalException, SystemException {
103
104 return RoleLocalServiceUtil.getUserRoles(userId);
105 }
106
107 public boolean hasUserRole(
108 long userId, long companyId, String name, boolean inherited)
109 throws PortalException, SystemException {
110
111 return RoleLocalServiceUtil.hasUserRole(
112 userId, companyId, name, inherited);
113 }
114
115 public boolean hasUserRoles(
116 long userId, long companyId, String[] names, boolean inherited)
117 throws PortalException, SystemException {
118
119 return RoleLocalServiceUtil.hasUserRoles(
120 userId, companyId, names, inherited);
121 }
122
123 public Role updateRole(long roleId, String name)
124 throws PortalException, SystemException {
125
126 RolePermissionUtil.check(
127 getPermissionChecker(), roleId, ActionKeys.UPDATE);
128
129 return RoleLocalServiceUtil.updateRole(roleId, name);
130 }
131
132 }