001
014
015 package com.liferay.portlet.assetcategoryadmin.action;
016
017 import com.liferay.portal.kernel.util.ParamUtil;
018 import com.liferay.portal.theme.ThemeDisplay;
019 import com.liferay.portal.util.PortalUtil;
020 import com.liferay.portal.util.WebKeys;
021 import com.liferay.portlet.asset.model.AssetCategory;
022 import com.liferay.portlet.asset.model.AssetVocabulary;
023 import com.liferay.portlet.asset.service.AssetCategoryServiceUtil;
024 import com.liferay.portlet.asset.service.AssetVocabularyServiceUtil;
025
026 import java.util.List;
027
028 import javax.portlet.PortletRequest;
029
030 import javax.servlet.http.HttpServletRequest;
031
032
036 public class ActionUtil {
037
038 public static void getCategory(HttpServletRequest request)
039 throws Exception {
040
041 long categoryId = ParamUtil.getLong(request, "categoryId");
042
043 AssetCategory category = null;
044
045 if (categoryId > 0) {
046 category = AssetCategoryServiceUtil.getCategory(categoryId);
047 }
048
049 request.setAttribute(WebKeys.ASSET_CATEGORY, category);
050 }
051
052 public static void getCategory(PortletRequest portletRequest)
053 throws Exception {
054
055 HttpServletRequest request = PortalUtil.getHttpServletRequest(
056 portletRequest);
057
058 getCategory(request);
059 }
060
061 public static void getVocabularies(HttpServletRequest request)
062 throws Exception {
063
064 ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
065 WebKeys.THEME_DISPLAY);
066
067 List<AssetVocabulary> vocabularies =
068 AssetVocabularyServiceUtil.getGroupVocabularies(
069 themeDisplay.getScopeGroupId());
070
071 request.setAttribute(WebKeys.ASSET_VOCABULARIES, vocabularies);
072 }
073
074 public static void getVocabularies(PortletRequest portletRequest)
075 throws Exception {
076
077 HttpServletRequest request = PortalUtil.getHttpServletRequest(
078 portletRequest);
079
080 getVocabularies(request);
081 }
082
083 public static void getVocabulary(HttpServletRequest request)
084 throws Exception {
085
086 long vocabularyId = ParamUtil.getLong(request, "vocabularyId");
087
088 AssetVocabulary vocabulary = null;
089
090 if (vocabularyId > 0) {
091 vocabulary = AssetVocabularyServiceUtil.getVocabulary(vocabularyId);
092 }
093
094 request.setAttribute(WebKeys.ASSET_VOCABULARY, vocabulary);
095 }
096
097 public static void getVocabulary(PortletRequest portletRequest)
098 throws Exception {
099
100 HttpServletRequest request = PortalUtil.getHttpServletRequest(
101 portletRequest);
102
103 getVocabulary(request);
104 }
105
106 }