diff --git a/scm-core/src/main/java/sonia/scm/filter/GZipFilter.java b/scm-core/src/main/java/sonia/scm/filter/GZipFilter.java index 32b963053f..8e5c07e1c8 100644 --- a/scm-core/src/main/java/sonia/scm/filter/GZipFilter.java +++ b/scm-core/src/main/java/sonia/scm/filter/GZipFilter.java @@ -53,6 +53,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** + * Filter for gzip encoding. * * @author Sebastian Sdorra * @since 1.15 @@ -70,10 +71,10 @@ public class GZipFilter extends HttpFilter //~--- get methods ---------------------------------------------------------- /** - * Method description + * Return the configuration for the gzip filter. * * - * @return + * @return gzip filter configuration */ public GZipFilterConfig getConfig() { @@ -83,12 +84,12 @@ public class GZipFilter extends HttpFilter //~--- methods -------------------------------------------------------------- /** - * Method description + * Encodes the response, if the request has support for gzip encoding. * * - * @param request - * @param response - * @param chain + * @param request http request + * @param response http response + * @param chain filter chain * * @throws IOException * @throws ServletException @@ -119,6 +120,6 @@ public class GZipFilter extends HttpFilter //~--- fields --------------------------------------------------------------- - /** Field description */ + /** gzip filter configuration */ private GZipFilterConfig config = new GZipFilterConfig(); } diff --git a/scm-core/src/main/java/sonia/scm/filter/GZipFilterConfig.java b/scm-core/src/main/java/sonia/scm/filter/GZipFilterConfig.java index 1132ff1259..c1cf412a06 100644 --- a/scm-core/src/main/java/sonia/scm/filter/GZipFilterConfig.java +++ b/scm-core/src/main/java/sonia/scm/filter/GZipFilterConfig.java @@ -30,9 +30,11 @@ */ + package sonia.scm.filter; /** + * Configuration for the {@link GZipFilter}. * * @author Sebastian Sdorra * @since 1.16 @@ -41,32 +43,61 @@ public class GZipFilterConfig { /** - * Method description + * Returns true if the response should be buffered. * * - * @return + * @return true if the response should be buffered + * @deprecated use {@link #isBufferResponse()} instead. */ + @Deprecated public boolean isBufferRequest() { - return bufferRequest; + return bufferResponse; + } + + /** + * Returns true if the response should be buffered. + * + * + * @return true if the response should be buffered + */ + public boolean isBufferResponse() + { + return bufferResponse; } //~--- set methods ---------------------------------------------------------- /** - * Method description + * Enables or disables response buffering. Default buffering is enabled. * * - * @param bufferRequest + * @param bufferRequest true to enabled response buffering. + * @deprecated use {@link #setBufferResponse(boolean)} instead. * + * @param bufferResponse */ - public void setBufferRequest(boolean bufferRequest) + @Deprecated + public void setBufferRequest(boolean bufferResponse) { - this.bufferRequest = bufferRequest; + this.bufferResponse = bufferResponse; + } + + /** + * Enables or disables response buffering. Default buffering is enabled. + * + * + * @param bufferRequest true to enabled response buffering. + * + * @param bufferResponse + */ + public void setBufferResponse(boolean bufferResponse) + { + this.bufferResponse = bufferResponse; } //~--- fields --------------------------------------------------------------- /** Field description */ - private boolean bufferRequest = true; + private boolean bufferResponse = true; } diff --git a/scm-core/src/main/java/sonia/scm/filter/GZipResponseStream.java b/scm-core/src/main/java/sonia/scm/filter/GZipResponseStream.java index c0768a42d6..4c71412a46 100644 --- a/scm-core/src/main/java/sonia/scm/filter/GZipResponseStream.java +++ b/scm-core/src/main/java/sonia/scm/filter/GZipResponseStream.java @@ -51,6 +51,7 @@ import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; /** + * Response stream for gzip encoding. * * @author Sebastian Sdorra * @since 1.15 @@ -90,15 +91,15 @@ public class GZipResponseStream extends ServletOutputStream * @since 1.16 */ public GZipResponseStream(HttpServletResponse response, - GZipFilterConfig config) - throws IOException + GZipFilterConfig config) + throws IOException { super(); closed = false; this.response = response; response.addHeader("Content-Encoding", "gzip"); - if ((config == null) || config.isBufferRequest()) + if ((config == null) || config.isBufferResponse()) { if (logger.isTraceEnabled()) { @@ -243,10 +244,10 @@ public class GZipResponseStream extends ServletOutputStream //~--- get methods ---------------------------------------------------------- /** - * Method description + * Returns true if the stream is closed. * * - * @return + * @return true if the stream is closed */ public boolean isClosed() { diff --git a/scm-core/src/main/java/sonia/scm/filter/GZipResponseWrapper.java b/scm-core/src/main/java/sonia/scm/filter/GZipResponseWrapper.java index d7f0a43da7..6b05ff53c6 100644 --- a/scm-core/src/main/java/sonia/scm/filter/GZipResponseWrapper.java +++ b/scm-core/src/main/java/sonia/scm/filter/GZipResponseWrapper.java @@ -48,6 +48,7 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; /** + * Response wrapper for gzip encoding. * * @author Sebastian Sdorra * @since 1.15 @@ -56,10 +57,10 @@ public class GZipResponseWrapper extends HttpServletResponseWrapper { /** - * Constructs ... + * Constructs a new GZipResponseWrapper * * - * @param response + * @param response http response to wrap */ public GZipResponseWrapper(HttpServletResponse response) { @@ -207,15 +208,15 @@ public class GZipResponseWrapper extends HttpServletResponseWrapper //~--- fields --------------------------------------------------------------- - /** Field description */ + /** gzip filter config */ protected GZipFilterConfig config = null; - /** Field description */ + /** original http response */ protected HttpServletResponse origResponse = null; - /** Field description */ + /** gzip stream */ protected GZipResponseStream stream = null; - /** Field description */ + /** response writer */ protected PrintWriter writer = null; } diff --git a/scm-core/src/main/java/sonia/scm/filter/package-info.java b/scm-core/src/main/java/sonia/scm/filter/package-info.java new file mode 100644 index 0000000000..3048854b66 --- /dev/null +++ b/scm-core/src/main/java/sonia/scm/filter/package-info.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of SCM-Manager; nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + +/** http filter for SCM-Manager */ +package sonia.scm.filter; \ No newline at end of file