001    /**
002     * Copyright (c) 2000-2011 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.dao.search;
016    
017    import com.liferay.portal.kernel.bean.BeanPropertiesUtil;
018    import com.liferay.portal.kernel.servlet.PipingServletResponse;
019    
020    import javax.servlet.RequestDispatcher;
021    import javax.servlet.ServletContext;
022    import javax.servlet.http.HttpServletRequest;
023    import javax.servlet.http.HttpServletResponse;
024    import javax.servlet.jsp.PageContext;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class JSPSearchEntry extends SearchEntry {
030    
031            public JSPSearchEntry() {
032            }
033    
034            /**
035             * @deprecated
036             */
037            public JSPSearchEntry(String align, String valign, String path) {
038                    this(align, valign, DEFAULT_COLSPAN, path, null, null, null);
039            }
040    
041            /**
042             * @deprecated
043             */
044            public JSPSearchEntry(
045                    String align, String valign, int colspan, String path) {
046    
047                    this(align, valign, colspan, path, null, null, null);
048            }
049    
050            /**
051             * @deprecated
052             */
053            public JSPSearchEntry(
054                    String align, String valign, int colspan, String path,
055                    ServletContext servletContext, HttpServletRequest request,
056                    HttpServletResponse response) {
057    
058                    super(align, valign, colspan);
059    
060                    _path = path;
061                    _servletContext = servletContext;
062                    _request = request;
063                    _response = response;
064            }
065    
066            @Override
067            public Object clone() {
068                    JSPSearchEntry jspSearchEntry = new JSPSearchEntry();
069    
070                    BeanPropertiesUtil.copyProperties(this, jspSearchEntry);
071    
072                    return jspSearchEntry;
073            }
074    
075            public String getPath() {
076                    return _path;
077            }
078    
079            public HttpServletRequest getRequest() {
080                    return _request;
081            }
082    
083            public HttpServletResponse getResponse() {
084                    return _response;
085            }
086    
087            public ServletContext getServletContext() {
088                    return _servletContext;
089            }
090    
091            @Override
092            public void print(PageContext pageContext) throws Exception {
093                    if (_servletContext != null) {
094                            RequestDispatcher requestDispatcher =
095                                    _servletContext.getRequestDispatcher(_path);
096    
097                            requestDispatcher.include(
098                                    _request, new PipingServletResponse(pageContext));
099                    }
100                    else {
101                            pageContext.include(_path);
102                    }
103            }
104    
105            public void setPath(String path) {
106                    _path = path;
107            }
108    
109            public void setRequest(HttpServletRequest request) {
110                    _request = request;
111            }
112    
113            public void setResponse(HttpServletResponse response) {
114                    _response = response;
115            }
116    
117            public void setServletContext(ServletContext servletContext) {
118                    _servletContext = servletContext;
119            }
120    
121            private String _path;
122            private HttpServletRequest _request;
123            private HttpServletResponse _response;
124            private ServletContext _servletContext;
125    
126    }