List of usage examples for com.liferay.portal.kernel.util WebKeys ASSET_RENDERER_FACTORY_GROUP
String ASSET_RENDERER_FACTORY_GROUP
To view the source code for com.liferay.portal.kernel.util WebKeys ASSET_RENDERER_FACTORY_GROUP.
Click Source Link
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; }//from ww w . j a v a2 s. com 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; }