List of usage examples for com.liferay.portal.kernel.service.permission LayoutPermissionUtil contains
public static boolean contains(PermissionChecker permissionChecker, long groupId, boolean privateLayout, long layoutId, String actionId) throws PortalException
From source file:com.liferay.journal.search.JournalOpenSearchImpl.java
License:Open Source License
protected String getLayoutURL(ThemeDisplay themeDisplay, String articleId) throws Exception { PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); List<JournalContentSearch> contentSearches = _journalContentSearchLocalService .getArticleContentSearches(articleId); for (JournalContentSearch contentSearch : contentSearches) { if (LayoutPermissionUtil.contains(permissionChecker, contentSearch.getGroupId(), contentSearch.isPrivateLayout(), contentSearch.getLayoutId(), ActionKeys.VIEW)) { if (contentSearch.isPrivateLayout()) { if (!_groupLocalService.hasUserGroup(themeDisplay.getUserId(), contentSearch.getGroupId())) { continue; }/* www. ja va 2 s . c o m*/ } Layout hitLayout = _layoutLocalService.getLayout(contentSearch.getGroupId(), contentSearch.isPrivateLayout(), contentSearch.getLayoutId()); return _portal.getLayoutURL(hitLayout, themeDisplay); } } return null; }
From source file:com.liferay.journal.search.JournalOpenSearchImpl.java
License:Open Source License
@Override protected String getURL(ThemeDisplay themeDisplay, long groupId, Document result, PortletURL portletURL) throws Exception { String articleId = result.get("articleId"); JournalArticle article = _journalArticleService.getArticle(groupId, articleId); if (Validator.isNotNull(article.getLayoutUuid())) { String groupFriendlyURL = _portal.getGroupFriendlyURL( _layoutSetLocalService.getLayoutSet(article.getGroupId(), false), themeDisplay); return groupFriendlyURL.concat(JournalArticleConstants.CANONICAL_URL_SEPARATOR) .concat(article.getUrlTitle()); }/*from w ww .j a va 2 s.c om*/ Layout layout = themeDisplay.getLayout(); List<Long> hitLayoutIds = _journalContentSearchLocalService.getLayoutIds(layout.getGroupId(), layout.isPrivateLayout(), articleId); for (Long hitLayoutId : hitLayoutIds) { PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (LayoutPermissionUtil.contains(permissionChecker, layout.getGroupId(), layout.isPrivateLayout(), hitLayoutId, ActionKeys.VIEW)) { Layout hitLayout = _layoutLocalService.getLayout(layout.getGroupId(), layout.isPrivateLayout(), hitLayoutId.longValue()); return _portal.getLayoutURL(hitLayout, themeDisplay); } } String layoutURL = getLayoutURL(themeDisplay, articleId); if (layoutURL != null) { return layoutURL; } AssetEntry assetEntry = _assetEntryLocalService.fetchEntry(JournalArticle.class.getName(), article.getResourcePrimKey()); if (assetEntry == null) { return null; } portletURL.setParameter("assetEntryId", String.valueOf(assetEntry.getEntryId())); portletURL.setParameter("groupId", String.valueOf(groupId)); portletURL.setParameter("articleId", articleId); return portletURL.toString(); }