protected AssetCategory getAssetCategory(long userId, long groupId, String name)
      throws PortalException, SystemException {

    AssetVocabulary assetVocabulary =
        assetVocabularyPersistence.fetchByG_N(groupId, _ASSET_VOCABULARY_NAME);

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setScopeGroupId(groupId);
    serviceContext.setUserId(userId);

    if (assetVocabulary == null) {
      assetVocabulary =
          assetVocabularyLocalService.addVocabulary(userId, _ASSET_VOCABULARY_NAME, serviceContext);
    }

    AssetCategory assetCategory =
        assetCategoryPersistence.fetchByP_N_V(
            AssetCategoryConstants.DEFAULT_PARENT_CATEGORY_ID,
            name,
            assetVocabulary.getVocabularyId());

    if (assetCategory != null) {
      return assetCategory;
    }

    return assetCategoryLocalService.addCategory(
        userId, name, assetVocabulary.getVocabularyId(), serviceContext);
  }
  public List<KeyValuePair> getAvailableVocabularyNames() throws PortalException {

    List<KeyValuePair> availableVocabularNames = new ArrayList<>();

    long[] assetVocabularyIds = getAssetVocabularyIds();

    Arrays.sort(assetVocabularyIds);

    Set<Long> availableAssetVocabularyIdsSet = SetUtil.fromArray(getAvailableAssetVocabularyIds());

    for (long assetVocabularyId : availableAssetVocabularyIdsSet) {
      if (Arrays.binarySearch(assetVocabularyIds, assetVocabularyId) < 0) {

        AssetVocabulary assetVocabulary =
            AssetVocabularyLocalServiceUtil.fetchAssetVocabulary(assetVocabularyId);

        assetVocabulary = assetVocabulary.toEscapedModel();

        availableVocabularNames.add(
            new KeyValuePair(String.valueOf(assetVocabularyId), getTitle(assetVocabulary)));
      }
    }

    return ListUtil.sort(availableVocabularNames, new KeyValuePairComparator(false, true));
  }
  protected String getTitle(AssetVocabulary assetVocabulary) {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    String title = assetVocabulary.getTitle(themeDisplay.getLanguageId());

    if (assetVocabulary.getGroupId() == themeDisplay.getCompanyGroupId()) {
      title += " (" + LanguageUtil.get(_request, "global") + ")";
    }

    return title;
  }
  @Override
  public void addVocabularyResources(
      AssetVocabulary vocabulary, String[] groupPermissions, String[] guestPermissions)
      throws PortalException {

    resourceLocalService.addModelResources(
        vocabulary.getCompanyId(),
        vocabulary.getGroupId(),
        vocabulary.getUserId(),
        AssetVocabulary.class.getName(),
        vocabulary.getVocabularyId(),
        groupPermissions,
        guestPermissions);
  }
  @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;
  }
  @Override
  public void addVocabularyResources(
      AssetVocabulary vocabulary, boolean addGroupPermissions, boolean addGuestPermissions)
      throws PortalException {

    resourceLocalService.addResources(
        vocabulary.getCompanyId(),
        vocabulary.getGroupId(),
        vocabulary.getUserId(),
        AssetVocabulary.class.getName(),
        vocabulary.getVocabularyId(),
        false,
        addGroupPermissions,
        addGuestPermissions);
  }
  public List<KeyValuePair> getCurrentVocabularyNames() throws PortalException {

    List<KeyValuePair> currentVocabularNames = new ArrayList<>();

    for (long assetVocabularyId : getAssetVocabularyIds()) {
      AssetVocabulary assetVocabulary =
          AssetVocabularyLocalServiceUtil.fetchAssetVocabulary(assetVocabularyId);

      assetVocabulary = assetVocabulary.toEscapedModel();

      currentVocabularNames.add(
          new KeyValuePair(String.valueOf(assetVocabularyId), getTitle(assetVocabulary)));
    }

    return currentVocabularNames;
  }
  /**
   * Adds the asset vocabulary to the database. Also notifies the appropriate model listeners.
   *
   * @param assetVocabulary the asset vocabulary
   * @return the asset vocabulary that was added
   */
  @Indexable(type = IndexableType.REINDEX)
  @Override
  public AssetVocabulary addAssetVocabulary(AssetVocabulary assetVocabulary) {
    assetVocabulary.setNew(true);

    return assetVocabularyPersistence.update(assetVocabulary);
  }
  public long[] getAvailableAssetVocabularyIds() throws PortalException {
    if (_availableAssetVocabularyIds != null) {
      return _availableAssetVocabularyIds;
    }

    List<AssetVocabulary> assetVocabularies = getAssetVocabularies();

    _availableAssetVocabularyIds = new long[assetVocabularies.size()];

    for (int i = 0; i < assetVocabularies.size(); i++) {
      AssetVocabulary assetVocabulary = assetVocabularies.get(i);

      _availableAssetVocabularyIds[i] = assetVocabulary.getVocabularyId();
    }

    return _availableAssetVocabularyIds;
  }
