remm 01/07/10 15:32:29
Modified: src/webdav/server/org/apache/slide/webdav WebdavServlet.java
src/webdav/server/org/apache/slide/webdav/method
PropFindMethod.java WebdavMethod.java
Log:
- 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.
- Patch submitted by Christopher Lenz <cmlenz at gmx.de>
Revision Changes Path
1.16 +13 -17
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.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- WebdavServlet.java 2001/06/13 17:44:21 1.15
+++ WebdavServlet.java 2001/07/10 22:32:17 1.16
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java,v
1.15 2001/06/13 17:44:21 remm Exp $
- * $Revision: 1.15 $
- * $Date: 2001/06/13 17:44:21 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java,v
1.16 2001/07/10 22:32:17 remm Exp $
+ * $Revision: 1.16 $
+ * $Date: 2001/07/10 22:32:17 $
*
* ====================================================================
*
@@ -119,9 +119,15 @@
/**
* 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 +137,7 @@
* @return WebdavMethod
* @exception WebdavException
*/
- private WebdavMethod createWebdavMethod
+ protected WebdavMethod createWebdavMethod
(HttpServletRequest req, HttpServletResponse resp)
throws WebdavException {
@@ -142,7 +148,8 @@
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 +263,6 @@
String namespaceName = null;
String domainConfigFile = "/Domain.xml";
- String managerServletPath = "/manager/";
- int depthLimit = 3;
String value = null;
try {
@@ -275,13 +280,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 +287,6 @@
} catch (Throwable t) {
;
}
-
- WebdavMethod.init(managerServletPath, depthLimit);
try {
1.25 +12 -4
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.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- PropFindMethod.java 2001/07/09 18:19:17 1.24
+++ PropFindMethod.java 2001/07/10 22:32:24 1.25
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
1.24 2001/07/09 18:19:17 remm Exp $
- * $Revision: 1.24 $
- * $Date: 2001/07/09 18:19:17 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
1.25 2001/07/10 22:32:24 remm Exp $
+ * $Revision: 1.25 $
+ * $Date: 2001/07/10 22:32:24 $
*
* ====================================================================
*
@@ -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();
1.24 +19 -41
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.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- WebdavMethod.java 2001/06/22 05:47:27 1.23
+++ WebdavMethod.java 2001/07/10 22:32:26 1.24
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
1.23 2001/06/22 05:47:27 msmith Exp $
- * $Revision: 1.23 $
- * $Date: 2001/06/22 05:47:27 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
1.24 2001/07/10 22:32:26 remm Exp $
+ * $Revision: 1.24 $
+ * $Date: 2001/07/10 22:32:26 $
*
* ====================================================================
*
@@ -234,16 +234,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 +307,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
@@ -351,14 +328,15 @@
transactionIsStarted = false;
}
} catch (WebdavException ex) {
- // ignore the WebDav Exception and assume that the response code is
already set.
+ // Ignore the WebDav Exception and assume that the response code
+ // is already set.
} catch (Exception ex) {
ex.printStackTrace();
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
} finally {
if (transactionIsStarted && methodNeedsTransactionSupport()) {
- // something went wrong, we are here and the TA is still open
+ // Something went wrong, we are here and the TA is still open
try {
token.rollback();
} catch (Exception e) {