Dear Friends,
I want to define permissions for Organization Role. I am using the below api for this -
1
2Role orgMentorRole = RoleLocalServiceUtil.fetchRole(companyId, "Organization Mentor");
3try{
4 setRolePermissions(orgMentorRole , AnnouncementsEntry.class.getName(), new String[] {ActionKeys.UPDATE, ActionKeys.VIEW});
5}catch(Exception e){
6 e.printStackTrace();
7}
Here is my setRolePermissions method -
1
2protected static void setRolePermissions(
3 Role role, String name, String[] actionIds)
4 throws Exception {
5
6 long roleId = role.getRoleId();
7 long companyId = role.getCompanyId();
8 int scope = ResourceConstants.SCOPE_COMPANY;
9 String primKey = String.valueOf(companyId);
10
11 if (_PERMISSIONS_USER_CHECK_ALGORITHM == 6) {
12 System.out.println(">_PERMISSIONS_USER_CHECK_ALGORITHM is 6");
13 ResourcePermissionLocalServiceUtil.setResourcePermissions(
14 companyId, name, scope, primKey, roleId, actionIds);
15 }
16 else {
17 System.out.println(">_PERMISSIONS_USER_CHECK_ALGORITHM is not 6");
18 PermissionLocalServiceUtil.setRolePermissions(
19 roleId, companyId, name, scope, primKey, actionIds);
20 }
21 }
But the above code does not define permissions. Also, there is no exception being thrown. Plz lemme know what I am missing here.
Note: - The above code works fine if it is Regular Role.
Regards,
Nilesh
Please sign in to flag this as inappropriate.