예제 #10
0
  protected Map<Locale, String> getAssetVocabularyTitleMap(AssetVocabulary assetVocabulary) {

    Map<Locale, String> titleMap = assetVocabulary.getTitleMap();

    if (titleMap == null) {
      titleMap = new HashMap<Locale, String>();
    }

    Locale locale = LocaleUtil.getDefault();

    String title = titleMap.get(locale);

    if (Validator.isNull(title)) {
      titleMap.put(locale, assetVocabulary.getName());
    }

    return titleMap;
  }
  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }

    if (!(obj instanceof AssetVocabulary)) {
      return false;
    }

    AssetVocabulary assetVocabulary = (AssetVocabulary) obj;

    long primaryKey = assetVocabulary.getPrimaryKey();

    if (getPrimaryKey() == primaryKey) {
      return true;
    } else {
      return false;
    }
  }
  @Indexable(type = IndexableType.DELETE)
  @Override
  @SystemEvent(action = SystemEventConstants.ACTION_SKIP, type = SystemEventConstants.TYPE_DELETE)
  public void deleteVocabulary(AssetVocabulary vocabulary) throws PortalException {

    // Vocabulary

    assetVocabularyPersistence.remove(vocabulary);

    // Resources

    resourceLocalService.deleteResource(
        vocabulary.getCompanyId(),
        AssetVocabulary.class.getName(),
        ResourceConstants.SCOPE_INDIVIDUAL,
        vocabulary.getVocabularyId());

    // Categories

    assetCategoryLocalService.deleteVocabularyCategories(vocabulary.getVocabularyId());
  }
  @Override
  public int compareTo(AssetVocabulary assetVocabulary) {
    int value = 0;

    value = getName().compareTo(assetVocabulary.getName());

    if (value != 0) {
      return value;
    }

    return 0;
  }
예제 #14
0
  protected void exportAssetVocabulary(
      PortletDataContext portletDataContext,
      Element assetVocabulariesElement,
      AssetVocabulary assetVocabulary)
      throws Exception {

    String path = getAssetVocabulariesPath(portletDataContext, assetVocabulary.getVocabularyId());

    if (!portletDataContext.isPathNotProcessed(path)) {
      return;
    }

    Element assetVocabularyElement = assetVocabulariesElement.addElement("vocabulary");

    assetVocabularyElement.addAttribute("path", path);

    assetVocabulary.setUserUuid(assetVocabulary.getUserUuid());

    portletDataContext.addZipEntry(path, assetVocabulary);

    portletDataContext.addPermissions(AssetVocabulary.class, assetVocabulary.getVocabularyId());
  }
  protected JSONArray toJSONArray(List<AssetCategory> categories)
      throws PortalException, SystemException {

    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

    for (AssetCategory category : categories) {
      String categoryJSON = JSONFactoryUtil.looseSerialize(category);

      JSONObject categoryJSONObject = JSONFactoryUtil.createJSONObject(categoryJSON);

      List<String> names = new ArrayList<String>();

      AssetCategory curCategory = category;

      while (curCategory.getParentCategoryId() > 0) {
        AssetCategory parentCategory = getCategory(curCategory.getParentCategoryId());

        names.add(parentCategory.getName());
        names.add(StringPool.SPACE + StringPool.GREATER_THAN + StringPool.SPACE);

        curCategory = parentCategory;
      }

      Collections.reverse(names);

      AssetVocabulary vocabulary = assetVocabularyService.getVocabulary(category.getVocabularyId());

      StringBundler sb = new StringBundler(1 + names.size());

      sb.append(vocabulary.getName());
      sb.append(names.toArray(new String[names.size()]));

      categoryJSONObject.put("path", sb.toString());

      jsonArray.put(categoryJSONObject);
    }

    return jsonArray;
  }
  public JSONArray getJSONSearch(
      long groupId, String name, long[] vocabularyIds, int start, int end)
      throws PortalException, SystemException {

    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

    for (AssetVocabulary vocabulary : assetVocabularyService.getVocabularies(vocabularyIds)) {

      List<AssetCategory> vocabularyCategory =
          assetCategoryFinder.findByG_N_V(
              groupId, name, vocabulary.getVocabularyId(), start, end, null);

      JSONArray vocabularyCategoryJSONArray = toJSONArray(vocabularyCategory);

      for (int i = 0; i < vocabularyCategoryJSONArray.length(); ++i) {
        JSONObject vocabularyCategoryJSONObject = vocabularyCategoryJSONArray.getJSONObject(i);

        jsonArray.put(vocabularyCategoryJSONObject);
      }
    }

    return jsonArray;
  }
