001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.journalcontent.action;
016    
017    import com.liferay.portal.kernel.portlet.DefaultConfigurationAction;
018    import com.liferay.portal.kernel.servlet.SessionErrors;
019    import com.liferay.portal.kernel.util.ParamUtil;
020    import com.liferay.portal.model.Layout;
021    import com.liferay.portal.theme.ThemeDisplay;
022    import com.liferay.portal.util.WebKeys;
023    import com.liferay.portlet.journal.service.JournalContentSearchLocalServiceUtil;
024    
025    import javax.portlet.ActionRequest;
026    import javax.portlet.ActionResponse;
027    import javax.portlet.PortletConfig;
028    
029    /**
030     * @author Brian Wing Shun Chan
031     */
032    public class ConfigurationActionImpl extends DefaultConfigurationAction {
033    
034            @Override
035            public void processAction(
036                            PortletConfig portletConfig, ActionRequest actionRequest,
037                            ActionResponse actionResponse)
038                    throws Exception {
039    
040                    String[] extensions = actionRequest.getParameterValues("extensions");
041    
042                    setPreference(actionRequest, "extensions", extensions);
043    
044                    super.processAction(portletConfig, actionRequest, actionResponse);
045    
046                    if (SessionErrors.isEmpty(actionRequest)) {
047                            updateContentSearch(actionRequest);
048                    }
049            }
050    
051            protected void updateContentSearch(ActionRequest actionRequest)
052                    throws Exception {
053    
054                    ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
055                            WebKeys.THEME_DISPLAY);
056    
057                    String articleId = getParameter(
058                            actionRequest, "articleId").toUpperCase();
059    
060                    String portletResource = ParamUtil.getString(
061                            actionRequest, "portletResource");
062    
063                    Layout layout = themeDisplay.getLayout();
064    
065                    JournalContentSearchLocalServiceUtil.updateContentSearch(
066                            layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(),
067                            portletResource, articleId, true);
068            }
069    
070    }