use of com.liferay.asset.kernel.model.AssetTag in project liferay-db-setup-core by ableneo.
the class TaggingUtil method getCategories.
public static long[] getCategories(final List<String> categories, final long groupId, final long runAsUser) {
// The categories and tags to assign
final long[] assetCategoryIds = new long[categories.size()];
for (int i = 0; i < categories.size(); ++i) {
final String name = categories.get(i);
AssetTag assetTag = null;
try {
assetTag = AssetTagLocalServiceUtil.getTag(groupId, name);
} catch (final NoSuchTagException e) {
try {
assetTag = AssetTagLocalServiceUtil.addTag(runAsUser, groupId, name, new ServiceContext());
} catch (PortalException | SystemException e1) {
LOG.error(String.format("Category %1$s not found! ", name), e1);
}
} catch (PortalException | SystemException e) {
LOG.error(String.format("Category %1$s not found! ", name), e);
}
if (assetTag != null) {
assetCategoryIds[i] = assetTag.getTagId();
}
}
return assetCategoryIds;
}
Aggregations