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.action;
016    
017    import com.liferay.portal.kernel.util.HttpUtil;
018    import com.liferay.portal.kernel.util.ParamUtil;
019    import com.liferay.portal.kernel.util.Validator;
020    import com.liferay.util.servlet.ServletResponseUtil;
021    
022    import javax.servlet.http.HttpServletRequest;
023    import javax.servlet.http.HttpServletResponse;
024    
025    import org.apache.struts.action.Action;
026    import org.apache.struts.action.ActionForm;
027    import org.apache.struts.action.ActionForward;
028    import org.apache.struts.action.ActionMapping;
029    
030    /**
031     * @author David Truong
032     * @author Gavin Wan
033     */
034    public class RESTProxyAction extends Action {
035    
036            public ActionForward execute(
037                            ActionMapping mapping, ActionForm form, HttpServletRequest request,
038                            HttpServletResponse response)
039                    throws Exception {
040    
041                    String url = ParamUtil.getString(request, "url");
042    
043                    if (Validator.isNotNull(url)) {
044                            String content = HttpUtil.URLtoString(url, true);
045    
046                            ServletResponseUtil.write(response, content);
047                    }
048    
049                    return null;
050            }
051    
052    }