1
22
23 package com.liferay.portlet.journalcontent.action;
24
25 import com.liferay.portal.kernel.portlet.ConfigurationAction;
26 import com.liferay.portal.kernel.util.Constants;
27 import com.liferay.portal.kernel.util.ParamUtil;
28 import com.liferay.portal.model.Layout;
29 import com.liferay.portal.theme.ThemeDisplay;
30 import com.liferay.portal.util.WebKeys;
31 import com.liferay.portlet.PortletPreferencesFactoryUtil;
32 import com.liferay.portlet.journal.service.JournalContentSearchLocalServiceUtil;
33
34 import javax.portlet.ActionRequest;
35 import javax.portlet.ActionResponse;
36 import javax.portlet.PortletConfig;
37 import javax.portlet.PortletPreferences;
38 import javax.portlet.RenderRequest;
39 import javax.portlet.RenderResponse;
40
41
47 public class ConfigurationActionImpl implements ConfigurationAction {
48
49 public void processAction(
50 PortletConfig config, ActionRequest req, ActionResponse res)
51 throws Exception {
52
53 String cmd = ParamUtil.getString(req, Constants.CMD);
54
55 if (!cmd.equals(Constants.UPDATE)) {
56 return;
57 }
58
59 long groupId = ParamUtil.getLong(req, "groupId");
60 String articleId = ParamUtil.getString(req, "articleId").toUpperCase();
61 String templateId = ParamUtil.getString(
62 req, "templateId").toUpperCase();
63 boolean disableCaching = ParamUtil.getBoolean(req, "disableCaching");
64 boolean showAvailableLocales = ParamUtil.getBoolean(
65 req, "showAvailableLocales");
66 boolean enableRatings = ParamUtil.getBoolean(req, "enableRatings");
67 boolean enableComments = ParamUtil.getBoolean(req, "enableComments");
68
69 String portletResource = ParamUtil.getString(req, "portletResource");
70
71 PortletPreferences prefs =
72 PortletPreferencesFactoryUtil.getPortletSetup(
73 req, portletResource, true, true);
74
75 prefs.setValue("group-id", String.valueOf(groupId));
76 prefs.setValue("article-id", articleId);
77 prefs.setValue("template-id", templateId);
78 prefs.setValue("disable-caching", String.valueOf(disableCaching));
79 prefs.setValue(
80 "show-available-locales", String.valueOf(showAvailableLocales));
81 prefs.setValue("enable-ratings", String.valueOf(enableRatings));
82 prefs.setValue("enable-comments", String.valueOf(enableComments));
83
84 prefs.store();
85
86 updateContentSearch(req, portletResource, articleId);
87
88 res.sendRedirect(ParamUtil.getString(req, "redirect"));
89 }
90
91 public String render(
92 PortletConfig config, RenderRequest req, RenderResponse res)
93 throws Exception {
94
95 return "/html/portlet/journal_content/configuration.jsp";
96 }
97
98 protected void updateContentSearch(
99 ActionRequest req, String portletResource, String articleId)
100 throws Exception {
101
102 ThemeDisplay themeDisplay =
103 (ThemeDisplay)req.getAttribute(WebKeys.THEME_DISPLAY);
104
105 Layout layout = themeDisplay.getLayout();
106
107 JournalContentSearchLocalServiceUtil.updateContentSearch(
108 layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(),
109 portletResource, articleId, true);
110 }
111
112 }