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