001
014
015 package com.liferay.portlet.assetcategoriesnavigation.action;
016
017 import com.liferay.portal.kernel.portlet.BaseConfigurationAction;
018 import com.liferay.portal.kernel.servlet.SessionMessages;
019 import com.liferay.portal.kernel.util.ArrayUtil;
020 import com.liferay.portal.kernel.util.Constants;
021 import com.liferay.portal.kernel.util.ParamUtil;
022 import com.liferay.portal.kernel.util.StringUtil;
023 import com.liferay.portlet.PortletPreferencesFactoryUtil;
024
025 import javax.portlet.ActionRequest;
026 import javax.portlet.ActionResponse;
027 import javax.portlet.PortletConfig;
028 import javax.portlet.PortletPreferences;
029 import javax.portlet.RenderRequest;
030 import javax.portlet.RenderResponse;
031
032
035 public class ConfigurationActionImpl extends BaseConfigurationAction {
036
037 public void processAction(
038 PortletConfig portletConfig, ActionRequest actionRequest,
039 ActionResponse actionResponse)
040 throws Exception {
041
042 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
043
044 if (!cmd.equals(Constants.UPDATE)) {
045 return;
046 }
047
048 boolean allAssetVocabularies = ParamUtil.getBoolean(
049 actionRequest, "allAssetVocabularies");
050 long[] assetVocabularyIds = StringUtil.split(
051 ParamUtil.getString(actionRequest, "assetVocabularyIds"), 0L);
052
053 String portletResource = ParamUtil.getString(
054 actionRequest, "portletResource");
055
056 PortletPreferences preferences =
057 PortletPreferencesFactoryUtil.getPortletSetup(
058 actionRequest, portletResource);
059
060 preferences.setValue(
061 "all-asset-vocabularies", String.valueOf(allAssetVocabularies));
062 preferences.setValues(
063 "asset-vocabulary-ids",
064 ArrayUtil.toStringArray(assetVocabularyIds));
065
066 preferences.store();
067
068 SessionMessages.add(
069 actionRequest, portletConfig.getPortletName() + ".doConfigure");
070 }
071
072 public String render(
073 PortletConfig portletConfig, RenderRequest renderRequest,
074 RenderResponse renderResponse)
075 throws Exception {
076
077 return "/html/portlet/asset_categories_navigation/configuration.jsp";
078 }
079
080 }