001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.journalcontent.action;
022:
023: import com.liferay.portal.kernel.portlet.ConfigurationAction;
024: import com.liferay.portal.kernel.util.Constants;
025: import com.liferay.portal.kernel.util.ParamUtil;
026: import com.liferay.portal.model.Layout;
027: import com.liferay.portal.theme.ThemeDisplay;
028: import com.liferay.portal.util.WebKeys;
029: import com.liferay.portlet.PortletPreferencesFactoryUtil;
030: import com.liferay.portlet.journal.service.JournalContentSearchLocalServiceUtil;
031:
032: import javax.portlet.ActionRequest;
033: import javax.portlet.ActionResponse;
034: import javax.portlet.PortletConfig;
035: import javax.portlet.PortletPreferences;
036: import javax.portlet.RenderRequest;
037: import javax.portlet.RenderResponse;
038:
039: /**
040: * <a href="ConfigurationActionImpl.java.html"><b><i>View Source</i></b></a>
041: *
042: * @author Brian Wing Shun Chan
043: *
044: */
045: public class ConfigurationActionImpl implements ConfigurationAction {
046:
047: public void processAction(PortletConfig config, ActionRequest req,
048: ActionResponse res) throws Exception {
049:
050: String cmd = ParamUtil.getString(req, Constants.CMD);
051:
052: if (!cmd.equals(Constants.UPDATE)) {
053: return;
054: }
055:
056: long groupId = ParamUtil.getLong(req, "groupId");
057: String articleId = ParamUtil.getString(req, "articleId")
058: .toUpperCase();
059: String templateId = ParamUtil.getString(req, "templateId")
060: .toUpperCase();
061: boolean showAvailableLocales = ParamUtil.getBoolean(req,
062: "showAvailableLocales");
063: boolean enableRatings = ParamUtil.getBoolean(req,
064: "enableRatings");
065: boolean enableComments = ParamUtil.getBoolean(req,
066: "enableComments");
067:
068: String portletResource = ParamUtil.getString(req,
069: "portletResource");
070:
071: PortletPreferences prefs = PortletPreferencesFactoryUtil
072: .getPortletSetup(req, portletResource, true, true);
073:
074: prefs.setValue("group-id", String.valueOf(groupId));
075: prefs.setValue("article-id", articleId);
076: prefs.setValue("template-id", templateId);
077: prefs.setValue("show-available-locales", String
078: .valueOf(showAvailableLocales));
079: prefs.setValue("enable-ratings", String.valueOf(enableRatings));
080: prefs.setValue("enable-comments", String
081: .valueOf(enableComments));
082:
083: prefs.store();
084:
085: updateContentSearch(req, portletResource, articleId);
086:
087: res.sendRedirect(ParamUtil.getString(req, "redirect"));
088: }
089:
090: public String render(PortletConfig config, RenderRequest req,
091: RenderResponse res) throws Exception {
092:
093: return "/html/portlet/journal_content/configuration.jsp";
094: }
095:
096: protected void updateContentSearch(ActionRequest req,
097: String portletResource, String articleId) throws Exception {
098:
099: ThemeDisplay themeDisplay = (ThemeDisplay) req
100: .getAttribute(WebKeys.THEME_DISPLAY);
101:
102: Layout layout = themeDisplay.getLayout();
103:
104: JournalContentSearchLocalServiceUtil.updateContentSearch(layout
105: .getGroupId(), layout.isPrivateLayout(), layout
106: .getLayoutId(), portletResource, articleId, true);
107: }
108:
109: }
|