1
14
15 package com.liferay.portlet.assetcategoriesnavigation.action;
16
17 import com.liferay.portal.kernel.portlet.BaseConfigurationAction;
18 import com.liferay.portal.kernel.servlet.SessionMessages;
19 import com.liferay.portal.kernel.util.ArrayUtil;
20 import com.liferay.portal.kernel.util.Constants;
21 import com.liferay.portal.kernel.util.ParamUtil;
22 import com.liferay.portal.kernel.util.StringUtil;
23 import com.liferay.portlet.PortletPreferencesFactoryUtil;
24
25 import javax.portlet.ActionRequest;
26 import javax.portlet.ActionResponse;
27 import javax.portlet.PortletConfig;
28 import javax.portlet.PortletPreferences;
29 import javax.portlet.RenderRequest;
30 import javax.portlet.RenderResponse;
31
32
37 public class ConfigurationActionImpl extends BaseConfigurationAction {
38
39 public void processAction(
40 PortletConfig portletConfig, ActionRequest actionRequest,
41 ActionResponse actionResponse)
42 throws Exception {
43
44 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
45
46 if (!cmd.equals(Constants.UPDATE)) {
47 return;
48 }
49
50 boolean allAssetVocabularies = ParamUtil.getBoolean(
51 actionRequest, "allAssetVocabularies");
52 long[] assetVocabularyIds = StringUtil.split(
53 ParamUtil.getString(actionRequest, "assetVocabularyIds"), 0L);
54
55 String portletResource = ParamUtil.getString(
56 actionRequest, "portletResource");
57
58 PortletPreferences preferences =
59 PortletPreferencesFactoryUtil.getPortletSetup(
60 actionRequest, portletResource);
61
62 preferences.setValue(
63 "all-asset-vocabularies", String.valueOf(allAssetVocabularies));
64 preferences.setValues(
65 "asset-vocabulary-ids",
66 ArrayUtil.toStringArray(assetVocabularyIds));
67
68 preferences.store();
69
70 SessionMessages.add(
71 actionRequest, portletConfig.getPortletName() + ".doConfigure");
72 }
73
74 public String render(
75 PortletConfig portletConfig, RenderRequest renderRequest,
76 RenderResponse renderResponse)
77 throws Exception {
78
79 return "/html/portlet/asset_categories_navigation/configuration.jsp";
80 }
81
82 }