howdy,
another patch, this one's better tested, but contains more changes :P
- Make the WebdavServlet better extendable by making some members
protected instead of private or package private.
- Do not use a static depthLimit member in WebdavMethod, as that
does not allow for different WebdavServlets having different
depth limits, not even if they are in different application
contexts.
- as the depth-limit is only used in PropFindMethod, move it there
and assign it in it's constructor.
- Remove the static init() method of WebdavMethod, and also the
obsolete managerServletPath.
- Move initialization of the md5Helper into a static initialization
block of WebdavMethod.
dunno whether these changes are okay with you, but it's been working
fine in the testing I've done.
-chris
________________________________________________________________
[EMAIL PROTECTED]
Index: src/webdav/server/org/apache/slide/webdav/WebdavServlet.java
===================================================================
RCS file:
/home/cvspublic/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java,v
retrieving revision 1.15
diff -u -r1.15 WebdavServlet.java
--- src/webdav/server/org/apache/slide/webdav/WebdavServlet.java 2001/06/13
17:44:21 1.15
+++ src/webdav/server/org/apache/slide/webdav/WebdavServlet.java 2001/07/10
+07:50:56
@@ -96,32 +96,21 @@
public class WebdavServlet extends HttpServlet {
// ----------------------------------------------------- Instance Variables
/**
* Access token to the namespace.
*/
- NamespaceAccessToken token;
+ protected NamespaceAccessToken token;
+ /**
+ * Depth limit. To limit tree browsing when using depth = infinity.
+ */
+ protected int depthLimit = 3;
+
+
// -------------------------------------------------------- Private Methods
@@ -131,7 +120,7 @@
* @return WebdavMethod
* @exception WebdavException
*/
- private WebdavMethod createWebdavMethod
+ protected WebdavMethod createWebdavMethod
(HttpServletRequest req, HttpServletResponse resp)
throws WebdavException {
@@ -142,7 +131,7 @@
if (methodName.equalsIgnoreCase("GET")) {
resultMethod = new GetMethod(this, token, req, resp);
} else if (methodName.equalsIgnoreCase("PROPFIND")) {
- resultMethod = new PropFindMethod(this, token, req, resp);
+ resultMethod = new PropFindMethod(this, token, req, resp, depthLimit);
} else if (methodName.equalsIgnoreCase("HEAD")) {
resultMethod = new HeadMethod(this, token, req, resp);
} else if (methodName.equalsIgnoreCase("LOCK")) {
@@ -256,8 +245,6 @@
String namespaceName = null;
String domainConfigFile = "/Domain.xml";
- String managerServletPath = "/manager/";
- int depthLimit = 3;
String value = null;
try {
@@ -275,13 +262,6 @@
;
}
try {
- value = getServletConfig().getInitParameter("manager");
- if (value != null)
- managerServletPath = value;
- } catch (Throwable t) {
- ;
- }
- try {
value = getServletConfig().getInitParameter("depth-limit");
if (value != null) {
depthLimit = Integer.parseInt(value);
@@ -289,8 +269,6 @@
} catch (Throwable t) {
;
}
-
- WebdavMethod.init(managerServletPath, depthLimit);
try {
Index: src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java
===================================================================
RCS file:
/home/cvspublic/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
retrieving revision 1.24
diff -u -r1.24 PropFindMethod.java
--- src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java
2001/07/09 18:19:17 1.24
+++ src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java
+2001/07/10 07:51:08
@@ -258,6 +258,12 @@
*/
protected int depth;
+
+ /**
+ * Depth limit. To limit tree browsing when using depth = infinity.
+ */
+ protected int depthLimit;
+
/**
* Type of the PROPFIND method.
@@ -300,8 +306,10 @@
* @param resp HTTP response
*/
public PropFindMethod(GenericServlet servlet, NamespaceAccessToken token,
- HttpServletRequest req, HttpServletResponse resp) {
+ HttpServletRequest req, HttpServletResponse resp,
+ int depthLimit) {
super(servlet, token, req, resp);
+ this.depthLimit = depthLimit;
readRequestContent();
namespaceAbbrevs = new Hashtable();
Index: src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java
===================================================================
RCS file:
/home/cvspublic/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
retrieving revision 1.23
diff -u -r1.23 WebdavMethod.java
--- src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java 2001/06/22
05:47:27 1.23
+++ src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java 2001/07/10
+07:51:09
@@ -233,18 +233,19 @@
*/
protected static final MD5Encoder md5Encoder = new MD5Encoder();
-
- /**
- * Manager servlet path.
- */
- protected static String managerServletPath = "/manager/";
-
-
- /**
- * Depth limit. To limit tree browsing when using depth = infinity
- */
- protected static int depthLimit = 3;
+ // -------------------------------------------------- Static Initialization
+
+ static {
+
+ // Load the MD5 helper used to calculate signatures.
+ try {
+ md5Helper = MessageDigest.getInstance("MD5");
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ throw new IllegalStateException();
+ }
+ }
// ----------------------------------------------------------- Constructors
@@ -304,32 +305,6 @@
/**
- * Initializes static fields.
- *
- * @param servletPath Path of the manager servlet
- */
- public static void init(String servletPath, int limit) {
-
- // Load the MD5 helper used to calculate signatures.
- try {
- md5Helper = MessageDigest.getInstance("MD5");
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- throw new IllegalStateException();
- }
-
- if (servletPath != null) {
- managerServletPath = servletPath;
- }
-
- if (limit>0) {
- depthLimit = limit;
- }
-
- }
-
-
- /**
* Exceute method.
*
* @exception WebdavException