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.kernel.bi.reporting.servlet;
016    
017    import com.liferay.portal.kernel.bi.reporting.ReportDesignRetriever;
018    
019    import java.io.InputStream;
020    
021    import java.util.Date;
022    
023    import javax.servlet.ServletContext;
024    
025    /**
026     * @author Michael C. Han
027     */
028    public class ServletContextReportDesignRetriever
029            implements ReportDesignRetriever {
030    
031            public ServletContextReportDesignRetriever(
032                    ServletContext servletContext, String reportName, String prefix,
033                    String postfix) {
034    
035                    _servletContext = servletContext;
036                    _reportName = reportName;
037                    _prefix = prefix;
038                    _postfix = postfix;
039            }
040    
041            public InputStream getInputStream() {
042                    return _servletContext.getResourceAsStream(
043                            _prefix + _reportName + _postfix);
044            }
045    
046            public Date getModifiedDate() {
047                    return new Date();
048            }
049    
050            public String getReportName() {
051                    return _reportName;
052            }
053    
054            private String _postfix;
055            private String _prefix;
056            private String _reportName;
057            private ServletContext _servletContext;
058    
059    }