@Indexable(type = IndexableType.REINDEX)
  @Override
  public AssetVocabulary updateVocabulary(
      long vocabularyId,
      String title,
      Map<Locale, String> titleMap,
      Map<Locale, String> descriptionMap,
      String settings,
      ServiceContext serviceContext)
      throws PortalException {

    String name = titleMap.get(LocaleUtil.getSiteDefault());

    AssetVocabulary vocabulary = assetVocabularyPersistence.findByPrimaryKey(vocabularyId);

    if (!vocabulary.getName().equals(name)) {
      validate(vocabulary.getGroupId(), name);
    }

    vocabulary.setName(name);
    vocabulary.setTitleMap(titleMap);

    if (Validator.isNotNull(title)) {
      vocabulary.setTitle(title);
    }

    vocabulary.setDescriptionMap(descriptionMap);
    vocabulary.setSettings(settings);

    assetVocabularyPersistence.update(vocabulary);

    return vocabulary;
  }
  @Indexable(type = IndexableType.REINDEX)
  @Override
  public AssetVocabulary addVocabulary(
      long userId,
      long groupId,
      String title,
      Map<Locale, String> titleMap,
      Map<Locale, String> descriptionMap,
      String settings,
      ServiceContext serviceContext)
      throws PortalException {

    // Vocabulary

    User user = userPersistence.findByPrimaryKey(userId);
    String name = titleMap.get(LocaleUtil.getSiteDefault());

    validate(groupId, name);

    long vocabularyId = counterLocalService.increment();

    AssetVocabulary vocabulary = assetVocabularyPersistence.create(vocabularyId);

    vocabulary.setUuid(serviceContext.getUuid());
    vocabulary.setGroupId(groupId);
    vocabulary.setCompanyId(user.getCompanyId());
    vocabulary.setUserId(user.getUserId());
    vocabulary.setUserName(user.getFullName());
    vocabulary.setName(name);

    if (Validator.isNotNull(title)) {
      vocabulary.setTitle(title);
    } else {
      vocabulary.setTitleMap(titleMap);
    }

    vocabulary.setDescriptionMap(descriptionMap);
    vocabulary.setSettings(settings);

    assetVocabularyPersistence.update(vocabulary);

    // Resources

    if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) {

      addVocabularyResources(
          vocabulary,
          serviceContext.isAddGroupPermissions(),
          serviceContext.isAddGuestPermissions());
    } else {
      addVocabularyResources(
          vocabulary, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions());
    }

    return vocabulary;
  }