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.events;
016    
017    import com.liferay.portal.util.PortalUtil;
018    
019    import javax.portlet.RenderRequest;
020    import javax.portlet.RenderResponse;
021    
022    import javax.servlet.http.HttpServletRequest;
023    import javax.servlet.http.HttpServletResponse;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public abstract class Action {
029    
030            public abstract void run(
031                            HttpServletRequest request, HttpServletResponse response)
032                    throws ActionException;
033    
034            public void run(RenderRequest renderRequest, RenderResponse renderResponse)
035                    throws ActionException {
036    
037                    try {
038                            HttpServletRequest request = PortalUtil.getHttpServletRequest(
039                                    renderRequest);
040                            HttpServletResponse response = PortalUtil.getHttpServletResponse(
041                                    renderResponse);
042    
043                            run(request, response);
044                    }
045                    catch (ActionException ae) {
046                            throw ae;
047                    }
048                    catch (Exception e) {
049                            throw new ActionException(e);
050                    }
051            }
052    
053    }