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 cm...@apache.org on 2001/08/01 18:30:59 UTC
cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/method AbstractMultistatusResponseMethod.java AclMethod.java CopyMethod.java DeleteMethod.java GetMethod.java HeadMethod.java LockMethod.java MkcolMethod.java MoveMethod.java OptionsMethod.java PostMethod.java PropFindMethod.java PropPatchMethod.java PutMethod.java UnlockMethod.java WebdavMethod.java
cmlenz 01/08/01 09:30:59
Modified: src/webdav/server/org/apache/slide/webdav WebdavServlet.java
src/webdav/server/org/apache/slide/webdav/method
AbstractMultistatusResponseMethod.java
AclMethod.java CopyMethod.java DeleteMethod.java
GetMethod.java HeadMethod.java LockMethod.java
MkcolMethod.java MoveMethod.java OptionsMethod.java
PostMethod.java PropFindMethod.java
PropPatchMethod.java PutMethod.java
UnlockMethod.java WebdavMethod.java
Added: src/webdav/server/org/apache/slide/webdav
WebdavServletConfig.java
Log:
- Added a WebdavServletConfig class that wraps around ServletConfig and
provides convenient access to configuration parameters (like depth limit)
- Changed WebdavMethod and subclasses to accept a WebdavServletConfig
object in their constructor instead of GenericServlet and ServletContext,
and use the config when required
- Changed WebdavServlet to create the WevdavServletConfig and pass it to
the constructors of the various WebdavMethod subclasses
- You can now use the 'default-mime-type' init-parameter to define which
MIME type will be used if clients don't provide the ContentType header
(but the default default MIME type should probably be
'application/octet-stream' instead of 'text/plain')
Revision Changes Path
1.19 +40 -38 jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java
Index: WebdavServlet.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- WebdavServlet.java 2001/07/25 00:51:34 1.18
+++ WebdavServlet.java 2001/08/01 16:30:58 1.19
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java,v 1.18 2001/07/25 00:51:34 remm Exp $
- * $Revision: 1.18 $
- * $Date: 2001/07/25 00:51:34 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java,v 1.19 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.19 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -141,17 +141,17 @@
/**
- * Depth limit. To limit tree browsing when using depth = infinity.
+ * Configuration of the WebdavServlet.
*/
- protected int depthLimit = 3;
-
-
+ protected WebdavServletConfig config;
+
+
/**
* Directory browsing enabled.
*/
protected boolean directoryBrowsing = true;
-
-
+
+
// ------------------------------------------------------ Protected Methods
@@ -170,35 +170,34 @@
WebdavMethod resultMethod = null;
if (methodName.equalsIgnoreCase("GET")) {
- resultMethod = new GetMethod(this, token, req, resp);
+ resultMethod = new GetMethod(token, req, resp, config);
} else if (methodName.equalsIgnoreCase("PROPFIND")) {
- resultMethod =
- new PropFindMethod(this, token, req, resp, depthLimit);
+ resultMethod = new PropFindMethod(token, req, resp, config);
} else if (methodName.equalsIgnoreCase("HEAD")) {
- resultMethod = new HeadMethod(this, token, req, resp);
+ resultMethod = new HeadMethod(token, req, resp, config);
} else if (methodName.equalsIgnoreCase("LOCK")) {
- resultMethod = new LockMethod(this, token, req, resp);
+ resultMethod = new LockMethod(token, req, resp, config);
} else if (methodName.equalsIgnoreCase("UNLOCK")) {
- resultMethod = new UnlockMethod(this, token, req, resp);
+ resultMethod = new UnlockMethod(token, req, resp, config);
} else if (methodName.equalsIgnoreCase("OPTIONS")) {
- resultMethod = new OptionsMethod(this, token, req, resp);
+ resultMethod = new OptionsMethod(token, req, resp, config);
} else if (methodName.equalsIgnoreCase("PUT")) {
- resultMethod = new PutMethod(this, token, req, resp);
+ resultMethod = new PutMethod(token, req, resp, config);
} else if (methodName.equalsIgnoreCase("MKCOL")) {
- resultMethod = new MkcolMethod(this, token, req, resp);
+ resultMethod = new MkcolMethod(token, req, resp, config);
} else if (methodName.equalsIgnoreCase("POST")) {
- resultMethod = new PostMethod(this, token, req, resp);
+ resultMethod = new PostMethod(token, req, resp, config);
} else if (methodName.equalsIgnoreCase("COPY")) {
- resultMethod = new CopyMethod(this, token, req, resp);
+ resultMethod = new CopyMethod(token, req, resp, config);
} else if (methodName.equalsIgnoreCase("MOVE")) {
- resultMethod = new MoveMethod(this, token, req, resp);
+ resultMethod = new MoveMethod(token, req, resp, config);
} else if (methodName.equalsIgnoreCase("DELETE")) {
- resultMethod = new DeleteMethod(this, token, req, resp);
+ resultMethod = new DeleteMethod(token, req, resp, config);
} else if (methodName.equalsIgnoreCase("PROPPATCH")) {
- resultMethod = new PropPatchMethod(this, token, req, resp);
+ resultMethod = new PropPatchMethod(token, req, resp,config);
} else if (methodName.equalsIgnoreCase("ACL")) {
if( org.apache.slide.util.Configuration.useIntegratedSecurity() )
- resultMethod = new AclMethod(this, token, req, resp);
+ resultMethod = new AclMethod(token, req, resp, config);
}
if (resultMethod == null) {
@@ -218,8 +217,11 @@
long startTime = System.currentTimeMillis();
- // if logging for the request/response is required initialise the facades
- if (Domain.isEnabled("org.apache.slide.webdav.WebdavServlet.requestResponseLogger", Logger.DEBUG)) {
+ // if logging for the request/response is required initialise the
+ // facades
+ if (Domain.isEnabled
+ ("org.apache.slide.webdav.WebdavServlet.requestResponseLogger",
+ Logger.DEBUG)) {
if ( req != null ) req = new XHttpServletRequestFacade(req);
if ( resp != null ) resp = new XHttpServletResponseFacade(resp);
}
@@ -277,11 +279,14 @@
Domain.info
(req.getMethod()
+ ( (resp instanceof XHttpServletResponseFacade)
- ? (" = " + ((XHttpServletResponseFacade)resp).getStatus()
+ ? (" = " + ((XHttpServletResponseFacade)resp)
+ .getStatus()
+ " " + (WebdavStatus.getStatusText
- (((XHttpServletResponseFacade)resp).getStatus())))
+ (((XHttpServletResponseFacade)resp)
+ .getStatus())))
: ("") )
- + " (time: " + (System.currentTimeMillis() - startTime) + " ms)"
+ + " (time: " + (System.currentTimeMillis() - startTime)
+ + " ms)"
+ " URI = " + WebdavMethod.getRelativePath(req));
}
@@ -312,14 +317,6 @@
;
}
try {
- value = getServletConfig().getInitParameter("depth-limit");
- if (value != null) {
- depthLimit = Integer.parseInt(value);
- }
- } catch (Throwable t) {
- ;
- }
- try {
value = getServletConfig().getInitParameter("directory-browsing");
if (value != null) {
directoryBrowsing = new Boolean(value).booleanValue();
@@ -328,6 +325,9 @@
;
}
+ // initialize the shared configuration object
+ config = new WebdavServletConfig(getServletConfig());
+
try {
Domain.init(getServletContext().getResource(domainConfigFile));
@@ -341,7 +341,6 @@
token = Domain.accessNamespace
(new SecurityToken(this), namespaceName);
}
-
}
@@ -351,6 +350,9 @@
public void destroy() {
Domain.closeNamespace(token);
}
+
+
+ // ------------------------------------------------------ Protected Methods
/**
1.1 jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServletConfig.java
Index: WebdavServletConfig.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServletConfig.java,v 1.1 2001/08/01 16:30:58 cmlenz Exp $
* $Revision: 1.1 $
* $Date: 2001/08/01 16:30: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;
import java.util.Enumeration;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
/**
* WebDAV Servlet Configuration. This class wraps around a ServletConfig object
* and makes the parameters conveniently accessible to the WebdavServlet and
* the WebdavMethod subclasses.
*
* @see org.apache.slide.webdav.method.WebdavMethod#getConfig
*
* @author Christopher Lenz (cmlenz at apache.org)
*/
public class WebdavServletConfig
implements ServletConfig {
// -------------------------------------------------------------- Constants
private static final String DEPTH_LIMIT_PARAMETER =
"depth-limit";
private static final String DEFAULT_MIME_TYPE_PARAMETER =
"default-mime-type";
// ----------------------------------------------------- Instance Variables
/**
* Default MIME type of resources.
*/
private String defaultMimeType = "text/plain";
/**
* Depth limit. To limit tree browsing when using depth = infinity.
*/
private int depthLimit = 3;
/**
* The wrapped ServletConfig.
*/
private ServletConfig config;
// ----------------------------------------------------------- Construction
/**
* Constructor.
*
* @param config ServletConfig
*/
WebdavServletConfig(ServletConfig config) {
this.config = config;
ServletContext context = getServletContext();
String value = null;
// read 'depth-limit' parameter
try {
value = getInitParameter(DEPTH_LIMIT_PARAMETER);
if (value == null) {
value = context.getInitParameter(DEPTH_LIMIT_PARAMETER);
}
if (value != null) {
depthLimit = Integer.parseInt(value);
}
} catch (Throwable t) {
;
}
// read 'default-mime-type' parameter
try {
value = getInitParameter(DEFAULT_MIME_TYPE_PARAMETER);
if (value == null) {
value = context.getInitParameter(DEFAULT_MIME_TYPE_PARAMETER);
}
if (value != null) {
defaultMimeType = value;
}
} catch (Throwable t) {
;
}
}
// ------------------------------------------- ServletConfig Implementation
/**
* 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 config.getInitParameter(name);
}
/**
* 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() {
return config.getInitParameterNames();
}
/**
* 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 config.getServletContext();
}
/**
* 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() {
return config.getServletName();
}
// --------------------------------------------------------- Public Methods
/**
* 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 "text/plain")
*/
public String getDefaultMimeType() {
return defaultMimeType;
}
/**
* 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 "Depth: infinity"
*
* @return the depth limit
*/
public int getDepthLimit() {
return depthLimit;
}
}
1.8 +6 -6 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AbstractMultistatusResponseMethod.java
Index: AbstractMultistatusResponseMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AbstractMultistatusResponseMethod.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AbstractMultistatusResponseMethod.java 2001/07/26 02:33:00 1.7
+++ AbstractMultistatusResponseMethod.java 2001/08/01 16:30:58 1.8
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AbstractMultistatusResponseMethod.java,v 1.7 2001/07/26 02:33:00 remm Exp $
- * $Revision: 1.7 $
- * $Date: 2001/07/26 02:33:00 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AbstractMultistatusResponseMethod.java,v 1.8 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.8 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -122,9 +122,9 @@
* @param resp HTTP response
*/
public AbstractMultistatusResponseMethod
- (GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp) {
- super(servlet, token, req, resp);
+ (NamespaceAccessToken token, HttpServletRequest req,
+ HttpServletResponse resp, WebdavServletConfig config) {
+ super(token, req, resp, config);
}
1.10 +7 -7 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AclMethod.java
Index: AclMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AclMethod.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AclMethod.java 2001/07/27 00:31:07 1.9
+++ AclMethod.java 2001/08/01 16:30:58 1.10
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AclMethod.java,v 1.9 2001/07/27 00:31:07 remm Exp $
- * $Revision: 1.9 $
- * $Date: 2001/07/27 00:31:07 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AclMethod.java,v 1.10 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.10 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -150,11 +150,11 @@
* @param req HTTP request
* @param resp HTTP response
*/
- public AclMethod(GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp) {
- super(servlet, token, req, resp);
+ public AclMethod(NamespaceAccessToken token, HttpServletRequest req,
+ HttpServletResponse resp, WebdavServletConfig config) {
+ super(token, req, resp, config);
readRequestContent();
- config = token.getNamespaceConfig();
+ this.config = token.getNamespaceConfig();
}
1.18 +6 -6 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CopyMethod.java
Index: CopyMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CopyMethod.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- CopyMethod.java 2001/07/24 09:34:55 1.17
+++ CopyMethod.java 2001/08/01 16:30:58 1.18
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CopyMethod.java,v 1.17 2001/07/24 09:34:55 juergen Exp $
- * $Revision: 1.17 $
- * $Date: 2001/07/24 09:34:55 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CopyMethod.java,v 1.18 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.18 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -101,9 +101,9 @@
* @param req HTTP request
* @param resp HTTP response
*/
- public CopyMethod(GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp) {
- super(servlet, token, req, resp);
+ public CopyMethod(NamespaceAccessToken token, HttpServletRequest req,
+ HttpServletResponse resp, WebdavServletConfig config) {
+ super(token, req, resp, config);
}
1.12 +6 -6 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/DeleteMethod.java
Index: DeleteMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/DeleteMethod.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DeleteMethod.java 2001/07/24 09:34:55 1.11
+++ DeleteMethod.java 2001/08/01 16:30:58 1.12
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/DeleteMethod.java,v 1.11 2001/07/24 09:34:55 juergen Exp $
- * $Revision: 1.11 $
- * $Date: 2001/07/24 09:34:55 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/DeleteMethod.java,v 1.12 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.12 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -105,9 +105,9 @@
* @param req HTTP request
* @param resp HTTP response
*/
- public DeleteMethod(GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp) {
- super(servlet, token, req, resp);
+ public DeleteMethod(NamespaceAccessToken token, HttpServletRequest req,
+ HttpServletResponse resp, WebdavServletConfig config) {
+ super(token, req, resp, config);
}
1.15 +7 -7 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/GetMethod.java
Index: GetMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/GetMethod.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- GetMethod.java 2001/07/25 11:28:07 1.14
+++ GetMethod.java 2001/08/01 16:30:58 1.15
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/GetMethod.java,v 1.14 2001/07/25 11:28:07 juergen Exp $
- * $Revision: 1.14 $
- * $Date: 2001/07/25 11:28:07 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/GetMethod.java,v 1.15 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.15 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -83,8 +83,8 @@
import org.apache.slide.structure.ObjectNotFoundException;
import org.apache.slide.structure.Structure;
import org.apache.slide.webdav.WebdavException;
+import org.apache.slide.webdav.WebdavServletConfig;
-
/**
* GET method.
*
@@ -152,9 +152,9 @@
* @param req HTTP request
* @param resp HTTP response
*/
- public GetMethod(GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp) {
- super(servlet, token, req, resp);
+ public GetMethod(NamespaceAccessToken token, HttpServletRequest req,
+ HttpServletResponse resp, WebdavServletConfig config) {
+ super(token, req, resp, config);
}
1.3 +6 -6 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/HeadMethod.java
Index: HeadMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/HeadMethod.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HeadMethod.java 2001/03/23 05:08:29 1.2
+++ HeadMethod.java 2001/08/01 16:30:58 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/HeadMethod.java,v 1.2 2001/03/23 05:08:29 remm Exp $
- * $Revision: 1.2 $
- * $Date: 2001/03/23 05:08:29 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/HeadMethod.java,v 1.3 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -94,9 +94,9 @@
* @param req HTTP request
* @param resp HTTP response
*/
- public HeadMethod(GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp) {
- super(servlet, token, req, resp);
+ public HeadMethod(NamespaceAccessToken token, HttpServletRequest req,
+ HttpServletResponse resp, WebdavServletConfig config) {
+ super(token, req, resp, config);
printContent = false;
}
1.19 +6 -6 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java
Index: LockMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- LockMethod.java 2001/07/27 00:31:07 1.18
+++ LockMethod.java 2001/08/01 16:30:58 1.19
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java,v 1.18 2001/07/27 00:31:07 remm Exp $
- * $Revision: 1.18 $
- * $Date: 2001/07/27 00:31:07 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java,v 1.19 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.19 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -188,9 +188,9 @@
* @param req HTTP request
* @param resp HTTP response
*/
- public LockMethod(GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp) {
- super(servlet, token, req, resp);
+ public LockMethod(NamespaceAccessToken token, HttpServletRequest req,
+ HttpServletResponse resp, WebdavServletConfig config) {
+ super(token, req, resp, config);
readRequestContent();
}
1.12 +6 -6 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MkcolMethod.java
Index: MkcolMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MkcolMethod.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- MkcolMethod.java 2001/07/25 11:28:07 1.11
+++ MkcolMethod.java 2001/08/01 16:30:58 1.12
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MkcolMethod.java,v 1.11 2001/07/25 11:28:07 juergen Exp $
- * $Revision: 1.11 $
- * $Date: 2001/07/25 11:28:07 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MkcolMethod.java,v 1.12 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.12 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -108,9 +108,9 @@
* @param req HTTP request
* @param resp HTTP response
*/
- public MkcolMethod(GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp) {
- super(servlet, token, req, resp);
+ public MkcolMethod(NamespaceAccessToken token, HttpServletRequest req,
+ HttpServletResponse resp, WebdavServletConfig config) {
+ super(token, req, resp, config);
}
1.18 +6 -6 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java
Index: MoveMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- MoveMethod.java 2001/07/24 09:34:55 1.17
+++ MoveMethod.java 2001/08/01 16:30:58 1.18
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java,v 1.17 2001/07/24 09:34:55 juergen Exp $
- * $Revision: 1.17 $
- * $Date: 2001/07/24 09:34:55 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java,v 1.18 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.18 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -98,9 +98,9 @@
* @param req HTTP request
* @param resp HTTP response
*/
- public MoveMethod(GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp) {
- super(servlet, token, req, resp);
+ public MoveMethod(NamespaceAccessToken token, HttpServletRequest req,
+ HttpServletResponse resp, WebdavServletConfig config) {
+ super(token, req, resp, config);
}
1.7 +7 -6 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/OptionsMethod.java
Index: OptionsMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/OptionsMethod.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- OptionsMethod.java 2001/07/12 12:13:24 1.6
+++ OptionsMethod.java 2001/08/01 16:30:58 1.7
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/OptionsMethod.java,v 1.6 2001/07/12 12:13:24 juergen Exp $
- * $Revision: 1.6 $
- * $Date: 2001/07/12 12:13:24 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/OptionsMethod.java,v 1.7 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.7 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -88,9 +88,10 @@
// ----------------------------------------------------------- Constructors
- public OptionsMethod(GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp) {
- super(servlet, token, req, resp);
+ public OptionsMethod(NamespaceAccessToken token, HttpServletRequest req,
+ HttpServletResponse resp,
+ WebdavServletConfig config) {
+ super(token, req, resp, config);
}
protected void parseRequest()
1.3 +6 -6 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PostMethod.java
Index: PostMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PostMethod.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PostMethod.java 2001/03/23 05:08:31 1.2
+++ PostMethod.java 2001/08/01 16:30:58 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PostMethod.java,v 1.2 2001/03/23 05:08:31 remm Exp $
- * $Revision: 1.2 $
- * $Date: 2001/03/23 05:08:31 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PostMethod.java,v 1.3 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -83,9 +83,9 @@
// ----------------------------------------------------------- Constructors
- public PostMethod(GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp) {
- super(servlet, token, req, resp);
+ public PostMethod(NamespaceAccessToken token, HttpServletRequest req,
+ HttpServletResponse resp, WebdavServletConfig config) {
+ super(token, req, resp, config);
}
protected void parseRequest()
1.34 +14 -22 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java
Index: PropFindMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- PropFindMethod.java 2001/07/30 19:55:09 1.33
+++ PropFindMethod.java 2001/08/01 16:30:58 1.34
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v 1.33 2001/07/30 19:55:09 dirkv Exp $
- * $Revision: 1.33 $
- * $Date: 2001/07/30 19:55:09 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v 1.34 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.34 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -261,12 +261,6 @@
/**
- * Depth limit. To limit tree browsing when using depth = infinity.
- */
- protected int depthLimit;
-
-
- /**
* Type of the PROPFIND method.
*/
protected int propFindType;
@@ -300,11 +294,10 @@
* @param req HTTP request
* @param resp HTTP response
*/
- public PropFindMethod(GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp,
- int depthLimit) {
- super(servlet, token, req, resp);
- this.depthLimit = depthLimit;
+ public PropFindMethod(NamespaceAccessToken token, HttpServletRequest req,
+ HttpServletResponse resp,
+ WebdavServletConfig config) {
+ super(token, req, resp, config);
readRequestContent();
namespaces = new HashMap();
@@ -325,8 +318,8 @@
protected void parseRequest()
throws WebdavException {
+ // parse Depth header
String depthStr = req.getHeader("Depth");
-
if (depthStr == null) {
depth = INFINITY;
} else if (depthStr.equals("0")) {
@@ -338,18 +331,17 @@
} else {
try {
depth = Integer.parseInt(depthStr);
+ if (depth < 0) {
+ depth = 0;
+ }
} catch (NumberFormatException ex) {
depth = INFINITY;
}
}
-
- if (depth<0) {
- depth=0;
- }
- // To limit tree browsing a bit
- if (depth > depthLimit) {
- depth = depthLimit;
+ // limit tree browsing a bit
+ if (depth > getConfig().getDepthLimit()) {
+ depth = getConfig().getDepthLimit();
}
if (req.getContentLength() != 0) {
1.18 +7 -6 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java
Index: PropPatchMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- PropPatchMethod.java 2001/07/27 00:31:07 1.17
+++ PropPatchMethod.java 2001/08/01 16:30:58 1.18
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java,v 1.17 2001/07/27 00:31:07 remm Exp $
- * $Revision: 1.17 $
- * $Date: 2001/07/27 00:31:07 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java,v 1.18 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.18 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -135,9 +135,10 @@
* @param req HTTP request
* @param resp HTTP response
*/
- public PropPatchMethod(GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp) {
- super(servlet, token, req, resp);
+ public PropPatchMethod(NamespaceAccessToken token, HttpServletRequest req,
+ HttpServletResponse resp,
+ WebdavServletConfig config) {
+ super(token, req, resp, config);
readRequestContent();
}
1.15 +10 -10 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PutMethod.java
Index: PutMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PutMethod.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- PutMethod.java 2001/07/25 11:28:07 1.14
+++ PutMethod.java 2001/08/01 16:30:58 1.15
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PutMethod.java,v 1.14 2001/07/25 11:28:07 juergen Exp $
- * $Revision: 1.14 $
- * $Date: 2001/07/25 11:28:07 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PutMethod.java,v 1.15 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.15 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -108,9 +108,9 @@
* @param req HTTP request
* @param resp HTTP response
*/
- public PutMethod(GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp) {
- super(servlet, token, req, resp);
+ public PutMethod(NamespaceAccessToken token, HttpServletRequest req,
+ HttpServletResponse resp, WebdavServletConfig config) {
+ super(token, req, resp, config);
}
@@ -203,11 +203,11 @@
String contentType = req.getContentType();
if (contentType == null) {
- contentType = servlet.getServletContext()
+ contentType = getConfig().getServletContext()
.getMimeType(resourcePath);
}
if (contentType == null) {
- contentType = "text/plain";
+ contentType = getConfig().getDefaultMimeType();
}
property = new NodeProperty("getcontenttype", contentType,
true);
@@ -264,11 +264,11 @@
// Get content type
String contentType = req.getContentType();
if (contentType == null) {
- contentType = servlet.getServletContext()
+ contentType = getConfig().getServletContext()
.getMimeType(resourcePath);
}
if (contentType == null) {
- contentType = "text/plain";
+ contentType = getConfig().getDefaultMimeType();
}
property = new NodeProperty("getcontenttype", contentType,
true);
1.13 +6 -6 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UnlockMethod.java
Index: UnlockMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UnlockMethod.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- UnlockMethod.java 2001/07/25 11:28:07 1.12
+++ UnlockMethod.java 2001/08/01 16:30:58 1.13
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UnlockMethod.java,v 1.12 2001/07/25 11:28:07 juergen Exp $
- * $Revision: 1.12 $
- * $Date: 2001/07/25 11:28:07 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UnlockMethod.java,v 1.13 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.13 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -110,9 +110,9 @@
* @param req HTTP request
* @param resp HTTP response
*/
- public UnlockMethod(GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp) {
- super(servlet, token, req, resp);
+ public UnlockMethod(NamespaceAccessToken token, HttpServletRequest req,
+ HttpServletResponse resp, WebdavServletConfig config) {
+ super(token, req, resp, config);
}
1.32 +21 -17 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java
Index: WebdavMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- WebdavMethod.java 2001/07/27 00:31:07 1.31
+++ WebdavMethod.java 2001/08/01 16:30:58 1.32
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v 1.31 2001/07/27 00:31:07 remm Exp $
- * $Revision: 1.31 $
- * $Date: 2001/07/27 00:31:07 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v 1.32 2001/08/01 16:30:58 cmlenz Exp $
+ * $Revision: 1.32 $
+ * $Date: 2001/08/01 16:30:58 $
*
* ====================================================================
*
@@ -134,18 +134,12 @@
/**
- * HTTP servlet.
+ * Configuration.
*/
- protected GenericServlet servlet;
+ private WebdavServletConfig config;
/**
- * Servlet context.
- */
- protected ServletContext context;
-
-
- /**
* Request body.
*/
protected String requestBody;
@@ -226,13 +220,12 @@
/**
* Method constructor.
*/
- public WebdavMethod(GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp) {
+ public WebdavMethod(NamespaceAccessToken token, HttpServletRequest req,
+ HttpServletResponse resp, WebdavServletConfig config) {
this.req = req;
this.resp = resp;
- this.servlet = servlet;
- this.context = servlet.getServletContext();
+ this.config = config;
this.token = token;
this.structure = token.getStructureHelper();
@@ -281,8 +274,19 @@
return token;
}
-
-
+
+
+ /**
+ * Returns the configuration of the WebdavServlet.
+ *
+ * @return WebdavServletConfig
+ */
+ public WebdavServletConfig getConfig() {
+
+ return config;
+ }
+
+
/**
* Return the relative path associated with this servlet.
*
Re: cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/method AbstractMultistatusResponseMethod.java AclMethod.java CopyMethod.java DeleteMethod.java GetMethod.java HeadMethod.java LockMethod.java MkcolMethod.java MoveMethod.java OptionsMe
Posted by Remy Maucherat <re...@apache.org>.
> cmlenz 01/08/01 09:30:59
>
> Modified: src/webdav/server/org/apache/slide/webdav
WebdavServlet.java
> src/webdav/server/org/apache/slide/webdav/method
> AbstractMultistatusResponseMethod.java
> AclMethod.java CopyMethod.java DeleteMethod.java
> GetMethod.java HeadMethod.java LockMethod.java
> MkcolMethod.java MoveMethod.java
OptionsMethod.java
> PostMethod.java PropFindMethod.java
> PropPatchMethod.java PutMethod.java
> UnlockMethod.java WebdavMethod.java
> Added: src/webdav/server/org/apache/slide/webdav
> WebdavServletConfig.java
> Log:
> - Added a WebdavServletConfig class that wraps around ServletConfig and
> provides convenient access to configuration parameters (like depth
limit)
> - Changed WebdavMethod and subclasses to accept a WebdavServletConfig
> object in their constructor instead of GenericServlet and
ServletContext,
> and use the config when required
> - Changed WebdavServlet to create the WevdavServletConfig and pass it to
> the constructors of the various WebdavMethod subclasses
> - You can now use the 'default-mime-type' init-parameter to define which
> MIME type will be used if clients don't provide the ContentType header
> (but the default default MIME type should probably be
> 'application/octet-stream' instead of 'text/plain')
Didn't try it yet, but that looks good.
I would suggest the default content-type to be binary too. It looks a lot
safer ... Otherwise, HTTP browsers will attempt to display the resource.
Remy