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