001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    }