Checking the Weather user has userdelete Permission or not.


First of all we need the permission checker we can get it from the themedisplay.


PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

 boolean deleteStatus  = false;
try {

Getting the all the Role of the User
List<Role> roleList = RoleLocalServiceUtil.getUserRoles(themeDisplay.getUserId());
    for(Role role : roleList) {

Iterating the all the roles of the user
          if(permissionChecker.hasPermission(themeDisplay.getScopeGroupId(), User.class.getName(),                          role.getRoleId(), ActionKeys.DELETE)) {

           deleteStatus = true;
        System.out.println("roleId"+role.getName());

         }
    }

} catch (SystemException e) {
          e.printStackTrace();
}

Comments

Popular posts from this blog

How to know which liferay version we are using

Viewing the SQL Query in liferay : debugging the SQL Query in Hibernate

Opening portlet in popup