Search code examples
jakarta-eepermissionsliferayliferay-6

check permissions in journal article for specific user


I have a class in java with some information, like userId, companyId and JournalArticle. So I need check if this user have permission for view the journalArticle. I saw another post with the same idea but it's not what I need. Which is the best way for do this?

Thank you!!!

Add part of my code:

List<User> users = doListUsr(); //list of users
List<JournalArticle> listArticles = generatedListArticles(); //list of articles
for(User tmp: users){
    for(JournalArticle tmp2: listArticles){
      //check if this user has permission to view every journal article
    }
}

Solution

  • I solve it with API ResourcePermission:

        resourcePermissionList = ResourcePermissionLocalServiceUtil.getRoleResourcePermissions(roles[i]);
    

    I get the roles of user.