private static void _populateContextFromThreadLocals(Map<String, Serializable> context) { if (!context.containsKey("companyId")) { context.put("companyId", CompanyThreadLocal.getCompanyId()); } if (!context.containsKey("defaultLocale")) { context.put("defaultLocale", LocaleThreadLocal.getDefaultLocale()); } if (!context.containsKey("groupId")) { context.put("groupId", GroupThreadLocal.getGroupId()); } if (!context.containsKey("principalName")) { context.put("principalName", PrincipalThreadLocal.getName()); } if (!context.containsKey("principalPassword")) { context.put("principalPassword", PrincipalThreadLocal.getPassword()); } if (!context.containsKey("siteDefaultLocale")) { context.put("siteDefaultLocale", LocaleThreadLocal.getSiteDefaultLocale()); } if (!context.containsKey("themeDisplayLocale")) { context.put("themeDisplayLocale", LocaleThreadLocal.getThemeDisplayLocale()); } }
protected void updateArticleType() throws Exception { if (!hasSelectedArticleTypes()) { return; } 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); } }