cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From step...@apache.org
Subject cvs commit: xml-cocoon2/src/blocks/slide/samples sitemap.xmap
Date Sat, 15 Feb 2003 23:01:48 GMT
stephan     2003/02/15 15:01:48

  Modified:    lib      jars.xml
               src/blocks/slide/samples sitemap.xmap
  Added:       lib/optional slide-webdavservlet-20030215.jar
               src/blocks/slide/java/org/apache/cocoon/reading
                        WebdavReader.java
               src/blocks/slide/java/org/apache/cocoon/reading/helpers
                        WebdavServletConfig.java WebdavServletRequest.java
                        WebdavServletResponse.java
  Removed:     lib/optional slide-webdavservlet-20030208.jar
  Log:
  Add a reader, which responses HTTP 1.1(WebDAV) requests based
  on the Jakarta Slide WebDAV Servlet.
  
  Revision  Changes    Path
  1.80      +2 -2      xml-cocoon2/lib/jars.xml
  
  Index: jars.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/lib/jars.xml,v
  retrieving revision 1.79
  retrieving revision 1.80
  diff -u -r1.79 -r1.80
  --- jars.xml	13 Feb 2003 19:06:39 -0000	1.79
  +++ jars.xml	15 Feb 2003 23:01:46 -0000	1.80
  @@ -559,10 +559,10 @@
     <homepage>http://jakarta.apache.org/slide/</homepage>
    </file>
    <file name="slide-webdavservlet">
  -  <title>Slide kernel</title>
  +  <title>Slide WebDAV Servlet</title>
     <description>The Jakarta Slide WebDAV servlet.</description>
     <used-by>Slide block</used-by>
  -  <lib>optional/slide-webdavservlet-20030208.jar</lib>
  +  <lib>optional/slide-webdavservlet-20030215.jar</lib>
     <homepage>http://jakarta.apache.org/slide/</homepage>
    </file>
    <file name="jdom">
  
  
  
  1.1                  xml-cocoon2/lib/optional/slide-webdavservlet-20030215.jar
  
  	<<Binary file>>
  
  
  1.1                  xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/reading/WebdavReader.java
  
  Index: WebdavReader.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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  acknowledgment:   "This product includes software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" 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 name,  without prior written permission  of the
      Apache Software Foundation.
  
   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 (INCLU-
   DING, 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 and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.cocoon.reading;
  
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  import java.io.OutputStream;
  import java.util.Map;
  
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletContext;
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.ComponentSelector;
  import org.apache.avalon.framework.parameters.Parameterizable;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.avalon.framework.parameters.ParameterException;
  
  import org.apache.cocoon.ProcessingException;
  import org.apache.cocoon.components.repository.Repository;
  import org.apache.cocoon.components.repository.impl.SlideRepository;
  import org.apache.cocoon.environment.ObjectModelHelper;
  import org.apache.cocoon.environment.SourceResolver;
  import org.apache.cocoon.environment.http.HttpEnvironment;
  import org.apache.cocoon.reading.helpers.WebdavServletConfig;
  import org.apache.cocoon.reading.helpers.WebdavServletRequest;
  import org.apache.cocoon.reading.helpers.WebdavServletResponse;
  
  import org.apache.slide.common.NamespaceAccessToken;
  import org.apache.slide.common.SlideException;
  import org.apache.slide.webdav.WebdavException;
  import org.apache.slide.webdav.WebdavMethod;
  import org.apache.slide.webdav.WebdavMethodFactory;
  import org.apache.slide.webdav.WebdavServlet;
  import org.apache.slide.webdav.util.DirectoryIndexGenerator;
  import org.apache.slide.webdav.util.WebdavUtils;
  import org.apache.slide.security.AccessDeniedException;
  import org.apache.slide.structure.LinkedObjectNotFoundException;
  import org.apache.slide.structure.ObjectNotFoundException;
  
  import org.apache.util.WebdavStatus;
  
  import org.xml.sax.SAXException;
  
  /**
   * A reader, which responses WebDAV requests. This class based on
   * the WebDAVServlet from the Jakarta Slide project.
   *
   * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
   * @version CVS $Id: WebdavReader.java,v 1.1 2003/02/15 23:01:47 stephan Exp $
   */
  public class WebdavReader extends ComposerReader implements Parameterizable {
  
      /**
       * Parameters of the reader.
       */
      private Parameters parameters = null;
  
      /**
       * Access token to the namespace.
       */
      private NamespaceAccessToken token;
  
      /**
       * Instance of the WebdavMethodFactory to use by this servlet.
       */
      private WebdavMethodFactory methodFactory;
  
      /**
       * Directory browsing enabled.
       */
      private boolean directoryBrowsing = true;
  
      /**
       * RequestDispatcher to the directory browsing template, if specified.
       */
      private RequestDispatcher directoryBrowsingTemplate;
  
      /**
       * Directory browsing enabled.
       */
      private DirectoryIndexGenerator directoryIndexGenerator;
  
      private WebdavServletConfig config = null;
  
      /**
       * Provide component with parameters.
       *
       * @param parameters the parameters
       * @throws ParameterException if parameters are invalid
       */
      public void parameterize(Parameters parameters)
        throws ParameterException {
  
          this.parameters = parameters;
      }
  
      /**
       * Generate the response.
       */
      public void generate()
        throws IOException, SAXException, ProcessingException {
  
          WebdavServletRequest req = new WebdavServletRequest((HttpServletRequest) objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT),
                                         this.source);
          WebdavServletResponse resp = new WebdavServletResponse((HttpServletResponse)
                                           objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT), this.out);
  
          this.config = new WebdavServletConfig(parameters, (ServletContext)
              objectModel.get(HttpEnvironment.HTTP_SERVLET_CONTEXT));
  
          if (getLogger().isDebugEnabled()) {
              getLogger().debug("==> "+req.getMethod()+" start: ");
          }
  
          String repositoryname = parameters.getParameter("repository",
                                      "slide");
          String namespace = parameters.getParameter("namespace", null);
  
          ComponentSelector repositories = null;
          Repository repository = null;
  
          try {
              repositories = (ComponentSelector) this.manager.lookup(Repository.ROLE+
                  "Selector");
  
              repository = (Repository) repositories.select(repositoryname);
  
              if ( !(repository instanceof SlideRepository)) {
                  throw new ProcessingException("Can't get Slide repository");
              }
  
              SlideRepository sliderepository = (SlideRepository) repository;
  
              token = sliderepository.getNamespaceToken(namespace);
  
              if (token==null) {
                  throw new ProcessingException("Repository with the namespace '"+
                                                namespace+
                                                "' couldn't be found");
              }
  
              this.config.getServletContext().setAttribute(WebdavServlet.ATTRIBUTE_NAME, token);
  
          } catch (ComponentException ce) {
              throw new ProcessingException("Could not lookup for component.",
                                            ce);
          } finally {
              if ((repository!=null) && (repository instanceof Component)) {
                  repositories.release((Component) repository);
              }
              repository = null;
  
              if (repositories!=null) {
                  this.manager.release(repositories);
              }
              repositories = null;
          }
  
          try {
              long startTime = System.currentTimeMillis();
  
              resp.setStatus(WebdavStatus.SC_OK);
  
              String methodName = req.getMethod();
  
              if ((methodName.equalsIgnoreCase("GET") || methodName.equalsIgnoreCase("POST")) &&
                  WebdavUtils.isCollection(token, req, config)) {
                  // let the standard doGet() / doPost() methods handle
                  // GET/POST requests on collections (to display a directory
                  // index pag or something similar)
                  if (methodName.equalsIgnoreCase("GET")) {
                      doGet(req, resp);
                  } else {
                      doPut(req, resp);
                  }
              } else {
                  if (this.methodFactory==null) {
                      // Setup the method factory
                      this.methodFactory = WebdavMethodFactory.newInstance(config);
                  }
                  WebdavMethod method = methodFactory.createMethod(methodName);
  
                  if (method==null) {
                      throw new WebdavException(WebdavStatus.SC_METHOD_NOT_ALLOWED);
                  } else {
                      method.run(req, resp);
                  }
              }
          } catch (WebdavException e) {
              // There has been an error somewhere ...
              getLogger().error("Could not execute Webdav method", e);
              try {
                  resp.sendError(e.getStatusCode());
              } catch (Throwable ex) {}
          } catch (Throwable e) {
              // If something goes really wrong ...
              getLogger().error("Could not execute Webdav method", e);
              try {
                  resp.sendError(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
              } catch (Throwable ex) {}
          } finally {
              if (getLogger().isDebugEnabled()) {
                  getLogger().debug("<== "+req.getMethod()+" end: ");
              }
          }
  
      }
  
      /**
       * Handle a GET request on a collection resource.
       */
      private void doGet(HttpServletRequest req,
                         HttpServletResponse resp)
                           throws ServletException, IOException {
  
          if (directoryBrowsing) {
              if (directoryIndexGenerator==null) {
                  directoryIndexGenerator =
                      new DirectoryIndexGenerator
                          (token, config);
              }
  
              if (directoryBrowsingTemplate!=null) {
                  // attributes used by the tag library
                  req.setAttribute("org.apache.slide.NamespaceName",
                                   token.getName());
                  // attributes for general use
                  req.setAttribute("slide_namespace", token.getName());
                  req.setAttribute("slide_uri",
                                   WebdavUtils.getRelativePath(req, config));
                  directoryBrowsingTemplate.forward(req, resp);
              } else {
                  try {
                      directoryIndexGenerator.generate(req, resp);
                  } catch (AccessDeniedException e) {
                      resp.sendError(WebdavStatus.SC_FORBIDDEN);
                  } catch (ObjectNotFoundException e) {
                      resp.sendError(WebdavStatus.SC_NOT_FOUND);
                  } catch (LinkedObjectNotFoundException e) {
                      resp.sendError(WebdavStatus.SC_NOT_FOUND);
                  } catch (SlideException e) {
                      resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
                  }
              }
          } else {
              resp.sendError(WebdavStatus.SC_FORBIDDEN);
          }
      }
  
      /**
       * Handle a PUT request on a collection resource.
       */
      private void doPut(HttpServletRequest req,
                         HttpServletResponse resp)
                           throws ServletException, IOException {
  
          String protocol = req.getProtocol();
  
          if (protocol.endsWith("1.1")) {
              resp.sendError(WebdavStatus.SC_METHOD_NOT_ALLOWED);
          } else {
              resp.sendError(WebdavStatus.SC_BAD_REQUEST);
          }
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/reading/helpers/WebdavServletConfig.java
  
  Index: WebdavServletConfig.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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  acknowledgment:   "This product includes software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" 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 name,  without prior written permission  of the
      Apache Software Foundation.
  
   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 (INCLU-
   DING, 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 and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.cocoon.reading.helpers;
  
  import java.util.Enumeration;
  
  import javax.servlet.ServletConfig;
  import javax.servlet.ServletContext;
  
  import org.apache.avalon.framework.parameters.Parameters;
  
  /**
   * A wrapper for WebdavServletConfig, which respected the parameters
   * of the reader.
   *
   * @author <a href="mailto:stephan@apache.org">Stephan Michels </a>
   * @version CVS $Id: WebdavServletConfig.java,v 1.1 2003/02/15 23:01:47 stephan Exp $
   */
  public class WebdavServletConfig
    extends org.apache.slide.webdav.WebdavServletConfig {
  
      /**
       * Parameters of the WebDAVReader, which overrides the context parameters
       */
      private Parameters parameters = null;
  
      private ServletContext context = null;
  
      /**
       * Constructor.
       *
       * @param config the ServletConfig to wrap
       * @param parameters 
       */
      public WebdavServletConfig(Parameters parameters, ServletContext context) {
  
          this.parameters = parameters;
          this.context = context;
      }
  
      /**
       * Returns a String containing the value of the named initialization 
       * parameter, or null if the parameter does not exist.
       *
       * @param name a String specifying the name of the initialization parameter
       * @return a String containing the value of the initialization parameter
       */
      public String getInitParameter(String name) {
          
          return parameters.getParameter(name, null);
      }
      
  
      /**
       * Returns the names of the servlet's initialization parameters as an 
       * Enumeration of String objects, or an empty Enumeration if the servlet 
       * has no initialization parameters.
       *
       * @return an Enumeration of String objects containing the names of the 
       *         servlet's initialization parameters
       */
      public Enumeration getInitParameterNames() {
  
          throw new RuntimeException("Not implemented");
      }
      
  
      /**
       * Returns a reference to the ServletContext in which the caller 
       * is executing.
       *
       * @return a ServletContext object, used by the caller to interact with 
       *         its servlet container
       */
      public ServletContext getServletContext() {
      
          return context;
      }
      
  
      /**
       * Returns the name of this servlet instance.
       * The name may be provided via server administration, assigned in the 
       * web application deployment descriptor, or for an unregistered (and thus 
       * unnamed) servlet instance it will be the servlet's class name.
       *
       * @return the name of the servlet instance
       */
      public String getServletName() {
  
          throw new RuntimeException("Not implemented");
      }
  
      /**
       * Returns the default MIME type of resources, to be used for example when
       * clients do not specify the content-type of files uploaded with the
       * PUT method.
       *
       * @return the default MIME type (for example &quot;text/plain&quot;)
       */
      public String getDefaultMimeType() {
  
          return parameters.getParameter(SCOPE_PARAMETER,
                                         super.getDefaultMimeType());
      }
  
      /**
       * Returns the depth limit. The depth limit should be used to limit the
       * depth of (for instance) PROPFIND operations, in case the client has
       * requested &quot;Depth: infinity&quot;
       *
       * @return the depth limit
       */
      public int getDepthLimit() {
  
          return parameters.getParameterAsInteger(DEPTH_LIMIT_PARAMETER,
                                                  getDepthLimit());
      }
  
      /**
       * Returns the name of the WebdavMethodFactory class configured by the
       * user, or the default class name if the corresponding initialization
       * parameter 'method-factory' was not provided.
       *
       * @return class name of the method factory
       */
      public String getMethodFactory() {
  
          return parameters.getParameter(METHOD_FACTORY_PARAMETER,
                                         super.getMethodFactory());
      }
  
      /**
       * Returns the user defined scope in the namespace that shall be exposed
       * by the WebdavServlet. This should be treated as root directory of the
       * WebDAV namespace. By default this will be an empty string.
       *
       * @return the scope URI
       */
      public String getScope() {
  
          return parameters.getParameter(SCOPE_PARAMETER, super.getScope());
      }
  
      /**
       * Returns whether the servlet is mapped as default servlet of the web
       * application.
       *
       * @returns true if the servlet is configured as default servlet of the
       *          context
       *
       * @return
       */
      public boolean isDefaultServlet() {
  
          return false;
      }
  }
  
  
  
  
  1.1                  xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/reading/helpers/WebdavServletRequest.java
  
  Index: WebdavServletRequest.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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  acknowledgment:   "This product includes software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" 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 name,  without prior written permission  of the
      Apache Software Foundation.
  
   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 (INCLU-
   DING, 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 and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.cocoon.reading.helpers;
  
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.UnsupportedEncodingException;
  import java.util.Enumeration;
  import java.util.Locale;
  import java.util.Map;
  
  import javax.servlet.ServletInputStream;
  import javax.servlet.RequestDispatcher;
  import javax.servlet.http.Cookie;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  
  /**
   * A wrapper for HttpServletRequest, which respects the
   * uri of the reader.
   *
   * @author <a href="mailto:stephan@apache.org">Stephan Michels </a>
   * @version CVS $Id: WebdavServletRequest.java,v 1.1 2003/02/15 23:01:48 stephan Exp $
   */
  public class WebdavServletRequest implements HttpServletRequest {
  
      private String uri = null;
      private HttpServletRequest request;
  
      public WebdavServletRequest(HttpServletRequest request, String uri) {
          this.request = request;
          this.uri = uri;
      }
  
      /**
       * The default behavior of this method is to call getAttribute(String name)
       * on the wrapped request object.
       */
      public Object getAttribute(String name) {
          return this.request.getAttribute(name);
      }
  
      /**
       * The default behavior of this method is to return getAttributeNames()
       * on the wrapped request object.
       */
      public Enumeration getAttributeNames() {
          return this.request.getAttributeNames();
      }
  
      /**
       * The default behavior of this method is to return getCharacterEncoding()
       * on the wrapped request object.
       */
      public String getCharacterEncoding() {
          return this.request.getCharacterEncoding();
      }
  
      /**
       * The default behavior of this method is to return getContentLength()
       * on the wrapped request object.
       */
      public int getContentLength() {
          return this.request.getContentLength();
      }
  
      /**
       * The default behavior of this method is to return getContentType()
       * on the wrapped request object.
       */
      public String getContentType() {
          return this.request.getContentType();
      }
  
      /**
       * The default behavior of this method is to return getInputStream()
       * on the wrapped request object.
       */
      public ServletInputStream getInputStream() throws IOException {
          return this.request.getInputStream();
      }
  
      /**
       * The default behavior of this method is to return getParameter(String name)
       * on the wrapped request object.
       */
      public String getParameter(String name) {
          return this.request.getParameter(name);
      }
  
      /**
       * The default behavior of this method is to return getParameterNames()
       * on the wrapped request object.
       */
      public Enumeration getParameterNames() {
          return this.request.getParameterNames();
      }
  
      /**
       * The default behavior of this method is to return getParameterValues(String name)
       * on the wrapped request object.
       */
      public String[] getParameterValues(String name) {
          return this.request.getParameterValues(name);
      }
  
      /**
       * The default behavior of this method is to return getProtocol()
       * on the wrapped request object.
       */
      public String getProtocol() {
          return this.request.getProtocol();
      }
  
      /**
       * The default behavior of this method is to return getScheme()
       * on the wrapped request object.
       */
      public String getScheme() {
          return this.request.getScheme();
      }
  
      /**
       * The default behavior of this method is to return getServerName()
       * on the wrapped request object.
       */
      public String getServerName() {
          return this.request.getServerName();
      }
  
      /**
       * The default behavior of this method is to return getServerPort()
       * on the wrapped request object.
       */
      public int getServerPort() {
          return this.request.getServerPort();
      }
  
      /**
       * The default behavior of this method is to return getReader()
       * on the wrapped request object.
       */
      public BufferedReader getReader() throws IOException {
          return this.request.getReader();
      }
  
      /**
       * The default behavior of this method is to return getRemoteAddr()
       * on the wrapped request object.
       */
      public String getRemoteAddr() {
          return this.request.getRemoteAddr();
      }
  
      /**
       * The default behavior of this method is to return getRemoteHost()
       * on the wrapped request object.
       */
      public String getRemoteHost() {
          return this.request.getRemoteHost();
      }
  
      /**
       * The default behavior of this method is to return setAttribute(String name, Object o)
       * on the wrapped request object.
       */
      public void setAttribute(String name, Object o) {
          this.request.setAttribute(name, o);
      }
  
      /**
       * The default behavior of this method is to call removeAttribute(String name)
       * on the wrapped request object.
       */
      public void removeAttribute(String name) {
          this.request.removeAttribute(name);
      }
  
      /**
       * The default behavior of this method is to return getLocale()
       * on the wrapped request object.
       */
      public Locale getLocale() {
          return this.request.getLocale();
      }
  
      /**
       * The default behavior of this method is to return getLocales()
       * on the wrapped request object.
       */
      public Enumeration getLocales() {
          return this.request.getLocales();
      }
  
      /**
       * The default behavior of this method is to return isSecure()
       * on the wrapped request object.
       */
      public boolean isSecure() {
          return this.request.isSecure();
      }
  
      /**
       * The default behavior of this method is to return getRequestDispatcher(String path)
       * on the wrapped request object.
       */
      public RequestDispatcher getRequestDispatcher(String path) {
          return this.request.getRequestDispatcher(path);
      }
  
      /**
       * The default behavior of this method is to return getRealPath(String path)
       * on the wrapped request object.
       */
      public String getRealPath(String path) {
          return this.request.getRealPath(path);
      }
  
      /**
       * The default behavior of this method is to return getAuthType()
       * on the wrapped request object.
       */
      public String getAuthType() {
          return this.request.getAuthType();
      }
  
      /**
       * The default behavior of this method is to return getCookies()
       * on the wrapped request object.
       */
      public Cookie[] getCookies() {
          return this.request.getCookies();
      }
  
      /**
       * The default behavior of this method is to return getDateHeader(String name)
       * on the wrapped request object.
       */
      public long getDateHeader(String name) {
          return this.request.getDateHeader(name);
      }
  
      /**
       * The default behavior of this method is to return getHeader(String name)
       * on the wrapped request object.
       */
      public String getHeader(String name) {
          return this.request.getHeader(name);
      }
  
      /**
       * The default behavior of this method is to return getHeaders(String name)
       * on the wrapped request object.
       */
      public Enumeration getHeaders(String name) {
          return this.request.getHeaders(name);
      }
  
      /**
       * The default behavior of this method is to return getHeaderNames()
       * on the wrapped request object.
       */
      public Enumeration getHeaderNames() {
          return this.request.getHeaderNames();
      }
  
      /**
       * The default behavior of this method is to return getIntHeader(String name)
       * on the wrapped request object.
       */
      public int getIntHeader(String name) {
          return this.request.getIntHeader(name);
      }
  
      /**
       * The default behavior of this method is to return getMethod()
       * on the wrapped request object.
       */
      public String getMethod() {
          return this.request.getMethod();
      }
  
      /**
       * Returns any extra path information associated with
       * the URL the client sent when it made this request.
       * The extra path information follows the servlet path
       * but precedes the query string.
       * This method returns <code>null</code> if there
       * was no extra path information.
       *
       * <p>Same as the value of the CGI variable PATH_INFO.
       *
       * @return    a <code>String</code>, decoded by the
       *      web container, specifying
       *      extra path information that comes
       *      after the servlet path but before
       *      the query string in the request URL;
       *      or <code>null</code> if the URL does not have
       *      any extra path information
       *
       */
      public String getPathInfo() {
          return uri;
      }
  
      /**
       * The default behavior of this method is to return getPathTranslated()
       * on the wrapped request object.
       */
      public String getPathTranslated() {
          return this.request.getPathTranslated();
      }
  
      /**
       * The default behavior of this method is to return getContextPath()
       * on the wrapped request object.
       */
      public String getContextPath() {
          return this.request.getContextPath();
      }
  
      /**
       * The default behavior of this method is to return getQueryString()
       * on the wrapped request object.
       */
      public String getQueryString() {
          return this.request.getQueryString();
      }
  
      /**
       * The default behavior of this method is to return getRemoteUser()
       * on the wrapped request object.
       */
      public String getRemoteUser() {
          return this.request.getRemoteUser();
      }
  
      /**
       * The default behavior of this method is to return isUserInRole(String role)
       * on the wrapped request object.
       */
      public boolean isUserInRole(String role) {
          return this.request.isUserInRole(role);
      }
  
      /**
       * The default behavior of this method is to return getUserPrincipal()
       * on the wrapped request object.
       */
      public java.security.Principal getUserPrincipal() {
          return this.request.getUserPrincipal();
      }
  
      /**
       * The default behavior of this method is to return getRequestedSessionId()
       * on the wrapped request object.
       */
      public String getRequestedSessionId() {
          return this.request.getRequestedSessionId();
      }
  
      /**
       * The default behavior of this method is to return getRequestURI()
       * on the wrapped request object.
       */
      public String getRequestURI() {
          return this.request.getRequestURI();
      }
  
      /**
       * The default behavior of this method is to return getServletPath()
       * on the wrapped request object.
       */
      public String getServletPath() {
          return this.request.getServletPath();
      }
  
      /**
       * The default behavior of this method is to return getSession(boolean create)
       * on the wrapped request object.
       */
      public HttpSession getSession(boolean create) {
          return this.request.getSession(create);
      }
  
      /**
       * The default behavior of this method is to return getSession()
       * on the wrapped request object.
       */
      public HttpSession getSession() {
          return this.request.getSession();
      }
  
      /**
       * The default behavior of this method is to return isRequestedSessionIdValid()
       * on the wrapped request object.
       */
      public boolean isRequestedSessionIdValid() {
          return this.request.isRequestedSessionIdValid();
      }
  
      /**
       * The default behavior of this method is to return isRequestedSessionIdFromCookie()
       * on the wrapped request object.
       */
      public boolean isRequestedSessionIdFromCookie() {
          return this.request.isRequestedSessionIdFromCookie();
      }
  
      /**
       * The default behavior of this method is to return isRequestedSessionIdFromURL()
       * on the wrapped request object.
       */
      public boolean isRequestedSessionIdFromURL() {
          return this.request.isRequestedSessionIdFromURL();
      }
  
      /**
       * The default behavior of this method is to return isRequestedSessionIdFromUrl()
       * on the wrapped request object.
       */
      public boolean isRequestedSessionIdFromUrl() {
          return this.request.isRequestedSessionIdFromUrl();
      }
  }
  
  
  
  1.1                  xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/reading/helpers/WebdavServletResponse.java
  
  Index: WebdavServletResponse.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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  acknowledgment:   "This product includes software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" 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 name,  without prior written permission  of the
      Apache Software Foundation.
  
   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 (INCLU-
   DING, 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 and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  
  package org.apache.cocoon.reading.helpers;
  
  import java.io.IOException;
  import java.io.OutputStream;
  import java.io.PrintWriter;
  import java.io.UnsupportedEncodingException;
  import java.util.Locale;
  
  import javax.servlet.ServletOutputStream;
  import javax.servlet.http.Cookie;
  import javax.servlet.http.HttpServletResponse;
  
  /**
   * A wrapper for the HttpServletResponse.
   *
   * @author <a href="mailto:stephan@apache.org">Stephan Michels </a>
   * @version CVS $Id: WebdavServletResponse.java,v 1.1 2003/02/15 23:01:48 stephan Exp $
   */
  public class WebdavServletResponse implements HttpServletResponse {
  
      private HttpServletResponse response;
      private OutputStream stream;
  
      public WebdavServletResponse(HttpServletResponse response,
                                   OutputStream stream) {
          this.response = response;
          this.stream = stream;
      }
  
      /**
       * The default behavior of this method is to return getCharacterEncoding()
       * on the wrapped response object.
       *
       * @return
       */
      public String getCharacterEncoding() {
          return this.response.getCharacterEncoding();
      }
  
      /**
       * The default behavior of this method is to return getOutputStream()
       * on the wrapped response object.
       */
      public ServletOutputStream getOutputStream() throws IOException {
          return new WebdavServletOutputStream(this.stream);
      }
  
      /**
       * The default behavior of this method is to return getWriter()
       * on the wrapped response object.
       */
      public PrintWriter getWriter() throws IOException {
          return new PrintWriter(this.stream);
      }
  
      /**
       * The default behavior of this method is to call setContentLength(int len)
       * on the wrapped response object.
       */
      public void setContentLength(int len) {
          this.response.setContentLength(len);
      }
  
      /**
       * The default behavior of this method is to call setContentType(String type)
       * on the wrapped response object.
       */
      public void setContentType(String type) {
          this.response.setContentType(type);
      }
  
      /**
       * The default behavior of this method is to call setBufferSize(int size)
       * on the wrapped response object.
       */
      public void setBufferSize(int size) {
          this.response.setBufferSize(size);
      }
  
      /**
       * The default behavior of this method is to return getBufferSize()
       * on the wrapped response object.
       */
      public int getBufferSize() {
          return this.response.getBufferSize();
      }
  
      /**
       * The default behavior of this method is to call flushBuffer()
       * on the wrapped response object.
       */
      public void flushBuffer() throws IOException {
          this.response.flushBuffer();
      }
  
      /**
       * The default behavior of this method is to return isCommitted()
       * on the wrapped response object.
       */
      public boolean isCommitted() {
          return this.response.isCommitted();
      }
  
      /**
       * The default behavior of this method is to call reset()
       * on the wrapped response object.
       */
      public void reset() {
          this.response.reset();
      }
  
      /**
       * The default behavior of this method is to call setLocale(Locale loc)
       * on the wrapped response object.
       */
      public void setLocale(Locale loc) {
          this.response.setLocale(loc);
      }
  
      /**
       * The default behavior of this method is to return getLocale()
       * on the wrapped response object.
       */
      public Locale getLocale() {
          return this.response.getLocale();
      }
  
      /**
       * The default behavior of this method is to call addCookie(Cookie cookie)
       * on the wrapped response object.
       */
      public void addCookie(Cookie cookie) {
          this.response.addCookie(cookie);
      }
  
      /**
       * The default behavior of this method is to call containsHeader(String name)
       * on the wrapped response object.
       */
      public boolean containsHeader(String name) {
          return this.response.containsHeader(name);
      }
  
      /**
       * The default behavior of this method is to call encodeURL(String url)
       * on the wrapped response object.
       */
      public String encodeURL(String url) {
          return this.response.encodeURL(url);
      }
  
      /**
       * The default behavior of this method is to return encodeRedirectURL(String url)
       * on the wrapped response object.
       */
      public String encodeRedirectURL(String url) {
          return this.response.encodeRedirectURL(url);
      }
  
      /**
       * The default behavior of this method is to call encodeUrl(String url)
       * on the wrapped response object.
       */
      public String encodeUrl(String url) {
          return this.response.encodeUrl(url);
      }
  
      /**
       * The default behavior of this method is to return encodeRedirectUrl(String url)
       * on the wrapped response object.
       */
      public String encodeRedirectUrl(String url) {
          return this.response.encodeRedirectUrl(url);
      }
  
      /**
       * The default behavior of this method is to call sendError(int sc, String msg)
       * on the wrapped response object.
       */
      public void sendError(int sc, String msg) throws IOException {
          this.response.sendError(sc, msg);
      }
  
      /**
       * The default behavior of this method is to call sendError(int sc)
       * on the wrapped response object.
       */
      public void sendError(int sc) throws IOException {
          this.response.sendError(sc);
      }
  
      /**
       * The default behavior of this method is to return sendRedirect(String location)
       * on the wrapped response object.
       */
      public void sendRedirect(String location) throws IOException {
          this.response.sendRedirect(location);
      }
  
      /**
       * The default behavior of this method is to call setDateHeader(String name, long date)
       * on the wrapped response object.
       */
      public void setDateHeader(String name, long date) {
          this.response.setDateHeader(name, date);
      }
  
      /**
       * The default behavior of this method is to call addDateHeader(String name, long date)
       * on the wrapped response object.
       */
      public void addDateHeader(String name, long date) {
          this.response.addDateHeader(name, date);
      }
  
      /**
       * The default behavior of this method is to return setHeader(String name, String value)
       * on the wrapped response object.
       */
      public void setHeader(String name, String value) {
          this.response.setHeader(name, value);
      }
  
      /**
       * The default behavior of this method is to return addHeader(String name, String value)
       * on the wrapped response object.
       */
      public void addHeader(String name, String value) {
          this.response.addHeader(name, value);
      }
  
      /**
       * The default behavior of this method is to call setIntHeader(String name, int value)
       * on the wrapped response object.
       */
      public void setIntHeader(String name, int value) {
          this.response.setIntHeader(name, value);
      }
  
      /**
       * The default behavior of this method is to call addIntHeader(String name, int value)
       * on the wrapped response object.
       */
      public void addIntHeader(String name, int value) {
          this.response.addIntHeader(name, value);
      }
  
      /**
       * The default behavior of this method is to call setStatus(int sc)
       * on the wrapped response object.
       */
      public void setStatus(int sc) {
          this.response.setStatus(sc);
      }
  
      /**
       * The default behavior of this method is to call setStatus(int sc, String sm)
       * on the wrapped response object.
       */
      public void setStatus(int sc, String sm) {
          this.response.setStatus(sc, sm);
      }
  
      public class WebdavServletOutputStream extends ServletOutputStream {
          private OutputStream stream;
  
          public WebdavServletOutputStream(OutputStream stream) {
              this.stream = stream;
          }
  
          public void close() throws IOException {
              //stream.close();
          }
  
          public void flush() throws IOException {
              stream.flush();
          }
  
          public void write(byte[] b) throws IOException {
              stream.write(b);
          }
  
          public void write(byte[] b, int off, int len) throws IOException {
              stream.write(b, off, len);
          }
  
          public void write(int b) throws IOException {
              stream.write(b);
          }
      }
  }
  
  
  
  1.4       +14 -1     xml-cocoon2/src/blocks/slide/samples/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/blocks/slide/samples/sitemap.xmap,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- sitemap.xmap	3 Feb 2003 10:59:05 -0000	1.3
  +++ sitemap.xmap	15 Feb 2003 23:01:48 -0000	1.4
  @@ -25,7 +25,16 @@
      <map:transformer name="log" src="org.apache.cocoon.transformation.LogTransformer"/>
     </map:transformers>
   
  -  <map:readers default="resource"/>
  +  <map:readers default="resource">
  +   <map:reader     logger="sitemap.reader.webdav" name="webdav"  
  +                   src="org.apache.cocoon.reading.WebdavReader">
  +    <parameter name="scope"              value="/files"/>
  +    <parameter name="depth-limit"        value="3"/>
  +    <parameter name="default-mime-type"  value="application/octet-stream"/>
  +    <parameter name="namespace"          value="myrepository"/>
  +    <parameter name="directory-browsing" value="true"/>
  +   </map:reader>
  +  </map:readers>
     <map:serializers default="html">
      <map:serializer logger="sitemap.serializer.xml" mime-type="text/xml" name="xml"
                      src="org.apache.cocoon.serialization.XMLSerializer"/>
  @@ -264,6 +273,10 @@
         </map:generate>
         <map:transform src="principal2html4users.xsl"/>
         <map:serialize type="html"/>
  +     </map:match>
  +
  +     <map:match pattern="webdav/**">
  +      <map:read type="webdav" src="/{1}"/>
        </map:match>
   
       </map:act>
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message