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);
    }
  }
  private static void _populateThreadLocalsFromContext(Map<String, Serializable> context) {

    long companyId = GetterUtil.getLong(context.get("companyId"));

    if (companyId > 0) {
      CompanyThreadLocal.setCompanyId(companyId);
    }

    Locale defaultLocale = (Locale) context.get("defaultLocale");

    if (defaultLocale != null) {
      LocaleThreadLocal.setDefaultLocale(defaultLocale);
    }

    long groupId = GetterUtil.getLong(context.get("groupId"));

    if (groupId > 0) {
      GroupThreadLocal.setGroupId(groupId);
    }

    String principalName = GetterUtil.getString(context.get("principalName"));

    if (Validator.isNotNull(principalName)) {
      PrincipalThreadLocal.setName(principalName);
    }

    PermissionChecker permissionChecker = null;

    if (Validator.isNotNull(principalName)) {
      try {
        User user = UserLocalServiceUtil.fetchUser(PrincipalThreadLocal.getUserId());

        permissionChecker = PermissionCheckerFactoryUtil.create(user);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }

    if (permissionChecker != null) {
      PermissionThreadLocal.setPermissionChecker(permissionChecker);
    }

    String principalPassword = GetterUtil.getString(context.get("principalPassword"));

    if (Validator.isNotNull(principalPassword)) {
      PrincipalThreadLocal.setPassword(principalPassword);
    }

    Locale siteDefaultLocale = (Locale) context.get("siteDefaultLocale");

    if (siteDefaultLocale != null) {
      LocaleThreadLocal.setSiteDefaultLocale(siteDefaultLocale);
    }

    Locale themeDisplayLocale = (Locale) context.get("themeDisplayLocale");

    if (themeDisplayLocale != null) {
      LocaleThreadLocal.setThemeDisplayLocale(themeDisplayLocale);
    }
  }