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 je...@apache.org on 2001/04/13 08:39:03 UTC
cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods PropFindMethod.java
jericho 01/04/12 23:39:03
Modified: src/webdav/client/src/org/apache/webdav/util
WebdavResource.java
src/webdav/client/src/org/apache/webdav/lib/methods
PropFindMethod.java
Log:
- Improved to make the WebDAV client download the less XML responses for its performance.
- When the named property is requested, it's reqiured to be DAV property explicity by some WebDAV servers.
Revision Changes Path
1.37 +122 -28 jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java
Index: WebdavResource.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- WebdavResource.java 2001/04/12 17:39:18 1.36
+++ WebdavResource.java 2001/04/13 06:39:02 1.37
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v 1.36 2001/04/12 17:39:18 jericho Exp $
- * $Revision: 1.36 $
- * $Date: 2001/04/12 17:39:18 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v 1.37 2001/04/13 06:39:02 jericho Exp $
+ * $Revision: 1.37 $
+ * $Date: 2001/04/13 06:39:02 $
*
* ====================================================================
*
@@ -383,20 +383,44 @@
/**
+ * Set the named properties for this resource.
+ *
+ * @param depth The depth.
+ * @param propertyNames The property-names.
+ */
+ private void setNamedProp(int depth, Vector propertyNames)
+ throws WebdavException, IOException {
+
+ Enumeration responses = propfindMethod(depth, propertyNames);
+ setWebdavProperties(responses);
+ }
+
+
+ /**
+ * Set all properties for this resource.
+ *
+ * @param depth The depth
+ */
+ private void setAllProp(int depth)
+ throws WebdavException, IOException {
+
+ Enumeration responses = propfindMethod(depth);
+ setWebdavProperties(responses);
+ }
+
+
+ /**
* Set WebDAV properties following to the given http URL.
* This method is fundamental for getting information of a collection.
*
- * @param httpURL the parent http URL to get properties.
+ * @param httpURL The parent http URL to get properties.
* @param depth The depth.
* @exception WebdavException
* @exception IOException The socket error with a server.
*/
- private void setAllProp(HttpURL httpURL, int depth)
+ private void setWebdavProperties(Enumeration responses)
throws WebdavException, IOException {
- // Basically, get resources with depth 1.
- Enumeration responses = propfindMethod(DepthSupport.DEPTH_1);
-
// Make the resources in the collection empty.
children.removeAll();
while (responses.hasMoreElements()) {
@@ -555,7 +579,7 @@
// make its existence false
setExistence(false);
if (action)
- setAllProp(httpURL, DepthSupport.DEPTH_0);
+ setAllProp(DepthSupport.DEPTH_0);
}
@@ -580,7 +604,7 @@
// make its existence false
setExistence(false);
if (action)
- setAllProp(this.httpURL, DepthSupport.DEPTH_0);
+ setAllProp(DepthSupport.DEPTH_0);
}
@@ -1140,7 +1164,7 @@
public WebdavResources getChildren()
throws WebdavException, IOException {
- setAllProp(httpURL, DepthSupport.DEPTH_1);
+ setAllProp(DepthSupport.DEPTH_1);
return children;
}
@@ -1156,10 +1180,10 @@
*/
public String[] list()
throws WebdavException, IOException {
-
- // TODO: required to add the new method for XML reponse's load.
- setAllProp(httpURL, DepthSupport.DEPTH_1);
+ Vector property = new Vector();
+ property.addElement(DISPLAYNAME);
+ setNamedProp(DepthSupport.DEPTH_1, property);
Enumeration hrefs = children.getResourceNames();
// To be atomic.
Vector hrefList = new Vector();
@@ -1192,10 +1216,14 @@
*/
public Vector listInDetail()
throws WebdavException, IOException {
-
- // TODO: required to add the new method for XML reponse's load.
- setAllProp(httpURL, DepthSupport.DEPTH_1);
+ Vector properties = new Vector();
+ properties.addElement(DISPLAYNAME);
+ properties.addElement(GETCONTENTLENGTH);
+ properties.addElement(ISCOLLECTION);
+ properties.addElement(RESOURCETYPE);
+ properties.addElement(GETLASTMODIFIED);
+ setNamedProp(DepthSupport.DEPTH_1, properties);
Enumeration hrefs = children.getResourceNames();
Vector hrefList = new Vector();
while (hrefs.hasMoreElements()) {
@@ -1211,6 +1239,7 @@
long length = currentResource.getGetContentLength();
// getcontentlength
longFormat[1] = new Long(length).toString();
+ // resourcetype
ResourceTypeProperty resourceTypeProperty =
currentResource.getResourceType();
String getContentType =
@@ -1412,7 +1441,7 @@
boolean result = putMethod(httpURL.getPath(), data);
if (result)
- setAllProp(httpURL, DepthSupport.DEPTH_0);
+ setAllProp(DepthSupport.DEPTH_0);
return result;
}
@@ -1457,7 +1486,7 @@
boolean result = putMethod(httpURL.getPath(), file);
if (result)
- setAllProp(httpURL, DepthSupport.DEPTH_0);
+ setAllProp(DepthSupport.DEPTH_0);
return result;
}
@@ -1663,6 +1692,71 @@
}
+
+ /*
+ * Execute PROPFIND method with by propname for theis resource.
+ * Get list of named WebDAV properties on this resource.
+ *
+ * <p>Once used this method, the the status code in the 207
+ * reponse is need to be set for the method of WebdavResource.
+ *
+ * <p>The values of DepthSupport.DEPTH_0, DepthSupport.DEPTH_1
+ * DepthSupport.DEPTH_INFINITY is possbile for the depth.
+ *
+ * @param depth The depth.
+ * @param properties The named properties.
+ * @return The response entity body that has pairs of href and properties.
+ * @exception WebdavException
+ * @exception IOException
+ */
+ public Enumeration propfindMethod(int depth, Vector properties)
+ throws WebdavException, IOException {
+
+ return propfindMethod(httpURL.getPath(), depth, properties);
+ }
+
+
+ /*
+ * Execute PROPFIND method with by propname for the given path.
+ * Get list of named WebDAV properties on the given resource.
+ *
+ * <p>Once used this method, the the status code in the 207
+ * reponse is need to be set for the method of WebdavResource.
+ *
+ * <p>The values of DepthSupport.DEPTH_0, DepthSupport.DEPTH_1
+ * DepthSupport.DEPTH_INFINITY is possbile for the depth.
+ *
+ * @param path The path to request.
+ * @param depth The depth.
+ * @param properties The named properties.
+ * @return The response entity body that has pairs of href and properties.
+ * @exception WebdavException
+ * @exception IOException
+ */
+ public Enumeration propfindMethod(String path, int depth,
+ Vector properties)
+ throws WebdavException, IOException {
+
+ WebdavClient client = getSessionInstance(httpURL);
+
+ // Check the path alright.
+ path = HttpURL.getPath(path);
+ // Change the depth for prop
+ PropFindMethod method = new PropFindMethod(path, depth,
+ properties.elements());
+ client.setDebug(debug);
+ method.setDebug(debug);
+ client.executeMethod(method);
+
+ // Set the status code.
+ setStatusCode(method.getStatusCode());
+ // In order to save this session.
+ this.client = client;
+
+ return method.getResponses();
+ }
+
+
/*
* Execute PROPFIND method for this WebdavResource.
* Get list of given WebDAV properties on this WebDAV resource.
@@ -1803,7 +1897,7 @@
boolean result = proppatchMethod
(httpURL.getPath(), propertyName, propertyValue);
if (result)
- setAllProp(httpURL, DepthSupport.DEPTH_0);
+ setAllProp(DepthSupport.DEPTH_0);
return result;
}
@@ -1841,7 +1935,7 @@
boolean result = proppatchMethod(httpURL.getPath(), property);
if (result)
- setAllProp(httpURL, DepthSupport.DEPTH_0);
+ setAllProp(DepthSupport.DEPTH_0);
return result;
}
@@ -1941,7 +2035,7 @@
boolean result = deleteMethod(httpURL.getPath());
if (result)
- setAllProp(httpURL, DepthSupport.DEPTH_0);
+ setAllProp(DepthSupport.DEPTH_0);
return result;
}
@@ -1985,7 +2079,7 @@
boolean result = moveMethod(httpURL.getPath(),
HttpURL.getPath(destination));
if (result)
- setAllProp(httpURL, DepthSupport.DEPTH_0);
+ setAllProp(DepthSupport.DEPTH_0);
return result;
}
@@ -2033,7 +2127,7 @@
boolean result = copyMethod(httpURL.getPath(),
HttpURL.getPath(destination));
if (result)
- setAllProp(httpURL, DepthSupport.DEPTH_0);
+ setAllProp(DepthSupport.DEPTH_0);
return result;
}
@@ -2079,7 +2173,7 @@
boolean result = mkcolMethod(httpURL.getPath());
if (result)
- setAllProp(httpURL, DepthSupport.DEPTH_0);
+ setAllProp(DepthSupport.DEPTH_0);
return result;
}
@@ -2132,7 +2226,7 @@
boolean result = lockMethod(httpURL.getPath(), owner, (short) 120);
if (result)
- setAllProp(httpURL, DepthSupport.DEPTH_0);
+ setAllProp(DepthSupport.DEPTH_0);
return result;
}
@@ -2152,7 +2246,7 @@
boolean result = lockMethod(httpURL.getPath(), owner, (short) 120);
if (result)
- setAllProp(httpURL, DepthSupport.DEPTH_0);
+ setAllProp(DepthSupport.DEPTH_0);
return result;
}
@@ -2234,7 +2328,7 @@
boolean result = unlockMethod(httpURL.getPath());
if (result)
- setAllProp(httpURL, DepthSupport.DEPTH_0);
+ setAllProp(DepthSupport.DEPTH_0);
return result;
}
1.23 +15 -4 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropFindMethod.java
Index: PropFindMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropFindMethod.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- PropFindMethod.java 2001/04/04 13:04:45 1.22
+++ PropFindMethod.java 2001/04/13 06:39:03 1.23
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropFindMethod.java,v 1.22 2001/04/04 13:04:45 juergen Exp $
- * $Revision: 1.22 $
- * $Date: 2001/04/04 13:04:45 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropFindMethod.java,v 1.23 2001/04/13 06:39:03 jericho Exp $
+ * $Revision: 1.23 $
+ * $Date: 2001/04/13 06:39:03 $
*
* ====================================================================
*
@@ -188,6 +188,17 @@
}
+ /**
+ * Method constructor.
+ */
+ public PropFindMethod(String path, int depth, Enumeration propertyNames) {
+ this(path);
+ setDepth(depth);
+ setPropertyNames(propertyNames);
+ setType(BY_NAME);
+ }
+
+
// ----------------------------------------------------- Instance Variables
@@ -360,7 +371,7 @@
printer.writeElement("D", "prop", XMLPrinter.OPENING);
while (propertyNames.hasMoreElements()) {
String propertyName = (String) propertyNames.nextElement();
- printer.writeElement(null, propertyName,
+ printer.writeElement("D", propertyName,
XMLPrinter.NO_CONTENT);
}
printer.writeElement("D", "prop", XMLPrinter.CLOSING);