Example usage for com.liferay.portal.kernel.upgrade.util UpgradeProcessUtil getDefaultLanguageId

List of usage examples for com.liferay.portal.kernel.upgrade.util UpgradeProcessUtil getDefaultLanguageId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.upgrade.util UpgradeProcessUtil getDefaultLanguageId.

Prototype

public static String getDefaultLanguageId(long companyId) throws SQLException 

Source Link

Usage

From source file:com.liferay.defaultwebcontent.hook.upgrade.v1_0_0.UpgradeJournal.java

License:Open Source License

@Override
protected void doUpgrade() throws Exception {
    long companyId = PortalUtil.getDefaultCompanyId();

    Group group = GroupLocalServiceUtil.getCompanyGroup(companyId);

    long groupId = group.getGroupId();
    long userId = UserLocalServiceUtil.getDefaultUserId(companyId);

    String languageId = UpgradeProcessUtil.getDefaultLanguageId(companyId);

    Locale locale = LocaleUtil.fromLanguageId(languageId);

    addJournalStructures(groupId, userId, locale);
    addJournalTemplates(groupId, userId, locale);
}

From source file:com.liferay.journal.internal.upgrade.v0_0_3.UpgradeJournalArticleType.java

License:Open Source License

protected void updateArticleType() throws Exception {
    try (LoggingTimer loggingTimer = new LoggingTimer()) {
        if (!hasSelectedArticleTypes()) {
            return;
        }/*from  www  .ja  va 2  s  . co m*/

        List<String> types = getArticleTypes();

        if (types.size() <= 0) {
            return;
        }

        Locale localeThreadLocalDefaultLocale = LocaleThreadLocal.getDefaultLocale();

        try {
            List<Company> companies = _companyLocalService.getCompanies();

            for (Company company : companies) {
                LocaleThreadLocal.setDefaultLocale(company.getLocale());

                Set<Locale> locales = LanguageUtil.getAvailableLocales(company.getGroupId());

                Locale defaultLocale = LocaleUtil
                        .fromLanguageId(UpgradeProcessUtil.getDefaultLanguageId(company.getCompanyId()));

                Map<Locale, String> nameMap = LocalizationUtil.getLocalizationMap(locales, defaultLocale,
                        "type");

                AssetVocabulary assetVocabulary = addAssetVocabulary(company.getGroupId(),
                        company.getCompanyId(), "type", nameMap, new HashMap<Locale, String>());

                Map<String, Long> journalArticleTypesToAssetCategoryIds = new HashMap<>();

                for (String type : types) {
                    AssetCategory assetCategory = addAssetCategory(company.getGroupId(), company.getCompanyId(),
                            type, assetVocabulary.getVocabularyId());

                    journalArticleTypesToAssetCategoryIds.put(type, assetCategory.getCategoryId());
                }

                updateArticles(company.getCompanyId(), journalArticleTypesToAssetCategoryIds);
            }
        } finally {
            LocaleThreadLocal.setDefaultLocale(localeThreadLocalDefaultLocale);
        }
    }
}

From source file:com.liferay.journal.internal.upgrade.v0_0_5.UpgradeJournal.java

License:Open Source License

protected String addBasicWebContentStructureAndTemplate(long companyId) throws Exception {

    initJournalDDMCompositeModelsResourceActions();

    Group group = _groupLocalService.getCompanyGroup(companyId);

    long defaultUserId = _userLocalService.getDefaultUserId(companyId);

    Class<?> clazz = getClass();

    _defaultDDMStructureHelper.addDDMStructures(defaultUserId, group.getGroupId(),
            PortalUtil.getClassNameId(JournalArticle.class), clazz.getClassLoader(),
            "com/liferay/journal/internal/upgrade/v1_0_0/dependencies" + "/basic-web-content-structure.xml",
            new ServiceContext());

    String defaultLanguageId = UpgradeProcessUtil.getDefaultLanguageId(companyId);

    Locale defaultLocale = LocaleUtil.fromLanguageId(defaultLanguageId);

    List<Element> structureElements = getDDMStructures(defaultLocale);

    Element structureElement = structureElements.get(0);

    return StringUtil.toUpperCase(structureElement.elementText("name"));
}