001
014
015 package com.liferay.portlet.asset.model.impl;
016
017 import com.liferay.portal.kernel.exception.SystemException;
018 import com.liferay.portal.kernel.log.Log;
019 import com.liferay.portal.kernel.log.LogFactoryUtil;
020 import com.liferay.portal.kernel.util.ListUtil;
021 import com.liferay.portal.kernel.util.StringUtil;
022 import com.liferay.portlet.asset.AssetRendererFactoryRegistryUtil;
023 import com.liferay.portlet.asset.model.AssetCategory;
024 import com.liferay.portlet.asset.model.AssetRenderer;
025 import com.liferay.portlet.asset.model.AssetRendererFactory;
026 import com.liferay.portlet.asset.model.AssetTag;
027 import com.liferay.portlet.asset.service.AssetCategoryLocalServiceUtil;
028 import com.liferay.portlet.asset.service.AssetTagLocalServiceUtil;
029
030 import java.util.List;
031
032
036 public class AssetEntryImpl extends AssetEntryBaseImpl {
037
038 public AssetEntryImpl() {
039 }
040
041 public AssetRenderer getAssetRenderer() {
042 AssetRendererFactory assetRendererFactory =
043 AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(
044 getClassName());
045
046 try {
047 return assetRendererFactory.getAssetRenderer(getClassPK());
048 }
049 catch (Exception e) {
050 if (_log.isWarnEnabled()) {
051 _log.warn("Unable to get asset renderer", e);
052 }
053 }
054
055 return null;
056 }
057
058 public AssetRendererFactory getAssetRendererFactory() {
059 return
060 AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(
061 getClassName());
062 }
063
064 public List<AssetCategory> getCategories() throws SystemException {
065 return AssetCategoryLocalServiceUtil.getEntryCategories(getEntryId());
066 }
067
068 public long[] getCategoryIds() throws SystemException {
069 return StringUtil.split(
070 ListUtil.toString(
071 getCategories(), AssetCategory.CATEGORY_ID_ACCESSOR), 0L);
072 }
073
074 public String[] getTagNames() throws SystemException {
075 return StringUtil.split(
076 ListUtil.toString(getTags(), AssetTag.NAME_ACCESSOR));
077 }
078
079 public List<AssetTag> getTags() throws SystemException {
080 return AssetTagLocalServiceUtil.getEntryTags(getEntryId());
081 }
082
083 private static Log _log = LogFactoryUtil.getLog(AssetEntryImpl.class);
084
085 }