List of usage examples for com.liferay.portal.kernel.util PortalUtil getCurrentAndAncestorSiteGroupIds
public static long[] getCurrentAndAncestorSiteGroupIds(long[] groupIds) throws PortalException
From source file:com.liferay.asset.categories.navigation.web.internal.display.context.AssetCategoriesNavigationDisplayContext.java
License:Open Source License
public List<AssetVocabulary> getAssetVocabularies() { if (_assetVocabularies != null) { return _assetVocabularies; }//from www .j a va2 s. c o m ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); long[] groupIds = new long[0]; try { groupIds = PortalUtil.getCurrentAndAncestorSiteGroupIds(themeDisplay.getScopeGroupId()); } catch (PortalException pe) { groupIds = new long[] { themeDisplay.getScopeGroupId() }; _log.error(pe, pe); } _assetVocabularies = AssetVocabularyServiceUtil.getGroupVocabularies(groupIds); return _assetVocabularies; }
From source file:com.liferay.asset.taglib.internal.display.context.InputAssetLinksDisplayContext.java
License:Open Source License
private List<Map<String, Object>> _getSelectorEntries(AssetRendererFactory<?> assetRendererFactory) throws Exception { long groupId = _getAssetBrowserGroupId(assetRendererFactory); ClassTypeReader classTypeReader = assetRendererFactory.getClassTypeReader(); List<ClassType> classTypes = classTypeReader.getAvailableClassTypes( PortalUtil.getCurrentAndAncestorSiteGroupIds(groupId), _themeDisplay.getLocale()); if (classTypes.isEmpty()) { return Collections.emptyList(); }//from w w w.j av a 2 s . com List<Map<String, Object>> selectorEntries = new ArrayList<>(); for (ClassType classType : classTypes) { Map<String, Object> selectorEntry = new HashMap<>(); selectorEntry.put("data", _getSelectorEntryData(assetRendererFactory, classType)); selectorEntry.put("iconCssClass", _getSelectorEntryIconCssClass(assetRendererFactory)); selectorEntry.put("id", _getSelectorEntryId(assetRendererFactory, classType)); selectorEntry.put("message", _getSelectorEntryMessage(classType)); selectorEntries.add(selectorEntry); } return selectorEntries; }
From source file:com.liferay.asset.taglib.servlet.taglib.AssetCategoriesSelectorTag.java
License:Open Source License
protected long[] getGroupIds() { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); try {//from w w w. ja v a 2s. c o m if (ArrayUtil.isEmpty(_groupIds)) { return PortalUtil.getCurrentAndAncestorSiteGroupIds(themeDisplay.getScopeGroupId()); } return PortalUtil.getCurrentAndAncestorSiteGroupIds(_groupIds); } catch (Exception e) { } return new long[0]; }
From source file:com.liferay.document.library.service.test.DLFileEntryTypeServiceTest.java
License:Open Source License
@Before public void setUp() throws Exception { setUpDDMFormXSDDeserializer();//from w ww . j a v a2 s . c om setUpPermissionThreadLocal(); setUpPrincipalThreadLocal(); _group = GroupTestUtil.addGroup(); _folder = DLAppLocalServiceUtil.addFolder(TestPropsValues.getUserId(), _group.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Folder A", "", ServiceContextTestUtil.getServiceContext(_group.getGroupId())); _subfolder = DLAppLocalServiceUtil.addFolder(TestPropsValues.getUserId(), _group.getGroupId(), _folder.getFolderId(), "SubFolder AA", "", ServiceContextTestUtil.getServiceContext(_group.getGroupId())); _basicDocumentDLFileEntryType = DLFileEntryTypeLocalServiceUtil .getFileEntryType(DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT); _dlFileEntryTypes = DLFileEntryTypeLocalServiceUtil .getFileEntryTypes(PortalUtil.getCurrentAndAncestorSiteGroupIds(_group.getGroupId())); for (DLFileEntryType dlFileEntryType : _dlFileEntryTypes) { String fileEntryTypeKey = dlFileEntryType.getFileEntryTypeKey(); if (fileEntryTypeKey.equals(DLFileEntryTypeConstants.FILE_ENTRY_TYPE_KEY_CONTRACT)) { _contractDLFileEntryType = dlFileEntryType; } else if (fileEntryTypeKey.equals(DLFileEntryTypeConstants.FILE_ENTRY_TYPE_KEY_MARKETING_BANNER)) { _marketingBannerDLFileEntryType = dlFileEntryType; } } }
From source file:com.liferay.document.library.service.test.DLFileVersionTest.java
License:Open Source License
@Before public void setUp() throws Exception { setUpPermissionThreadLocal();//from w ww. jav a 2s. co m setUpPrincipalThreadLocal(); _group = GroupTestUtil.addGroup(); setUpParentFolder(); setUpResourcePermission(); List<DLFileEntryType> dlFileEntryTypes = DLFileEntryTypeLocalServiceUtil .getFileEntryTypes(PortalUtil.getCurrentAndAncestorSiteGroupIds(_group.getGroupId())); for (DLFileEntryType dlFileEntryType : dlFileEntryTypes) { String fileEntryTypeKey = dlFileEntryType.getFileEntryTypeKey(); if (fileEntryTypeKey.equals(DLFileEntryTypeConstants.FILE_ENTRY_TYPE_KEY_CONTRACT)) { _contractDLFileEntryTypeId = dlFileEntryType.getFileEntryTypeId(); } } ExpandoTable expandoTable = ExpandoTableLocalServiceUtil.addDefaultTable(PortalUtil.getDefaultCompanyId(), DLFileEntry.class.getName()); ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), _EXPANDO_ATTRIBUTE_NAME, ExpandoColumnConstants.STRING, StringPool.BLANK); _serviceContext = getServiceContext(); FileEntry fileEntry = DLAppServiceUtil.addFileEntry(_group.getGroupId(), _parentFolder.getFolderId(), _SOURCE_FILE_NAME, ContentTypes.APPLICATION_OCTET_STREAM, _TITLE, StringPool.BLANK, StringPool.BLANK, _DATA_VERSION_1, _serviceContext); _fileVersion = DLFileVersionLocalServiceUtil.getFileVersion(fileEntry.getFileEntryId(), DLFileEntryConstants.VERSION_DEFAULT); }
From source file:com.liferay.dynamic.data.mapping.util.BaseDDMDisplay.java
License:Open Source License
@Override public long[] getTemplateGroupIds(ThemeDisplay themeDisplay, boolean includeAncestorTemplates) throws Exception { HttpServletRequest request = themeDisplay.getRequest(); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); long groupId = themeDisplay.getScopeGroupId(); String refererPortletName = ParamUtil.getString(request, portletDisplay.getNamespace() + "refererPortletName"); if (Validator.isNull(refererPortletName)) { groupId = PortalUtil.getScopeGroupId(request, refererPortletName); }/*from w w w. j a v a 2 s .c om*/ if (includeAncestorTemplates) { return PortalUtil.getCurrentAndAncestorSiteGroupIds(groupId); } return new long[] { groupId }; }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
protected void validateDDMStructureId(long groupId, long folderId, String ddmStructureKey) throws PortalException { int restrictionType = JournalUtil.getRestrictionType(folderId); DDMStructure ddmStructure = ddmStructureLocalService.getStructure(PortalUtil.getSiteGroupId(groupId), classNameLocalService.getClassNameId(JournalArticle.class), ddmStructureKey, true); List<DDMStructure> folderDDMStructures = journalFolderLocalService .getDDMStructures(PortalUtil.getCurrentAndAncestorSiteGroupIds(groupId), folderId, restrictionType); for (DDMStructure folderDDMStructure : folderDDMStructures) { if (folderDDMStructure.getStructureId() == ddmStructure.getStructureId()) { return; }//www.j av a2 s. c o m } throw new InvalidDDMStructureException( "Invalid structure " + ddmStructure.getStructureId() + " for folder " + folderId); }
From source file:com.liferay.journal.service.impl.JournalFolderLocalServiceImpl.java
License:Open Source License
@Override public void validateFolderDDMStructures(long folderId, long parentFolderId) throws PortalException { JournalFolder folder = journalFolderLocalService.fetchFolder(folderId); int restrictionType = JournalFolderConstants.RESTRICTION_TYPE_DDM_STRUCTURES_AND_WORKFLOW; JournalFolder parentFolder = journalFolderLocalService.fetchFolder(parentFolderId); if (parentFolder != null) { restrictionType = parentFolder.getRestrictionType(); }/*from w w w . j av a2s .com*/ List<DDMStructure> folderDDMStructures = getDDMStructures( PortalUtil.getCurrentAndAncestorSiteGroupIds(folder.getGroupId()), parentFolderId, restrictionType); long[] ddmStructureIds = new long[folderDDMStructures.size()]; for (int i = 0; i < folderDDMStructures.size(); i++) { DDMStructure folderDDMStructure = folderDDMStructures.get(i); ddmStructureIds[i] = folderDDMStructure.getStructureId(); } validateArticleDDMStructures(folderId, ddmStructureIds); }
From source file:com.liferay.journal.service.test.JournalFolderServiceTest.java
License:Open Source License
@Test public void testAddArticleToRestrictedFolder() throws Exception { JournalFolder folder = JournalTestUtil.addFolder(_group.getGroupId(), JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Test 1"); DDMStructure ddmStructure1 = DDMStructureTestUtil.addStructure(_group.getGroupId(), JournalArticle.class.getName()); long[] ddmStructureIds = new long[] { ddmStructure1.getStructureId() }; ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); JournalFolderLocalServiceUtil.updateFolder(TestPropsValues.getUserId(), serviceContext.getScopeGroupId(), folder.getFolderId(), folder.getParentFolderId(), folder.getName(), folder.getDescription(), ddmStructureIds, JournalFolderConstants.RESTRICTION_TYPE_DDM_STRUCTURES_AND_WORKFLOW, false, serviceContext);/*from www. ja va 2 s .co m*/ List<DDMStructure> ddmStructures = JournalFolderLocalServiceUtil.getDDMStructures( PortalUtil.getCurrentAndAncestorSiteGroupIds(_group.getGroupId()), folder.getFolderId(), JournalFolderConstants.RESTRICTION_TYPE_DDM_STRUCTURES_AND_WORKFLOW); Assert.assertFalse(ddmStructures.isEmpty()); String xml = DDMStructureTestUtil.getSampleStructuredContent("Test Article"); DDMStructure ddmStructure2 = DDMStructureTestUtil.addStructure(_group.getGroupId(), JournalArticle.class.getName()); DDMTemplate ddmTemplate2 = DDMTemplateTestUtil.addTemplate(_group.getGroupId(), ddmStructure2.getStructureId(), PortalUtil.getClassNameId(JournalArticle.class), LocaleUtil.getDefault()); try { JournalTestUtil.addArticleWithXMLContent(_group.getGroupId(), folder.getFolderId(), JournalArticleConstants.CLASSNAME_ID_DEFAULT, xml, ddmStructure2.getStructureKey(), ddmTemplate2.getTemplateKey()); Assert.fail(); } catch (InvalidDDMStructureException iddmse) { } JournalFolder subfolder = JournalTestUtil.addFolder(_group.getGroupId(), folder.getFolderId(), "Test 1.1"); try { JournalTestUtil.addArticleWithXMLContent(_group.getGroupId(), subfolder.getFolderId(), JournalArticleConstants.CLASSNAME_ID_DEFAULT, xml, ddmStructure2.getStructureKey(), ddmTemplate2.getTemplateKey()); Assert.fail(); } catch (InvalidDDMStructureException iddmse) { } JournalFolderLocalServiceUtil.deleteFolder(folder.getFolderId()); ddmStructures = JournalFolderLocalServiceUtil.getDDMStructures( PortalUtil.getCurrentAndAncestorSiteGroupIds(_group.getGroupId()), folder.getFolderId(), JournalFolderConstants.RESTRICTION_TYPE_DDM_STRUCTURES_AND_WORKFLOW); Assert.assertTrue(ddmStructures.isEmpty()); }