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