Forums de discussion
Giving view permission for a ROLE on a Resource
sri p, modifié il y a 10 années.
Giving view permission for a ROLE on a Resource
Junior Member Publications: 85 Date d'inscription: 22/01/11 Publications récentes
Hello All,
(Liferay 6.1)
I created categories and roles pro-grammatically and I could see them in control panel.
I tried following ways to give(check box should be checked) VIEW permission for a role on a category.
PermissionLocalServiceUtil.setRolePermissions(...) // throwing NoSuchPermission exception.
ResourcePermissionLocalServiceUtil.setResourcePermissions(...) //throwing NoSuchResourceActionException.
and obviously there are no records in RESOURCEPERMISSION table associated to above created role.
I see all permissions UNchecked for the created role on created category (all the check boxes are unchecked) (:
I would like to check VIEW permission programmatically.
Do I need to add permissions first on resource for specific role ? If so, I do not see any method in ResourcePermissionLocalServiceUtil that adds a permission on resource for specific role at INDIVIDUAL scope.
I appreciate any inputs or help on this!
Thanks,
Sri
(Liferay 6.1)
I am trying to enable VIEW permission for a Role on a Message Board Category at INDIVIDUAL scope level PROGRAMMATICALLY
I created categories and roles pro-grammatically and I could see them in control panel.
I tried following ways to give(check box should be checked) VIEW permission for a role on a category.
PermissionLocalServiceUtil.setRolePermissions(roleId, companyId, resourceName, resourceScope, resourceId , actionIds);
ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId, resourceName, resourceScope, resourceId, roleId, actionIds);
PermissionLocalServiceUtil.setRolePermissions(...) // throwing NoSuchPermission exception.
ResourcePermissionLocalServiceUtil.setResourcePermissions(...) //throwing NoSuchResourceActionException.
and obviously there are no records in RESOURCEPERMISSION table associated to above created role.
I see all permissions UNchecked for the created role on created category (all the check boxes are unchecked) (:
I would like to check VIEW permission programmatically.
Do I need to add permissions first on resource for specific role ? If so, I do not see any method in ResourcePermissionLocalServiceUtil that adds a permission on resource for specific role at INDIVIDUAL scope.
I appreciate any inputs or help on this!
Thanks,
Sri
sri p, modifié il y a 10 années.
RE: Giving view permission for a ROLE on a Resource
Junior Member Publications: 85 Date d'inscription: 22/01/11 Publications récentes
PermissionLocalServiceUtil.setRolePermissions(...) // throwing NoSuchPermission exception.
ResourcePermissionLocalServiceUtil.setResourcePermissions(...) //throwing NoSuchResourceActionException.
I hope some one from Liferay staff could tell me why I am getting above exceptions and what should I do !
ResourcePermissionLocalServiceUtil.setResourcePermissions(...) //throwing NoSuchResourceActionException.
I hope some one from Liferay staff could tell me why I am getting above exceptions and what should I do !
sri p, modifié il y a 10 années.
RE: Giving view permission for a ROLE on a Resource (Réponse)
Junior Member Publications: 85 Date d'inscription: 22/01/11 Publications récentesI solved this by the following code. May it help others!
Resource resource = null;
try{
resource = ResourceLocalServiceUtil.getResource(category.getCompanyId(), MBCategory.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(category.getPrimaryKey()));
} catch (NoSuchResourceException ne) {
ResourceLocalServiceUtil.addResources(category.getCompanyId(), category.getGroupId(), 0, MBCategory.class.getName(), category.getCategoryId(), false, false, false);
resource = ResourceLocalServiceUtil.getResource(category.getCompanyId(), MBCategory.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(category.getPrimaryKey()));
}
ResourcePermissionLocalServiceUtil.setResourcePermissions((companyId, resource.getName(), resourceScope, resource.getPrimKey(), roleId, actionIds);