1
19
20 package com.liferay.portlet.journalcontent.action;
21
22 import com.liferay.portal.kernel.portlet.BaseConfigurationAction;
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 extends BaseConfigurationAction {
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 String[] extensions = actionRequest.getParameterValues("extensions");
65 boolean enablePrint = ParamUtil.getBoolean(
66 actionRequest, "enablePrint");
67 boolean enableRatings = ParamUtil.getBoolean(
68 actionRequest, "enableRatings");
69 boolean enableComments = ParamUtil.getBoolean(
70 actionRequest, "enableComments");
71 boolean enableCommentRatings = ParamUtil.getBoolean(
72 actionRequest, "enableCommentRatings");
73
74 String portletResource = ParamUtil.getString(
75 actionRequest, "portletResource");
76
77 PortletPreferences preferences =
78 PortletPreferencesFactoryUtil.getPortletSetup(
79 actionRequest, portletResource);
80
81 preferences.setValue("group-id", String.valueOf(groupId));
82 preferences.setValue("article-id", articleId);
83 preferences.setValue("template-id", templateId);
84 preferences.setValue(
85 "show-available-locales", String.valueOf(showAvailableLocales));
86 preferences.setValues("extensions", extensions);
87 preferences.setValue("enable-print", String.valueOf(enablePrint));
88 preferences.setValue("enable-ratings", String.valueOf(enableRatings));
89 preferences.setValue("enable-comments", String.valueOf(enableComments));
90 preferences.setValue(
91 "enable-comment-ratings", String.valueOf(enableCommentRatings));
92
93 preferences.store();
94
95 updateContentSearch(actionRequest, portletResource, articleId);
96
97 actionResponse.sendRedirect(
98 ParamUtil.getString(actionRequest, "redirect"));
99 }
100
101 public String render(
102 PortletConfig portletConfig, RenderRequest renderRequest,
103 RenderResponse renderResponse)
104 throws Exception {
105
106 return "/html/portlet/journal_content/configuration.jsp";
107 }
108
109 protected void updateContentSearch(
110 ActionRequest actionRequest, String portletResource,
111 String articleId)
112 throws Exception {
113
114 ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
115 WebKeys.THEME_DISPLAY);
116
117 Layout layout = themeDisplay.getLayout();
118
119 JournalContentSearchLocalServiceUtil.updateContentSearch(
120 layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(),
121 portletResource, articleId, true);
122 }
123
124 }