com.liferay.portlet.journalcontent.action.ConfigurationActionImpl.java Source code

Java tutorial

Introduction

Here is the source code for com.liferay.portlet.journalcontent.action.ConfigurationActionImpl.java

Source

/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.liferay.portlet.journalcontent.action;

import com.liferay.portal.kernel.portlet.DefaultConfigurationAction;
import com.liferay.portal.kernel.servlet.SessionErrors;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.model.Layout;
import com.liferay.portal.theme.ThemeDisplay;
import com.liferay.portal.util.WebKeys;
import com.liferay.portlet.journal.service.JournalContentSearchLocalServiceUtil;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;

/**
 * @author Brian Wing Shun Chan
 */
public class ConfigurationActionImpl extends DefaultConfigurationAction {

    @Override
    public void processAction(PortletConfig portletConfig, ActionRequest actionRequest,
            ActionResponse actionResponse) throws Exception {

        String[] extensions = actionRequest.getParameterValues("extensions");

        setPreference(actionRequest, "extensions", extensions);

        super.processAction(portletConfig, actionRequest, actionResponse);

        if (SessionErrors.isEmpty(actionRequest)) {
            updateContentSearch(actionRequest);
        }
    }

    protected void updateContentSearch(ActionRequest actionRequest) throws Exception {

        ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

        String articleId = getParameter(actionRequest, "articleId").toUpperCase();

        String portletResource = ParamUtil.getString(actionRequest, "portletResource");

        Layout layout = themeDisplay.getLayout();

        JournalContentSearchLocalServiceUtil.updateContentSearch(layout.getGroupId(), layout.isPrivateLayout(),
                layout.getLayoutId(), portletResource, articleId, true);
    }

}