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);
}
Aggregations