从 5.0 迁移时,似乎尚未设置文章的访客查看权限(如果之前已为访客用户设置了所有权限)。简单的解决方法是为您希望在相应社区中对来宾可见的所有文章分配来宾查看权限。下面代码中的这一行分配了查看权限
JournalArticleLocalServiceUtil.addArticleResources(groupId,
article.getArticleId(), new String[] { "VIEW" },
new String[] { "VIEW" });
它被称为资源,您将向文章资源添加权限。
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" });
}