001    /**
002     * Copyright (c) 2000-present 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.portlet.asset.util;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.util.Validator;
020    
021    import java.io.IOException;
022    
023    import javax.servlet.RequestDispatcher;
024    import javax.servlet.ServletContext;
025    import javax.servlet.ServletException;
026    import javax.servlet.http.HttpServletRequest;
027    import javax.servlet.http.HttpServletResponse;
028    
029    /**
030     * @author Julio Camarero
031     */
032    public abstract class BaseJSPAssetEntryQueryProcessor
033            extends BaseAssetEntryQueryProcessor {
034    
035            public abstract String getJspPath();
036    
037            @Override
038            public void include(
039                            HttpServletRequest request, HttpServletResponse response)
040                    throws IOException {
041    
042                    String jspPath = getJspPath();
043    
044                    if (Validator.isNull(jspPath)) {
045                            return;
046                    }
047    
048                    RequestDispatcher requestDispatcher =
049                            _servletContext.getRequestDispatcher(jspPath);
050    
051                    try {
052                            requestDispatcher.include(request, response);
053                    }
054                    catch (ServletException se) {
055                            _log.error("Unable to include " + jspPath, se);
056                    }
057            }
058    
059            public void setServletContext(ServletContext servletContext) {
060                    _servletContext = servletContext;
061            }
062    
063            private static final Log _log = LogFactoryUtil.getLog(
064                    BaseJSPAssetEntryQueryProcessor.class);
065    
066            private ServletContext _servletContext;
067    
068    }