001
014
015 package com.liferay.taglib.ui;
016
017 import com.liferay.portal.kernel.exception.SystemException;
018 import com.liferay.portal.kernel.util.StringPool;
019 import com.liferay.portlet.asset.model.AssetEntry;
020 import com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil;
021 import com.liferay.taglib.util.IncludeTag;
022
023 import javax.servlet.http.HttpServletRequest;
024
025
029 public class AssetLinksTag extends IncludeTag {
030
031 public long getAssetEntryId() {
032 return _assetEntryId;
033 }
034
035 public String getClassName() {
036 return _className;
037 }
038
039 public long getClassPK() {
040 return _classPK;
041 }
042
043 public void setAssetEntryId(long assetEntryId) {
044 _assetEntryId = assetEntryId;
045 }
046
047 public void setClassName(String className) {
048 _className = className;
049 }
050
051 public void setClassPK(long classPK) {
052 _classPK = classPK;
053 }
054
055 @Override
056 protected void cleanUp() {
057 _assetEntryId = 0;
058 _className = StringPool.BLANK;
059 _classPK = 0;
060 }
061
062 @Override
063 protected String getPage() {
064 return _PAGE;
065 }
066
067 @Override
068 protected void setAttributes(HttpServletRequest request) {
069 if ((_assetEntryId <= 0) && (_classPK > 0)) {
070 try {
071 AssetEntry assetEntry = AssetEntryLocalServiceUtil.fetchEntry(
072 _className, _classPK);
073
074 if (assetEntry != null) {
075 _assetEntryId = assetEntry.getEntryId();
076 }
077 }
078 catch (SystemException se) {
079 }
080 }
081
082 request.setAttribute(
083 "liferay-ui:asset-links:assetEntryId",
084 String.valueOf(_assetEntryId));
085 }
086
087 private static final String _PAGE = "/html/taglib/ui/asset_links/page.jsp";
088
089 private long _assetEntryId;
090 private String _className = StringPool.BLANK;
091 private long _classPK;
092
093 }