コード例 #1
0
  @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;
  }
  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;
  }
コード例 #3
0
  @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);
  }
コード例 #4
0
  @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);
  }
コード例 #5
0
  @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);
  }