Example usage for com.liferay.portal.kernel.model Company getGroup

List of usage examples for com.liferay.portal.kernel.model Company getGroup

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model Company getGroup.

Prototype

public Group getGroup() throws com.liferay.portal.kernel.exception.PortalException;

Source Link

Usage

From source file:com.liferay.asset.categories.navigation.web.internal.exportimport.portlet.preferences.processor.AssetCategoriesNavigationPortletPreferencesProcessor.java

License:Open Source License

protected PortletPreferences updateImportPortletPreferences(PortletDataContext portletDataContext,
        PortletPreferences portletPreferences) throws Exception {

    Company company = _companyLocalService.getCompanyById(portletDataContext.getCompanyId());

    Group companyGroup = company.getGroup();

    Enumeration<String> enu = portletPreferences.getNames();

    while (enu.hasMoreElements()) {
        String name = enu.nextElement();

        if (name.equals("assetVocabularyIds")) {
            updateImportPortletPreferencesClassPKs(portletDataContext, portletPreferences, name,
                    AssetVocabulary.class, companyGroup.getGroupId());
        }//from  w  ww . jav  a2  s.c om
    }

    return portletPreferences;
}

From source file:com.liferay.asset.publisher.lar.test.AssetPublisherExportImportTest.java

License:Open Source License

@Test
public void testExportImportSeveralScopedAssetEntries() throws Exception {
    List<Group> groups = new ArrayList<>();

    Company company = CompanyLocalServiceUtil.getCompany(layout.getCompanyId());

    Group companyGroup = company.getGroup();

    groups.add(companyGroup);/*from  w  ww. jav a2  s  .c  o m*/

    groups.add(group);

    Group group2 = GroupTestUtil.addGroup();

    groups.add(group2);

    Group layoutGroup1 = GroupTestUtil.addGroup(TestPropsValues.getUserId(), layout);

    groups.add(layoutGroup1);

    Layout layout2 = LayoutTestUtil.addLayout(group);

    Group layoutGroup2 = GroupTestUtil.addGroup(TestPropsValues.getUserId(), layout2);

    groups.add(layoutGroup2);

    testExportImportAssetEntries(groups);
}

From source file:com.liferay.asset.publisher.lar.test.AssetPublisherExportImportTest.java

License:Open Source License

@Test
public void testGlobalScopeId() throws Exception {
    Map<String, String[]> preferenceMap = new HashMap<>();

    Company company = CompanyLocalServiceUtil.getCompany(layout.getCompanyId());

    Group companyGroup = company.getGroup();

    preferenceMap.put("scopeIds",
            new String[] { AssetPublisherHelper.SCOPE_ID_GROUP_PREFIX + companyGroup.getGroupId() });

    PortletPreferences portletPreferences = getImportedPortletPreferences(preferenceMap);

    Assert.assertEquals(AssetPublisherHelper.SCOPE_ID_GROUP_PREFIX + companyGroup.getGroupId(),
            portletPreferences.getValue("scopeIds", null));
    Assert.assertEquals(null, portletPreferences.getValue("scopeId", null));
}

From source file:com.liferay.asset.publisher.lar.test.AssetPublisherExportImportTest.java

License:Open Source License

@Test
public void testSeveralLayoutScopeIds() throws Exception {
    Company company = CompanyLocalServiceUtil.getCompany(layout.getCompanyId());

    Layout secondLayout = LayoutTestUtil.addLayout(group);

    GroupTestUtil.addGroup(TestPropsValues.getUserId(), secondLayout);

    Map<String, String[]> preferenceMap = new HashMap<>();

    GroupTestUtil.addGroup(TestPropsValues.getUserId(), layout);

    Group companyGroup = company.getGroup();

    preferenceMap.put("scopeIds",
            new String[] { AssetPublisherHelper.SCOPE_ID_GROUP_PREFIX + companyGroup.getGroupId(),
                    AssetPublisherHelper.SCOPE_ID_LAYOUT_UUID_PREFIX + layout.getUuid(),
                    AssetPublisherHelper.SCOPE_ID_LAYOUT_UUID_PREFIX + secondLayout.getUuid() });

    PortletPreferences portletPreferences = getImportedPortletPreferences(preferenceMap);

    Layout importedSecondLayout = LayoutLocalServiceUtil.fetchLayoutByUuidAndGroupId(secondLayout.getUuid(),
            importedGroup.getGroupId(), importedLayout.isPrivateLayout());

    Assert.assertEquals(null, portletPreferences.getValue("scopeId", null));

    StringBundler sb = new StringBundler(8);

    sb.append(AssetPublisherHelper.SCOPE_ID_GROUP_PREFIX);
    sb.append(companyGroup.getGroupId());
    sb.append(StringPool.COMMA);/* w  w  w . j  a  v  a 2 s .co m*/
    sb.append(AssetPublisherHelper.SCOPE_ID_LAYOUT_UUID_PREFIX);
    sb.append(importedLayout.getUuid());
    sb.append(StringPool.COMMA);
    sb.append(AssetPublisherHelper.SCOPE_ID_LAYOUT_UUID_PREFIX);
    sb.append(importedSecondLayout.getUuid());

    Assert.assertEquals(sb.toString(), StringUtil.merge(portletPreferences.getValues("scopeIds", null)));
}

