001
014
015 package com.liferay.taglib.ui;
016
017 import com.liferay.portal.kernel.util.ServerDetector;
018 import com.liferay.portlet.asset.model.AssetTag;
019 import com.liferay.portlet.asset.service.AssetTagServiceUtil;
020 import com.liferay.taglib.TagSupport;
021
022 import java.util.ArrayList;
023 import java.util.List;
024
025 import javax.servlet.jsp.JspException;
026
027
030 public class AssetTagsAvailableTag<R> extends TagSupport {
031
032 @Override
033 public int doStartTag() throws JspException {
034 try {
035 _assetTags = AssetTagServiceUtil.getTags(_className, _classPK);
036
037 if (!_assetTags.isEmpty()) {
038 return EVAL_BODY_INCLUDE;
039 }
040
041 return SKIP_BODY;
042 }
043 catch (Exception e) {
044 throw new JspException(e);
045 }
046 finally {
047 if (!ServerDetector.isResin()) {
048 _className = null;
049 _classPK = 0;
050 }
051 }
052 }
053
054 public List<AssetTag> getAssetTags() {
055 return _assetTags;
056 }
057
058 public void setClassName(String className) {
059 _className = className;
060 }
061
062 public void setClassPK(long classPK) {
063 _classPK = classPK;
064 }
065
066 private List<AssetTag> _assetTags = new ArrayList<>();
067 private String _className;
068 private long _classPK;
069
070 }