예제 #17
0
  /** TODO: Remove. This should extend from EditFileEntryAction once it is modularized. */
  protected String getAddMultipleFileEntriesErrorMessage(
      PortletConfig portletConfig,
      ActionRequest actionRequest,
      ActionResponse actionResponse,
      Exception e)
      throws Exception {

    String errorMessage = null;

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if (e instanceof AntivirusScannerException) {
      AntivirusScannerException ase = (AntivirusScannerException) e;

      errorMessage = themeDisplay.translate(ase.getMessageKey());
    } else if (e instanceof AssetCategoryException) {
      AssetCategoryException ace = (AssetCategoryException) e;

      AssetVocabulary assetVocabulary = ace.getVocabulary();

      String vocabularyTitle = StringPool.BLANK;

      if (assetVocabulary != null) {
        vocabularyTitle = assetVocabulary.getTitle(themeDisplay.getLocale());
      }

      if (ace.getType() == AssetCategoryException.AT_LEAST_ONE_CATEGORY) {
        errorMessage =
            themeDisplay.translate("please-select-at-least-one-category-for-x", vocabularyTitle);
      } else if (ace.getType() == AssetCategoryException.TOO_MANY_CATEGORIES) {

        errorMessage =
            themeDisplay.translate(
                "you-cannot-select-more-than-one-category-for-x", vocabularyTitle);
      }
    } else if (e instanceof DuplicateFileEntryException) {
      errorMessage =
          themeDisplay.translate(
              "the-folder-you-selected-already-has-an-entry-with-this-name."
                  + "-please-select-a-different-folder");
    } else if (e instanceof FileExtensionException) {
      errorMessage =
          themeDisplay.translate(
              "please-enter-a-file-with-a-valid-extension-x",
              StringUtil.merge(
                  getAllowedFileExtensions(portletConfig, actionRequest, actionResponse)));
    } else if (e instanceof FileNameException) {
      errorMessage = themeDisplay.translate("please-enter-a-file-with-a-valid-file-name");
    } else if (e instanceof FileSizeException) {
      long fileMaxSize = PrefsPropsUtil.getLong(PropsKeys.DL_FILE_MAX_SIZE);

      if (fileMaxSize == 0) {
        fileMaxSize = PrefsPropsUtil.getLong(PropsKeys.UPLOAD_SERVLET_REQUEST_IMPL_MAX_SIZE);
      }

      errorMessage =
          themeDisplay.translate(
              "please-enter-a-file-with-a-valid-file-size-no-larger-than-x",
              TextFormatter.formatStorageSize(fileMaxSize, themeDisplay.getLocale()));
    } else if (e instanceof InvalidFileEntryTypeException) {
      errorMessage =
          themeDisplay.translate("the-document-type-you-selected-is-not-valid-for-this-folder");
    } else {
      errorMessage =
          themeDisplay.translate("an-unexpected-error-occurred-while-saving-your-document");
    }

    return errorMessage;
  }
  @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;
  }
  public void loadCategoriesFromCsv(ActionRequest actionRequest, ActionResponse actionResponse)
      throws IOException, PortletException, PortalException, SystemException {

    LOGGER.info("Begin  AssetCategoriesImporter");
    UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);
    ThemeDisplay themeDisplay =
        (ThemeDisplay) uploadPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);
    Map<String, FileItem[]> multipartParameterMap = uploadPortletRequest.getMultipartParameterMap();

    File file = null;
    BufferedReader bufferedReader = null;
    AssetVocabulary assetVocabulary = null;
    long userId = themeDisplay.getUserId();
    long groupId = themeDisplay.getScopeGroupId();

    ServiceContext serviceContext =
        ServiceContextFactory.getInstance(AssetCategory.class.getName(), uploadPortletRequest);

    // create vocabulary
    try {

      assetVocabulary =
          AssetVocabularyLocalServiceUtil.addVocabulary(
              userId,
              "Announcements",
              ServiceContextFactory.getInstance(
                  AssetVocabulary.class.getName(), uploadPortletRequest));
    } catch (DuplicateVocabularyException dve) {
      try {
        assetVocabulary =
            AssetVocabularyLocalServiceUtil.getGroupVocabulary(groupId, "Announcements");
      } catch (PortalException e) {
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug(e);
        }
        LOGGER.error(e.getMessage());
      } catch (SystemException e) {
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug(e);
        }
        LOGGER.error(e.getMessage());
      }
    }

    if (multipartParameterMap.keySet().contains("fileCategory")
        && Validator.isNotNull(assetVocabulary)) {
      try {
        file = uploadPortletRequest.getFile("fileCategory");
        bufferedReader = new BufferedReader(new FileReader(file.getAbsolutePath()));
        String line = StringPool.BLANK;
        long vocabularyId = assetVocabulary.getVocabularyId();

        String parentCategoryName = StringPool.BLANK;
        AssetCategory parentCategory = null;

        while ((line = bufferedReader.readLine()) != null) {

          // use comma as separator
          String[] categories = line.split(StringPool.SEMICOLON);

          if (categories.length == 4) {
            String parentCategoryCode = categories[0];

            if (Validator.isNull(parentCategory) || !parentCategoryName.equals(categories[1])) {
              parentCategoryName = categories[1];
              try {
                parentCategory =
                    AssetCategoryLocalServiceUtil.addCategory(
                        userId, parentCategoryName, vocabularyId, serviceContext);
                AssetCategoryPropertyLocalServiceUtil.addCategoryProperty(
                    userId, parentCategory.getCategoryId(), "Code", parentCategoryCode);
              } catch (Exception e) {
                if (LOGGER.isDebugEnabled()) {
                  LOGGER.debug(e);
                }
                LOGGER.error(e.getMessage());
              }
            }

            Map<Locale, String> titles = new HashMap<Locale, String>();
            Map<Locale, String> descriptionMap = new HashMap<Locale, String>();

            titles.put(LocaleUtil.fromLanguageId("fr_FR"), categories[3]);
            titles.put(LocaleUtil.fromLanguageId("en_US"), categories[3]);

            try {
              AssetCategory child =
                  AssetCategoryLocalServiceUtil.addCategory(
                      userId,
                      parentCategory.getCategoryId(),
                      titles,
                      descriptionMap,
                      vocabularyId,
                      null,
                      serviceContext);
              AssetCategoryPropertyLocalServiceUtil.addCategoryProperty(
                  userId, child.getCategoryId(), "Code", categories[2]);
            } catch (Exception e) {
              if (LOGGER.isDebugEnabled()) {
                LOGGER.debug(e);
              }
              LOGGER.error(e.getMessage());
            }
          }
        }
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      } finally {
        if (bufferedReader != null) {
          try {
            bufferedReader.close();
          } catch (IOException e) {
            if (LOGGER.isDebugEnabled()) {
              LOGGER.debug(e);
            }
            LOGGER.error(e.getMessage());
          }
        }
      }
    }
    LOGGER.info("End  AssetCategoriesImporter");
  }
  @Override
  public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {

    List<AssetVocabulary> vocabularies = new ArrayList<AssetVocabulary>();
    Map<AssetVocabulary, List<AssetCategory>> vocabulariesMap =
        new HashMap<AssetVocabulary, List<AssetCategory>>();
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long[] categoryIds = ParamUtil.getLongValues(renderRequest, "categoryIds");
    try {

      Group siteGroup = themeDisplay.getSiteGroup();
      long scopeGroupId = themeDisplay.getScopeGroupId();
      vocabularies.addAll(
          AssetVocabularyServiceUtil.getGroupVocabularies(siteGroup.getGroupId(), false));

      if (scopeGroupId != themeDisplay.getCompanyGroupId()) {
        vocabularies.addAll(
            AssetVocabularyServiceUtil.getGroupVocabularies(
                themeDisplay.getCompanyGroupId(), false));
      }

      long classNameId = PortalUtil.getClassNameId(Announcement.class);

      // Select announcement vocabularies for announcement only.
      for (AssetVocabulary vocabulary : vocabularies) {
        vocabulary = vocabulary.toEscapedModel();

        int vocabularyCategoriesCount =
            AssetCategoryServiceUtil.getVocabularyCategoriesCount(
                vocabulary.getGroupId(), vocabulary.getVocabularyId());

        if (vocabularyCategoriesCount == 0) {
          continue;
        }

        UnicodeProperties settingsProperties = vocabulary.getSettingsProperties();

        long[] selectedClassNameIds =
            StringUtil.split(settingsProperties.getProperty("selectedClassNameIds"), 0L);

        if ((selectedClassNameIds.length > 0)
            && (selectedClassNameIds[0] != AssetCategoryConstants.ALL_CLASS_NAME_IDS)
            && !ArrayUtil.contains(selectedClassNameIds, classNameId)) {
          continue;
        }

        List<AssetCategory> assetCategories =
            AssetCategoryServiceUtil.getVocabularyRootCategories(
                themeDisplay.getScopeGroupId(),
                vocabulary.getVocabularyId(),
                QueryUtil.ALL_POS,
                QueryUtil.ALL_POS,
                null);
        vocabulariesMap.put(vocabulary, assetCategories);
      }
    } catch (SystemException e) {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(e);
      }
      LOGGER.error("SystemException: unable to get types or currencies or vocabularies");
    } catch (PortalException e) {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(e);
      }
      LOGGER.error("SystemException: unable to get types or currencies or vocabularies");
    }

    renderRequest.setAttribute("vocabulariesMap", vocabulariesMap);
    renderRequest.setAttribute("categoryIds", StringUtil.merge(categoryIds));
    renderRequest.setAttribute("htmlUtil", HtmlUtil.getHtml());

    super.doView(renderRequest, renderResponse);
  }
