You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by ju...@apache.org on 2001/09/07 18:13:58 UTC

cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/logger XHttpServletResponseWrapper22.java

juergen     01/09/07 09:13:58

  Added:       src/webdav/server/org/apache/slide/webdav/logger
                        XHttpServletResponseWrapper22.java
  Log:
  the response code of the request is always logged.
  
  Revision  Changes    Path
  1.1                  jakarta-slide/src/webdav/server/org/apache/slide/webdav/logger/XHttpServletResponseWrapper22.java
  
  Index: XHttpServletResponseWrapper22.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/logger/XHttpServletResponseWrapper22.java,v 1.1 2001/09/07 16:13:58 juergen Exp $
   * $Revision: 1.1 $
   * $Date: 2001/09/07 16:13:58 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  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. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
   * ITS 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.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  
  package org.apache.slide.webdav.logger;
  
  import java.io.Writer;
  import java.io.OutputStreamWriter;
  import java.io.PrintWriter;
  import java.io.BufferedOutputStream;
  import java.io.IOException;
  // import java.net.*;
  import java.util.Locale;
  import java.util.Enumeration;
  import java.util.Vector;
  // import java.lang.IllegalArgumentException;
  import javax.servlet.http.Cookie;
  import javax.servlet.ServletOutputStream;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpServletRequest;
  
  import org.apache.slide.common.Domain;
  
  /**
   * Provides a convenient implementation of the HttpServletResponse interface
   * that can be subclassed by developers wishing to adapt the response from a
   * Servlet. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped response object.
   *
   * @author    Hardy.Kiefer@softwareag.com
   *
   * @version   0.1
   *
   * @invariant (inputStream != null)
   *
   * @see       javax.servlet.http.HttpServletResponse
   *
   */
  public class XHttpServletResponseWrapper  implements HttpServletResponse
  {
      
      /**
       * the HttpServletResponse to re-read.
       *
       * @invariant (response != null)
       *
       * @see javax.servlet.http.HttpServletResponse
       */
      protected HttpServletResponse response;
  
      
      /**
       * Constructs a response adaptor wrapping the given response.
       *
       * @pre        (response != null)
       * @post
       *
       * @param      response   HttpServletResponse
       *
       */
      public XHttpServletResponseWrapper(HttpServletResponse response) {
          this.response = response;
      }
  
      /**
       * The default behavior of this method is to call addCookie(Cookie cookie)
       * on the wrapped response object.
       *
       * @param      cookie - the Cookie to return to the client
       *
       * @return     none
       */
      public void addCookie(javax.servlet.http.Cookie cookie) {
          response.addCookie(cookie);
      }
  
      /**
       * The default behavior of this method is to call containsHeader(String name)
       * on the wrapped response object.
       *
       * @param      name - the header name
       *
       * @return     true if the named response header has already been set; false otherwise
       */
      public boolean containsHeader(String name) {
          return response.containsHeader(name);
      }
  
      /**
       * The default behavior of this method is to return encodeRedirectURL(String url)
       * on the wrapped response object.
       *
       * @param      url - the url to be encoded.
       *
       * @return     the encoded URL if encoding is needed; the unchanged URL otherwise.
       */
      public String encodeRedirectURL(String location) {
          return response.encodeRedirectURL(location);
      }
  
      /**
       * Deprecated. As of version 2.1, use encodeRedirectURL(String url) instead.
       * The default behavior of this method is to return encodeRedirectUrl(String url)
       * on the wrapped response object.
       * @param      url - the url to be encoded.
       *
       * @return     the encoded URL if encoding is needed; the unchanged URL otherwise.
       * @deprecated
       */
      public String encodeRedirectUrl(String location) {
          return encodeRedirectURL(location);
      }
  
      /**
       * The default behavior of this method is to call encodeURL(String url)
       * on the wrapped response object.
       *
       * @param      url - the url to be encoded.
       *
       * @return     the encoded URL if encoding is needed; the unchanged URL otherwise.
       */
      public String encodeURL(String url) {
          return response.encodeUrl(url);
      }
  
      /**
       * Deprecated. As of version 2.1, use encodeURL(String url) instead.
       * The default behavior of this method is to call encodeUrl(String url)
       * on the wrapped response object.
       *
       * @param      url - the url to be encoded.
       *
       * @return     the encoded URL if encoding is needed; the unchanged URL otherwise.
       *
       * @deprecated
       */
      public String encodeUrl(String url) {
      return encodeURL(url);
      }
  
      /**
       * Returns the name of the charset used for the MIME body sent in this response.
       *
       * @return     a String specifying the name of the charset, for example, ISO-8859-1
       */
      public String getCharacterEncoding() {
          return response.getCharacterEncoding();
      }
  
      /**
       * The default behavior of this method is to call sendError(int sc)
       * on the wrapped response object.
       *
       * @param      sc - the error status code.
       */
      public void sendError(int sc) throws IOException {
          sendError(sc, "No detailed message");
      }
  
      /**
       * The default behavior of this method is to call sendError(int sc, String msg)
       * on the wrapped response object.
       *
       * @param      sc - the error status code
       *            msg - the descriptive message
       */
      public void sendError(int sc, String msg) throws IOException {
          response.sendError(sc, msg);
      }
  
      /**
       * The default behavior of this method is to return sendRedirect(String location)
       * on the wrapped response object.
       *
       * @param      location - the redirect location URL
       */
      public void sendRedirect(String location)
          throws IOException, IllegalArgumentException {
          response.sendRedirect(location);
      }
  
      /**
       * The default behavior of this method is to call setDateHeader(String name, long date)
       * on the wrapped response object.
       *
       * @param      name - the name of the header to set
       *            value - the assigned date value
       */
      public void setDateHeader(String name, long date) {
          response.setDateHeader(name, date);
      }
  
      /**
       * The default behavior of this method is to call addDateHeader(String name, long date)
       * on the wrapped response object.
       *
       * @param      name - the name of the header to set
       *            value - the additional date value
       */
      public void addDateHeader(String name, long date) {
          response.addDateHeader(name, date);
      }
  
      /**
       * The default behavior of this method is to return setHeader(String name, String value)
       * on the wrapped response object.
       *
       * @param      name - the name of the header
       *            value - the header value
       */
      public void setHeader(String name, String value) {
          response.setHeader(name, value);
      }
  
      /**
       * The default behavior of this method is to return addHeader(String name, String value)
       * on the wrapped response object.
       *
       * @param      name - the name of the header
       *            value - the header value
       */
      public void addHeader(String name, String value) {
          response.addHeader(name, value);
      }
  
      /**
       * The default behavior of this method is to call setIntHeader(String name, int value)
       * on the wrapped response object.
       *
       * @param      name - the name of the header
       *            value - the assigned integer value
       */
      public void setIntHeader(String name, int value) {
          response.setHeader(name, Integer.toString(value));
      }
  
      /**
       * The default behavior of this method is to call addIntHeader(String name, int value)
       * on the wrapped response object.
       *
       * @param      name - the name of the header
       *            value - the assigned integer value
       */
      public void addIntHeader(String name, int value) {
          response.addHeader(name, Integer.toString(value));
      }
  
      /**
       * The default behavior of this method is to call setStatus(int sc)
       * on the wrapped response object.
       *
       * @param      sc - the status code
       */
      public void setStatus(int sc) {
          response.setStatus(sc);
      }
  
      /**
       * Returns the actual buffer size used for the response.
       *
       * @return      the actual buffer size used
       */
      public int getBufferSize() {
          return response.getBufferSize();
      }
  
      /**
       * Clears any data that exists in the buffer as well as the status code and headers.
       */
      public void reset() throws IllegalStateException {
          response.reset();
      }
  
      /**
       * Returns a boolean indicating if the response has been committed.
       *
       * @return      a boolean indicating if the response has been committed
       */
      public boolean isCommitted() {
          return response.isCommitted();
      }
  
      /**
       * Forces any content in the buffer to be written to the client.
       */
      public void flushBuffer() throws IOException {
          response.flushBuffer();
      }
  
      /**
       * Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate.
       *
       * @param      loc - the locale of the response
       */
      public void setLocale(Locale loc) {
          response.setLocale(loc);
      }
  
      /**
       * Returns the locale assigned to the response.
       *
       * @return      the locale assigned to the response.
       */
      public Locale getLocale() {
          return response.getLocale();
      }
  
      /**
       * The default behavior of this method is to call setStatus(int sc, String sm) on the wrapped response object.
       * @deprecated
       */
      public void setStatus(int sc, String msg) {
          response.setStatus(sc);
      }
      /**
       * The default behavior of this method is to call setBufferSize(int size)
       * the wrapped response object.
       *
       * @param      size - the preferred buffer size
       */
      public void setBufferSize(int size) throws IllegalStateException {
          response.setBufferSize(size);
      }
      /**
       * The default behavior of this method is to call setContentType(String type)
       * the wrapped response object.
       *
       * @param      type - a String specifying the MIME type of the content
       */
      public void setContentType(String type) {
          response.setContentType(type);
      }
      /**
       * The default behavior of this method is to call getWriter()
       * the wrapped response object.
       *
       * @return     a PrintWriter object that can return character data to the client
       */
      public PrintWriter getWriter() throws IOException {
          return response.getWriter();
      }
      /**
       * The default behavior of this method is to call setContentLength(int len)
       * the wrapped response object.
       *
       * @param      len - an integer specifying the length of the content being returned to the client; sets the Content-Length header
       */
      public void setContentLength(int len) {
          response.setContentLength(len);
      }
  
      /**
       * The default behavior of this method is to call getOutputStream()
       * the wrapped response object.
       *
       * @return     a ServletOutputStream for writing binary data
       */
      public ServletOutputStream getOutputStream()
          throws IOException {
          return response.getOutputStream();
      }
  
  
  }