0
votes

Our company is using Liferay portal 6.0.5 CE.

Within liferay we have a Community, community has few members and few web-contents.

By default all members have role Community member and they can view these web-contents. But if user tries to search web content via liferay search, it does not provide any results.

If I set permissions for web-contents such that Guest role can also view, then search provides the relevant results.

If it matters, before we had a Liferay 5.x and have migrated to 6.0 & then to 6.0.5.

Any ideas for this?

Thanks.

2

2 Answers

0
votes

It seems that the guest view permissions for articles have not been set when migrating from 5.0 (if at all permissions have been set before for guest users). Easy fix would be assigning guest view permissions for all the articles that you want to make visible for guest in the respective community. this line in the below code assigns view permissions

JournalArticleLocalServiceUtil.addArticleResources(groupId,
                article.getArticleId(), new String[] { "VIEW" },
                new String[] { "VIEW" });

its been referred as resource and you will be adding permissions to the Article Resources.

 ThemeDisplay themeDisplay = (ThemeDisplay) request
            .getAttribute(WebKeys.THEME_DISPLAY);
    long groupId = themeDisplay.getLayout().getGroupId();
    List<JournalArticle> articles = JournalArticleLocalServiceUtil
            .getArticles(groupId);

    for (JournalArticle article : articles) {
        JournalArticleLocalServiceUtil.addArticleResources(groupId,
                article.getArticleId(), new String[] { "VIEW" },
                new String[] { "VIEW" });
    }
0
votes

Thank you for advice, but I solved this trouble via hook for search portlet. For searching I used DynamicQuery and PermissionChecker and simple method String.contains(). It works bit slower, but it works--at least for 1k+ web contents!