From source file:com.liferay.asset.publisher.web.internal.exportimport.portlet.preferences.processor.AssetPublisherExportImportPortletPreferencesProcessor.java

License:Open Source License

protected PortletPreferences updateImportPortletPreferences(PortletDataContext portletDataContext,
        PortletPreferences portletPreferences) throws Exception {

    Company company = _companyLocalService.getCompanyById(portletDataContext.getCompanyId());

    Group companyGroup = company.getGroup();

    String anyAssetTypeClassName = portletPreferences.getValue("anyAssetType", StringPool.BLANK);

    Enumeration<String> enu = portletPreferences.getNames();

    while (enu.hasMoreElements()) {
        String name = enu.nextElement();

        String value = GetterUtil.getString(portletPreferences.getValue(name, null));

        if (name.equals("anyAssetType") || name.equals("classNameIds")) {
            updateImportClassNameIds(portletPreferences, name);
        } else if (name.equals("anyClassTypeDLFileEntryAssetRendererFactory")
                || (name.equals("classTypeIds") && anyAssetTypeClassName.equals(DLFileEntry.class.getName()))
                || name.equals("classTypeIdsDLFileEntryAssetRendererFactory")) {

            updateImportPortletPreferencesClassPKs(portletDataContext, portletPreferences, name,
                    DLFileEntryType.class, companyGroup.getGroupId());
        } else if (name.equals("anyClassTypeJournalArticleAssetRendererFactory")
                || (name.equals("classTypeIds") && anyAssetTypeClassName.equals(JournalArticle.class.getName()))
                || name.equals("classTypeIdsJournalArticleAssetRendererFactory")) {

            updateImportPortletPreferencesClassPKs(portletDataContext, portletPreferences, name,
                    DDMStructure.class, companyGroup.getGroupId());
        } else if (name.equals("assetVocabularyId")) {
            updateImportPortletPreferencesClassPKs(portletDataContext, portletPreferences, name,
                    AssetVocabulary.class, companyGroup.getGroupId());
        } else if (name.startsWith("orderByColumn")
                && StringUtil.startsWith(value, DDMStructureManager.STRUCTURE_INDEXER_FIELD_PREFIX)) {

            updateImportOrderByColumnClassPKs(portletDataContext, portletPreferences, name,
                    companyGroup.getGroupId());
        } else if (name.startsWith("queryName") && StringUtil.equalsIgnoreCase(value, "assetCategories")) {

            String index = name.substring(9);

            updateImportPortletPreferencesClassPKs(portletDataContext, portletPreferences,
                    "queryValues" + index, AssetCategory.class, companyGroup.getGroupId());
        } else if (name.equals("scopeIds")) {
            updateImportScopeIds(portletDataContext, portletPreferences, name, companyGroup.getGroupId(),
                    portletDataContext.getPlid());
        }/*from  w w w  .  j  a  va2  s . co m*/
    }

    restorePortletPreference(portletDataContext, "notifiedAssetEntryIds", portletPreferences);

    return portletPreferences;
}

From source file:com.liferay.asset.util.test.AssetVocabularyUtilTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    _group = GroupTestUtil.addGroup();//from  ww w. j av  a 2s  .c  o m

    Map<Locale, String> titleMap = new HashMap<>();

    titleMap.put(_LOCALE, _TITLE);

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId(),
            TestPropsValues.getUserId());

    _vocabulary = AssetVocabularyLocalServiceUtil.addVocabulary(TestPropsValues.getUserId(),
            _group.getGroupId(), _TITLE, titleMap, null, null, serviceContext);

    Company company = CompanyLocalServiceUtil.getCompany(_group.getCompanyId());

    _companyGroup = company.getGroup();

    serviceContext = ServiceContextTestUtil.getServiceContext(_companyGroup.getGroupId(),
            TestPropsValues.getUserId());

    _companyVocabulary = AssetVocabularyLocalServiceUtil.addVocabulary(TestPropsValues.getUserId(),
            _companyGroup.getGroupId(), _TITLE, titleMap, null, null, serviceContext);
}

From source file:com.liferay.blogs.recent.bloggers.web.internal.exportimport.portlet.preferences.processor.RecentBloggersExportImportPortletPreferencesProcessor.java

License:Open Source License

protected PortletPreferences updateImportPortletPreferences(PortletDataContext portletDataContext,
        PortletPreferences portletPreferences) throws Exception {

    long organizationId = GetterUtil.getLong(portletPreferences.getValue("organizationId", null));

    if (organizationId > 0) {
        Company company = _companyLocalService.getCompanyById(portletDataContext.getCompanyId());

        Group companyGroup = company.getGroup();

        updateImportPortletPreferencesClassPKs(portletDataContext, portletPreferences, "organizationId",
                Organization.class, companyGroup.getGroupId());
    }//  w  w  w.  ja v a 2 s. co  m

    return portletPreferences;
}

