001    /**
002     * Copyright (c) 2000-2010 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.portal.kernel.portlet;
016    
017    import com.liferay.portal.kernel.exception.SystemException;
018    import com.liferay.portal.kernel.util.ParamUtil;
019    import com.liferay.portal.kernel.util.WebKeys;
020    import com.liferay.portal.model.Portlet;
021    import com.liferay.portal.service.PortletLocalServiceUtil;
022    import com.liferay.portal.theme.ThemeDisplay;
023    import com.liferay.portlet.PortletConfigFactoryUtil;
024    
025    import javax.portlet.ActionRequest;
026    import javax.portlet.ActionResponse;
027    import javax.portlet.PortletConfig;
028    import javax.portlet.PortletRequest;
029    import javax.portlet.RenderRequest;
030    import javax.portlet.RenderResponse;
031    import javax.portlet.ResourceRequest;
032    import javax.portlet.ResourceResponse;
033    
034    import javax.servlet.ServletContext;
035    
036    /**
037     * @author Brian Wing Shun Chan
038     */
039    public class BaseConfigurationAction
040            implements ConfigurationAction, ResourceServingConfigurationAction {
041    
042            public void processAction(
043                            PortletConfig portletConfig, ActionRequest actionRequest,
044                            ActionResponse actionResponse)
045                    throws Exception {
046            }
047    
048            public String render(
049                            PortletConfig portletConfig, RenderRequest renderRequest,
050                            RenderResponse renderResponse)
051                    throws Exception {
052    
053                    return "/configuration.jsp";
054            }
055    
056            public void serveResource(
057                            PortletConfig portletConfig, ResourceRequest resourceRequest,
058                            ResourceResponse resourceResponse)
059                    throws Exception {
060            }
061    
062            protected PortletConfig getSelPortletConfig(PortletRequest portletRequest)
063                    throws SystemException {
064    
065                    ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
066                            WebKeys.THEME_DISPLAY);
067    
068                    String portletResource = ParamUtil.getString(
069                            portletRequest, "portletResource");
070    
071                    Portlet selPortlet = PortletLocalServiceUtil.getPortletById(
072                            themeDisplay.getCompanyId(), portletResource);
073    
074                    ServletContext servletContext =
075                            (ServletContext)portletRequest.getAttribute(WebKeys.CTX);
076    
077                    PortletConfig selPortletConfig = PortletConfigFactoryUtil.create(
078                            selPortlet, servletContext);
079    
080                    return selPortletConfig;
081            }
082    
083    }