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