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.portal.struts;
016    
017    import com.liferay.portal.kernel.struts.BaseStrutsAction;
018    
019    import javax.servlet.http.HttpServletRequest;
020    import javax.servlet.http.HttpServletResponse;
021    
022    import org.apache.struts.action.Action;
023    import org.apache.struts.action.ActionForm;
024    import org.apache.struts.action.ActionForward;
025    import org.apache.struts.action.ActionMapping;
026    
027    /**
028     * @author Mika Koivisto
029     */
030    public class StrutsActionAdapter extends BaseStrutsAction {
031    
032            public StrutsActionAdapter(
033                    Action action, ActionMapping actionMapping, ActionForm actionForm) {
034    
035                    _action = action;
036                    _actionMapping = actionMapping;
037                    _actionForm = actionForm;
038            }
039    
040            @Override
041            public String execute(
042                            HttpServletRequest request, HttpServletResponse response)
043                    throws Exception {
044    
045                    ActionForward actionForward = _action.execute(
046                            _actionMapping, _actionForm, request, response);
047    
048                    if (actionForward == null) {
049                            return null;
050                    }
051    
052                    return actionForward.getPath();
053            }
054    
055            private Action _action;
056            private ActionForm _actionForm;
057            private ActionMapping _actionMapping;
058    
059    }