예제 #22
0
  protected void importAssetVocabulary(
      PortletDataContext portletDataContext,
      Map<Long, Long> assetVocabularyPKs,
      Element assetVocabularyElement,
      AssetVocabulary assetVocabulary)
      throws Exception {

    long userId = portletDataContext.getUserId(assetVocabulary.getUserUuid());
    long groupId = portletDataContext.getScopeGroupId();

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setAddGroupPermissions(true);
    serviceContext.setAddGuestPermissions(true);
    serviceContext.setCreateDate(assetVocabulary.getCreateDate());
    serviceContext.setModifiedDate(assetVocabulary.getModifiedDate());
    serviceContext.setScopeGroupId(portletDataContext.getScopeGroupId());

    AssetVocabulary importedAssetVocabulary = null;

    AssetVocabulary existingAssetVocabulary =
        AssetVocabularyUtil.fetchByG_N(groupId, assetVocabulary.getName());

    if (existingAssetVocabulary == null) {
      Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(portletDataContext.getCompanyId());

      existingAssetVocabulary =
          AssetVocabularyUtil.fetchByG_N(companyGroup.getGroupId(), assetVocabulary.getName());
    }

    if (existingAssetVocabulary == null) {
      serviceContext.setUuid(assetVocabulary.getUuid());

      importedAssetVocabulary =
          AssetVocabularyLocalServiceUtil.addVocabulary(
              userId,
              assetVocabulary.getTitle(),
              getAssetVocabularyTitleMap(assetVocabulary),
              assetVocabulary.getDescriptionMap(),
              assetVocabulary.getSettings(),
              serviceContext);
    } else {
      importedAssetVocabulary =
          AssetVocabularyLocalServiceUtil.updateVocabulary(
              existingAssetVocabulary.getVocabularyId(),
              assetVocabulary.getTitle(),
              getAssetVocabularyTitleMap(assetVocabulary),
              assetVocabulary.getDescriptionMap(),
              assetVocabulary.getSettings(),
              serviceContext);
    }

    assetVocabularyPKs.put(
        assetVocabulary.getVocabularyId(), importedAssetVocabulary.getVocabularyId());

    portletDataContext.importPermissions(
        AssetVocabulary.class,
        assetVocabulary.getVocabularyId(),
        importedAssetVocabulary.getVocabularyId());
  }