List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getPermissionChecker
@JSON(include = false)
public PermissionChecker getPermissionChecker()
From source file:com.liferay.application.list.taglib.servlet.taglib.PanelCategoryTag.java
License:Open Source License
@Override protected void setAttributes(HttpServletRequest request) { PanelAppRegistry panelAppRegistry = (PanelAppRegistry) request .getAttribute(ApplicationListWebKeys.PANEL_APP_REGISTRY); PanelCategoryRegistry panelCategoryRegistry = (PanelCategoryRegistry) request .getAttribute(ApplicationListWebKeys.PANEL_CATEGORY_REGISTRY); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Group group = getGroup();//from w w w.j a va 2 s. co m List<PanelApp> panelApps = panelAppRegistry.getPanelApps(_panelCategory, themeDisplay.getPermissionChecker(), group); PanelCategoryHelper panelCategoryHelper = new PanelCategoryHelper(panelAppRegistry, panelCategoryRegistry); request.setAttribute("liferay-application-list:panel-category:active", isActive(panelApps, panelCategoryHelper, group)); request.setAttribute("liferay-application-list:panel-category:id", getId()); int notificationsCount = panelCategoryHelper.getNotificationsCount(_panelCategory.getKey(), themeDisplay.getPermissionChecker(), group, themeDisplay.getUser()); request.setAttribute("liferay-application-list:panel-category:notificationsCount", notificationsCount); request.setAttribute("liferay-application-list:panel-category:panelApps", panelApps); request.setAttribute("liferay-application-list:panel-category:panelCategory", _panelCategory); request.setAttribute("liferay-application-list:panel-category:persistState", isPersistState()); request.setAttribute("liferay-application-list:panel-category:showBody", _showBody); request.setAttribute("liferay-application-list:panel-category:showHeader", _showHeader); request.setAttribute("liferay-application-list:panel-category:showOpen", _showOpen); }
From source file:com.liferay.application.list.taglib.servlet.taglib.PanelTag.java
License:Open Source License
@Override protected void setAttributes(HttpServletRequest request) { if (_panelCategory == null) { _panelCategory = RootPanelCategory.getInstance(); }//from w ww .j a v a 2 s .com PanelCategoryRegistry panelCategoryRegistry = (PanelCategoryRegistry) request .getAttribute(ApplicationListWebKeys.PANEL_CATEGORY_REGISTRY); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); List<PanelCategory> childPanelCategories = panelCategoryRegistry.getChildPanelCategories(_panelCategory, themeDisplay.getPermissionChecker(), getGroup()); request.setAttribute("liferay-application-list:panel:childPanelCategories", childPanelCategories); request.setAttribute("liferay-application-list:panel:panelCategory", _panelCategory); }
From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java
License:Open Source License
public boolean hasPermission(AssetCategory category, String actionId) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); Boolean hasPermission = StagingPermissionUtil.hasPermission(permissionChecker, themeDisplay.getScopeGroupId(), AssetCategory.class.getName(), category.getCategoryId(), AssetCategoriesAdminPortletKeys.ASSET_CATEGORIES_ADMIN, actionId); if (hasPermission != null) { return hasPermission.booleanValue(); }/*from w ww . j a v a 2 s .com*/ return AssetCategoryPermission.contains(permissionChecker, category, actionId); }
From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java
License:Open Source License
public boolean hasPermission(AssetVocabulary vocabulary, String actionId) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); Boolean hasPermission = StagingPermissionUtil.hasPermission(permissionChecker, themeDisplay.getScopeGroupId(), AssetVocabulary.class.getName(), vocabulary.getVocabularyId(), AssetCategoriesAdminPortletKeys.ASSET_CATEGORIES_ADMIN, actionId); if (hasPermission != null) { return hasPermission.booleanValue(); }/*from ww w .j a v a 2 s.co m*/ return AssetVocabularyPermission.contains(permissionChecker, vocabulary, actionId); }
From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java
License:Open Source License
public boolean isShowCategoriesAddButton() { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); if (AssetCategoriesPermission.contains(themeDisplay.getPermissionChecker(), AssetCategoriesPermission.RESOURCE_NAME, AssetCategoriesAdminPortletKeys.ASSET_CATEGORIES_ADMIN, themeDisplay.getSiteGroupId(), ActionKeys.ADD_CATEGORY)) { return true; }//from w w w . j a v a2 s .c o m return false; }
From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java
License:Open Source License
public boolean isShowVocabulariesAddButton() { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); if (AssetCategoriesPermission.contains(themeDisplay.getPermissionChecker(), AssetCategoriesPermission.RESOURCE_NAME, AssetCategoriesAdminPortletKeys.ASSET_CATEGORIES_ADMIN, themeDisplay.getSiteGroupId(), ActionKeys.ADD_VOCABULARY)) { return true; }/* w w w. j a v a 2 s. c om*/ return false; }
From source file:com.liferay.asset.categories.admin.web.internal.portlet.configuration.icon.PermissionsPortletConfigurationIcon.java
License:Open Source License
@Override public boolean isShow(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); User user = themeDisplay.getUser();/* w ww . j av a 2 s. co m*/ if (user.isDefaultUser()) { return false; } PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); try { if (!AssetCategoriesPermission.contains(permissionChecker, themeDisplay.getSiteGroupId(), ActionKeys.PERMISSIONS) || !GroupPermissionUtil.contains(permissionChecker, themeDisplay.getSiteGroupId(), ActionKeys.PERMISSIONS)) { return false; } } catch (Exception e) { return false; } return true; }
From source file:com.liferay.asset.display.template.web.internal.display.context.AssetDisplayTemplateDisplayContext.java
License:Open Source License
public boolean isShowAddButton() { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); if (AssetDisplayPermission.contains(themeDisplay.getPermissionChecker(), themeDisplay.getSiteGroupId(), AssetDisplayTemplateActionKeys.ADD_ASSET_DISPLAY_TEMPLATE)) { return true; }//from ww w . j a v a2s .c o m return false; }
From source file:com.liferay.asset.internal.util.AssetHelperImpl.java
License:Open Source License
@Override public PortletURL getAddPortletURL(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, long groupId, String className, long classTypeId, long[] allAssetCategoryIds, String[] allAssetTagNames, String redirect) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); AssetRendererFactory<?> assetRendererFactory = AssetRendererFactoryRegistryUtil .getAssetRendererFactoryByClassName(className); if ((assetRendererFactory == null) || !assetRendererFactory .hasAddPermission(themeDisplay.getPermissionChecker(), groupId, classTypeId)) { return null; }/* w w w . j a va2 s. c om*/ if (groupId > 0) { Group group = _groupLocalService.fetchGroup(groupId); liferayPortletRequest.setAttribute(WebKeys.ASSET_RENDERER_FACTORY_GROUP, group); } PortletURL addPortletURL = assetRendererFactory.getURLAdd(liferayPortletRequest, liferayPortletResponse, classTypeId); if (addPortletURL == null) { return null; } if (redirect != null) { addPortletURL.setParameter("redirect", redirect); } String referringPortletResource = ParamUtil.getString(liferayPortletRequest, "portletResource"); if (Validator.isNotNull(referringPortletResource)) { addPortletURL.setParameter("referringPortletResource", referringPortletResource); } else { PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); addPortletURL.setParameter("referringPortletResource", portletDisplay.getId()); if (allAssetCategoryIds != null) { Map<Long, String> assetVocabularyAssetCategoryIds = new HashMap<>(); for (long assetCategoryId : allAssetCategoryIds) { AssetCategory assetCategory = _assetCategoryLocalService.fetchAssetCategory(assetCategoryId); if (assetCategory == null) { continue; } long assetVocabularyId = assetCategory.getVocabularyId(); if (assetVocabularyAssetCategoryIds.containsKey(assetVocabularyId)) { String assetCategoryIds = assetVocabularyAssetCategoryIds.get(assetVocabularyId); assetVocabularyAssetCategoryIds.put(assetVocabularyId, assetCategoryIds + StringPool.COMMA + assetCategoryId); } else { assetVocabularyAssetCategoryIds.put(assetVocabularyId, String.valueOf(assetCategoryId)); } } for (Map.Entry<Long, String> entry : assetVocabularyAssetCategoryIds.entrySet()) { long assetVocabularyId = entry.getKey(); String assetCategoryIds = entry.getValue(); addPortletURL.setParameter("assetCategoryIds_" + assetVocabularyId, assetCategoryIds); } } if (allAssetTagNames != null) { addPortletURL.setParameter("assetTagNames", StringUtil.merge(allAssetTagNames)); } } addPortletURL.setPortletMode(PortletMode.VIEW); addPortletURL.setWindowState(LiferayWindowState.POP_UP); return addPortletURL; }
From source file:com.liferay.asset.publisher.web.display.context.AssetPublisherDisplayContext.java
License:Open Source License
public void setLayoutAssetEntry(AssetEntry assetEntry) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); String defaultAssetPublisherPortletId = _assetPublisherWebUtil .getDefaultAssetPublisherId(themeDisplay.getLayout()); if (isDefaultAssetPublisher() || Validator.isNull(defaultAssetPublisherPortletId) || !PortletPermissionUtil.contains(themeDisplay.getPermissionChecker(), themeDisplay.getLayout(), defaultAssetPublisherPortletId, ActionKeys.VIEW)) { _request.setAttribute(WebKeys.LAYOUT_ASSET_ENTRY, assetEntry); }//from ww w .java2s. com }