Search in sources :

Example 1 with Validator

use of com.liferay.portal.kernel.util.Validator in project liferay-db-setup-core by ableneo.

the class TaggingUtil method associateTagsAndCategories.

public static void associateTagsAndCategories(long groupId, Article article, JournalArticle journalArticle) throws PortalException {
    List<Tag> tags = article.getTag();
    String[] tagNames = null;
    if (tags != null) {
        tagNames = tags.stream().map(Tag::getName).toArray(String[]::new);
    }
    long[] categoryIds = article.getCategory().stream().map(category -> ResolverUtil.lookupAll(groupId, journalArticle.getCompanyId(), category.getUuid(), article.getPath())).filter(Validator::isNumber).mapToLong(Long::parseLong).toArray();
    AssetEntry entry = AssetEntryLocalServiceUtil.getEntry(JournalArticle.class.getName(), journalArticle.getResourcePrimKey());
    AssetEntryLocalServiceUtil.updateEntry(SetupConfigurationThreadLocal.getRunAsUserId(), groupId, JournalArticle.class.getName(), entry.getClassPK(), categoryIds, tagNames);
}
Also used : NoSuchTagException(com.liferay.asset.kernel.exception.NoSuchTagException) LogFactoryUtil(com.liferay.portal.kernel.log.LogFactoryUtil) AssetTagLocalServiceUtil(com.liferay.asset.kernel.service.AssetTagLocalServiceUtil) AssetTag(com.liferay.asset.kernel.model.AssetTag) Validator(com.liferay.portal.kernel.util.Validator) ServiceContext(com.liferay.portal.kernel.service.ServiceContext) AssetEntryLocalServiceUtil(com.liferay.asset.kernel.service.AssetEntryLocalServiceUtil) Log(com.liferay.portal.kernel.log.Log) PortalException(com.liferay.portal.kernel.exception.PortalException) Tag(com.ableneo.liferay.portal.setup.domain.Tag) SystemException(com.liferay.portal.kernel.exception.SystemException) List(java.util.List) JournalArticle(com.liferay.journal.model.JournalArticle) SetupConfigurationThreadLocal(com.ableneo.liferay.portal.setup.SetupConfigurationThreadLocal) AssetEntry(com.liferay.asset.kernel.model.AssetEntry) Article(com.ableneo.liferay.portal.setup.domain.Article) AssetEntry(com.liferay.asset.kernel.model.AssetEntry) AssetTag(com.liferay.asset.kernel.model.AssetTag) Tag(com.ableneo.liferay.portal.setup.domain.Tag) Validator(com.liferay.portal.kernel.util.Validator) JournalArticle(com.liferay.journal.model.JournalArticle)

Aggregations

SetupConfigurationThreadLocal (com.ableneo.liferay.portal.setup.SetupConfigurationThreadLocal)1 Article (com.ableneo.liferay.portal.setup.domain.Article)1 Tag (com.ableneo.liferay.portal.setup.domain.Tag)1 NoSuchTagException (com.liferay.asset.kernel.exception.NoSuchTagException)1 AssetEntry (com.liferay.asset.kernel.model.AssetEntry)1 AssetTag (com.liferay.asset.kernel.model.AssetTag)1 AssetEntryLocalServiceUtil (com.liferay.asset.kernel.service.AssetEntryLocalServiceUtil)1 AssetTagLocalServiceUtil (com.liferay.asset.kernel.service.AssetTagLocalServiceUtil)1 JournalArticle (com.liferay.journal.model.JournalArticle)1 PortalException (com.liferay.portal.kernel.exception.PortalException)1 SystemException (com.liferay.portal.kernel.exception.SystemException)1 Log (com.liferay.portal.kernel.log.Log)1 LogFactoryUtil (com.liferay.portal.kernel.log.LogFactoryUtil)1 ServiceContext (com.liferay.portal.kernel.service.ServiceContext)1 Validator (com.liferay.portal.kernel.util.Validator)1 List (java.util.List)1