001    /**
002     * Copyright (c) 2000-2013 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.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    }