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.dao.search;
016    
017    import com.liferay.portal.kernel.bean.BeanPropertiesUtil;
018    import com.liferay.portal.kernel.servlet.DirectRequestDispatcherFactoryUtil;
019    import com.liferay.portal.kernel.servlet.PipingServletResponse;
020    
021    import javax.servlet.RequestDispatcher;
022    import javax.servlet.ServletContext;
023    import javax.servlet.http.HttpServletRequest;
024    import javax.servlet.http.HttpServletResponse;
025    import javax.servlet.jsp.PageContext;
026    
027    /**
028     * @author Brian Wing Shun Chan
029     */
030    public class JSPSearchEntry extends SearchEntry {
031    
032            @Override
033            public Object clone() {
034                    JSPSearchEntry jspSearchEntry = new JSPSearchEntry();
035    
036                    BeanPropertiesUtil.copyProperties(this, jspSearchEntry);
037    
038                    return jspSearchEntry;
039            }
040    
041            public String getPath() {
042                    return _path;
043            }
044    
045            public HttpServletRequest getRequest() {
046                    return _request;
047            }
048    
049            public HttpServletResponse getResponse() {
050                    return _response;
051            }
052    
053            public ServletContext getServletContext() {
054                    return _servletContext;
055            }
056    
057            @Override
058            public void print(PageContext pageContext) throws Exception {
059                    if (_servletContext != null) {
060                            RequestDispatcher requestDispatcher =
061                                    DirectRequestDispatcherFactoryUtil.getRequestDispatcher(
062                                            _servletContext, _path);
063    
064                            requestDispatcher.include(
065                                    _request, new PipingServletResponse(pageContext));
066                    }
067                    else {
068                            pageContext.include(_path);
069                    }
070            }
071    
072            public void setPath(String path) {
073                    _path = path;
074            }
075    
076            public void setRequest(HttpServletRequest request) {
077                    _request = request;
078            }
079    
080            public void setResponse(HttpServletResponse response) {
081                    _response = response;
082            }
083    
084            public void setServletContext(ServletContext servletContext) {
085                    _servletContext = servletContext;
086            }
087    
088            private String _path;
089            private HttpServletRequest _request;
090            private HttpServletResponse _response;
091            private ServletContext _servletContext;
092    
093    }