jericho 01/04/14 06:22:40
Modified: src/webdav/client/src/org/apache/webdav/util
WebdavResource.java
Log:
- Change children varialbe to childResources.
- Update setBasicProperties method from the listInDetail method.
- Add the function to set the status code of this resource for propfind.
Revision Changes Path
1.42 +55 -24
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.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- WebdavResource.java 2001/04/13 17:09:02 1.41
+++ WebdavResource.java 2001/04/14 13:22:40 1.42
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
1.41 2001/04/13 17:09:02 jericho Exp $
- * $Revision: 1.41 $
- * $Date: 2001/04/13 17:09:02 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
1.42 2001/04/14 13:22:40 jericho Exp $
+ * $Revision: 1.42 $
+ * $Date: 2001/04/14 13:22:40 $
*
* ====================================================================
*
@@ -249,11 +249,11 @@
/**
* Table of the hrefs gotten in a collection.
*/
- private WebdavResources children = new WebdavResources();
+ private WebdavResources childResources = new WebdavResources();
/**
- * the flag for this resource.
+ * The flag to set the status code by propfind.
*/
private boolean thisResource;
@@ -422,7 +422,7 @@
throws WebdavException, IOException {
// Make the resources in the collection empty.
- children.removeAll();
+ childResources.removeAll();
while (responses.hasMoreElements()) {
ResponseEntity response =
@@ -437,6 +437,7 @@
// Compare with the href path and requested-path itself.
if (compared == 0 || compared == -1 && href.endsWith("/") ||
compared == 1 && httpURLPath.endsWith("/")) {
+ // Set the status code for this resource.
if (response.getStatusCode() > 0)
setStatusCode(response.getStatusCode());
setExistence(true);
@@ -553,7 +554,7 @@
}
}
if (!itself)
- children.addResource(displayName, workingResource);
+ childResources.addResource(displayName, workingResource);
}
}
@@ -1166,15 +1167,35 @@
* @exception WebdavException
* @exception IOException
*/
- public WebdavResources getChildren()
+ public WebdavResources getChildResources()
throws WebdavException, IOException {
setAllProp(DepthSupport.DEPTH_1);
- return children;
+ return childResources;
}
+ /**
+ * Set the basic properties like displayname, getcontentlength,
+ * iscollection, getcontenttype, resourcetype, getlastmodified
+ * for this resoruce.
+ */
+ public void setBasicProperties()
+ throws WebdavException, IOException {
+
+ Vector properties = new Vector();
+ properties.addElement(DISPLAYNAME);
+ properties.addElement(GETCONTENTLENGTH);
+ properties.addElement(ISCOLLECTION);
+ properties.addElement(GETCONTENTTYPE);
+ properties.addElement(RESOURCETYPE);
+ properties.addElement(GETLASTMODIFIED);
+
+ setNamedProp(DepthSupport.DEPTH_1, properties);
+ }
+
+
/*
* Get an array of pathnames denoting the WebDAV resources in the
* collection denoted by this pathname.
@@ -1189,7 +1210,8 @@
Vector property = new Vector();
property.addElement(DISPLAYNAME);
setNamedProp(DepthSupport.DEPTH_1, property);
- Enumeration hrefs = children.getResourceNames();
+
+ Enumeration hrefs = childResources.getResourceNames();
// To be atomic.
Vector hrefList = new Vector();
while (hrefs.hasMoreElements()) {
@@ -1222,21 +1244,15 @@
public Vector listInDetail()
throws WebdavException, IOException {
- Vector properties = new Vector();
- properties.addElement(DISPLAYNAME);
- properties.addElement(GETCONTENTLENGTH);
- properties.addElement(ISCOLLECTION);
- properties.addElement(GETCONTENTTYPE);
- properties.addElement(RESOURCETYPE);
- properties.addElement(GETLASTMODIFIED);
- setNamedProp(DepthSupport.DEPTH_1, properties);
- Enumeration hrefs = children.getResourceNames();
+ setBasicProperties();
+ Enumeration hrefs = childResources.getResourceNames();
+
Vector hrefList = new Vector();
while (hrefs.hasMoreElements()) {
try {
String resourceName = (String) hrefs.nextElement();
WebdavResource currentResource =
- children.getResource(resourceName);
+ childResources.getResource(resourceName);
String[] longFormat = new String[4];
// displayname.
@@ -1659,6 +1675,7 @@
public Enumeration propfindMethod(int depth)
throws WebdavException, IOException {
+ thisResource = true;
return propfindMethod(httpURL.getPath(), depth);
}
@@ -1693,8 +1710,11 @@
// Default depth=infinity, type=allprop
client.executeMethod(method);
- // Set the status code.
- setStatusCode(method.getStatusCode());
+ // Set status code for this resource.
+ if (thisResource == true) {
+ setStatusCode(method.getStatusCode());
+ }
+ thisResource = false;
return method.getResponses();
}
@@ -1720,6 +1740,7 @@
public Enumeration propfindMethod(int depth, Vector properties)
throws WebdavException, IOException {
+ thisResource = true;
return propfindMethod(httpURL.getPath(), depth, properties);
}
@@ -1756,9 +1777,12 @@
method.setDebug(debug);
client.executeMethod(method);
- if (thisResource)
+ // Set status code for this resource.
+ if (thisResource == true) {
// Set the status code.
setStatusCode(method.getStatusCode());
+ }
+ thisResource = false;
return method.getResponses();
}
@@ -1779,6 +1803,7 @@
Vector property = new Vector();
property.addElement(propertyName);
+ thisResource = true;
return propfindMethod(httpURL.getPath(), property);
}
@@ -1798,6 +1823,7 @@
Vector property = new Vector();
property.addElement(propertyName);
+ thisResource = false;
return propfindMethod(HttpURL.getPath(path), property);
}
@@ -1814,6 +1840,7 @@
public Enumeration propfindMethod(Vector properties)
throws WebdavException, IOException {
+ thisResource = true;
return propfindMethod(httpURL.getPath(), properties);
}
@@ -1851,8 +1878,12 @@
ResponseEntity response =
(ResponseEntity) responses.nextElement();
String href = (String) response.getHref();
- if (response.getStatusCode() > 0)
+
+ // Set status code for this resource.
+ if ((thisResource == true) && (response.getStatusCode() > 0))
setStatusCode(response.getStatusCode());
+ thisResource = false;
+
Enumeration responseProperties =
method.getResponseProperties(href);
while (responseProperties.hasMoreElements()) {