@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;
  }
  /**
   * Converts the soap model instance into a normal model instance.
   *
   * @param soapModel the soap model instance to convert
   * @return the normal model instance
   */
  public static AssetVocabulary toModel(AssetVocabularySoap soapModel) {
    if (soapModel == null) {
      return null;
    }

    AssetVocabulary model = new AssetVocabularyImpl();

    model.setUuid(soapModel.getUuid());
    model.setVocabularyId(soapModel.getVocabularyId());
    model.setGroupId(soapModel.getGroupId());
    model.setCompanyId(soapModel.getCompanyId());
    model.setUserId(soapModel.getUserId());
    model.setUserName(soapModel.getUserName());
    model.setCreateDate(soapModel.getCreateDate());
    model.setModifiedDate(soapModel.getModifiedDate());
    model.setName(soapModel.getName());
    model.setTitle(soapModel.getTitle());
    model.setDescription(soapModel.getDescription());
    model.setSettings(soapModel.getSettings());

    return model;
  }