From source file:com.liferay.document.library.internal.exportimport.data.handler.test.FileEntryStagedModelDataHandlerTest.java

License:Open Source License

protected Map<String, List<StagedModel>> addCompanyDependencies() throws Exception {

    Map<String, List<StagedModel>> dependentStagedModelsMap = new HashMap<>();

    Company company = CompanyLocalServiceUtil.fetchCompany(stagingGroup.getCompanyId());

    Group companyGroup = company.getGroup();

    DDMStructure ddmStructure = DDMStructureTestUtil.addStructure(companyGroup.getGroupId(),
            DLFileEntryMetadata.class.getName());

    addDependentStagedModel(dependentStagedModelsMap, DDMStructureManagerUtil.getDDMStructureModelClass(),
            ddmStructure);/*from w w w .j a v  a  2  s  .co  m*/

    DLFileEntryType dlFileEntryType = addDLFileEntryType(companyGroup.getGroupId(),
            ddmStructure.getStructureId());

    addDependentStagedModel(dependentStagedModelsMap, DLFileEntryType.class, dlFileEntryType);

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(stagingGroup.getGroupId(),
            TestPropsValues.getUserId());

    Folder folder = DLAppServiceUtil.addFolder(stagingGroup.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, RandomTestUtil.randomString(),
            RandomTestUtil.randomString(), serviceContext);

    addDependentStagedModel(dependentStagedModelsMap, DLFolder.class, folder);

    return dependentStagedModelsMap;
}

From source file:com.liferay.exportimport.test.LayoutExportImportTest.java

License:Open Source License

@Test
public void testExportImportCompanyGroupInvalidLARType() throws Exception {

    // Import a layout set to a company layout set

    Group originalImportedGroup = importedGroup;
    Group originalGroup = group;/*from w ww.j  ava 2 s  . c  om*/

    Company company = CompanyLocalServiceUtil.getCompany(TestPropsValues.getCompanyId());

    importedGroup = company.getGroup();

    long[] layoutIds = new long[0];

    try {
        exportImportLayouts(layoutIds, getImportParameterMap());

        Assert.fail();
    } catch (LARTypeException larte) {
    } finally {
        importedGroup = originalImportedGroup;
    }

    // Import a company layout set to a layout set

    group = company.getGroup();
    importedGroup = originalGroup;

    try {
        exportImportLayouts(layoutIds, getImportParameterMap());

        Assert.fail();
    } catch (LARTypeException larte) {
    } finally {
        importedGroup = originalImportedGroup;
        group = originalGroup;
    }
}

From source file:com.liferay.exportimport.test.util.lar.BaseStagedModelDataHandlerTestCase.java

License:Open Source License

protected StagedModelAssets updateAssetEntry(StagedModel stagedModel, Group group) throws Exception {

    AssetEntry assetEntry = fetchAssetEntry(stagedModel, group);

    if (assetEntry == null) {
        return null;
    }//from  w  w  w.java 2  s  .  co  m

    AssetVocabulary assetVocabulary = AssetTestUtil.addVocabulary(stagingGroup.getGroupId());

    AssetCategory assetCategory = AssetTestUtil.addCategory(stagingGroup.getGroupId(),
            assetVocabulary.getVocabularyId());

    Company company = CompanyLocalServiceUtil.getCompany(stagedModel.getCompanyId());

    Group companyGroup = company.getGroup();

    AssetVocabulary companyAssetVocabulary = AssetTestUtil.addVocabulary(companyGroup.getGroupId());

    AssetCategory companyAssetCategory = AssetTestUtil.addCategory(companyGroup.getGroupId(),
            companyAssetVocabulary.getVocabularyId());

    AssetTag assetTag = AssetTestUtil.addTag(stagingGroup.getGroupId());

    double assetPriority = assetEntry.getPriority();

    if (isAssetPrioritySupported()) {
        assetPriority = RandomTestUtil.nextDouble();
    }

    assetEntry = AssetEntryLocalServiceUtil.updateEntry(TestPropsValues.getUserId(), stagingGroup.getGroupId(),
            assetEntry.getCreateDate(), assetEntry.getModifiedDate(), assetEntry.getClassName(),
            assetEntry.getClassPK(), assetEntry.getClassUuid(), assetEntry.getClassTypeId(),
            new long[] { assetCategory.getCategoryId(), companyAssetCategory.getCategoryId() },
            new String[] { assetTag.getName() }, assetEntry.isListable(), assetEntry.isVisible(),
            assetEntry.getStartDate(), assetEntry.getEndDate(), assetEntry.getPublishDate(),
            assetEntry.getExpirationDate(), assetEntry.getMimeType(), assetEntry.getTitle(),
            assetEntry.getDescription(), assetEntry.getSummary(), assetEntry.getUrl(),
            assetEntry.getLayoutUuid(), assetEntry.getHeight(), assetEntry.getWidth(), assetPriority);

    return new StagedModelAssets(assetCategory, assetEntry, assetTag, assetVocabulary);
}