jericho 01/03/31 07:41:10
Modified: src/webdav/client/src/org/apache/webdav/util
WebdavResource.java GenericURI.java
Log:
- Make setting WebDAV property robust.
There are some WebDAV servers don't give the <displayname>property.
Bug reported by: Miguel Carvalho <[EMAIL PROTECTED]>
Revision Changes Path
1.25 +17 -6
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.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- WebdavResource.java 2001/03/31 13:36:58 1.24
+++ WebdavResource.java 2001/03/31 15:41:10 1.25
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
1.24 2001/03/31 13:36:58 jericho Exp $
- * $Revision: 1.24 $
- * $Date: 2001/03/31 13:36:58 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
1.25 2001/03/31 15:41:10 jericho Exp $
+ * $Revision: 1.25 $
+ * $Date: 2001/03/31 15:41:10 $
*
* ====================================================================
*
@@ -461,8 +461,7 @@
boolean itself = false;
String httpURLPath = httpURL.getPath();
- String href = (String) response.getHref();
- String hrefPath = HttpURL.getPath(href);
+ String hrefPath = HttpURL.getPath((String) response.getHref());
int compared = httpURLPath.compareTo(hrefPath);
// Compare with the href path and requested-path itself.
if (compared == 0 || compared == -1 && hrefPath.endsWith("/") ||
@@ -571,7 +570,19 @@
}
}
}
- if (displayName != null && !itself)
+ if (displayName == null) {
+ displayName = HttpURL.getName(hrefPath);
+ if (itself) {
+ setDisplayName(displayName);
+ } else {
+ workingResource.setHttpURL
+ (httpURL, displayName, false);
+ workingResource.setExistence(true);
+ workingResource.setOverwrite(getOverwrite());
+ workingResource.setDisplayName(displayName);
+ }
+ }
+ if (!itself)
children.addResource(displayName, workingResource);
}
1.14 +11 -15
jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java
Index: GenericURI.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- GenericURI.java 2001/03/31 02:23:20 1.13
+++ GenericURI.java 2001/03/31 15:41:10 1.14
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v
1.13 2001/03/31 02:23:20 jericho Exp $
- * $Revision: 1.13 $
- * $Date: 2001/03/31 02:23:20 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v
1.14 2001/03/31 15:41:10 jericho Exp $
+ * $Revision: 1.14 $
+ * $Date: 2001/03/31 15:41:10 $
*
* ====================================================================
*
@@ -70,8 +70,6 @@
* URI (Uniform Resource Identifiers), RFC 2396.
* This is the generic URI version.
*
- * If a pathname is a collection or directory, it always ends with "/".
- *
* @author <a href="mailto:[EMAIL PROTECTED]">Park, Sung-Gu</a>
*/
public abstract class GenericURI implements java.io.Serializable {
@@ -711,7 +709,6 @@
/**
* Get the resource or collection name for this generic URI.
- * When you get a collection, the collection name ends with the slash.
*
* @return The resource or collection name string for this generic URI.
*/
@@ -722,7 +719,6 @@
/**
* Get the resource or collection name of the already-normalized path.
- * When you get a collection, the collection name ends with the slash.
*
* @param path the already-normalized path.
* @return the collection name, if the path is a collection,
@@ -730,15 +726,15 @@
*/
public static String getName(String path) {
+ // Return a string starting with the '/' charcater.
String name = getPath(path);
-
- int at = name.lastIndexOf("/");
- int len = name.length();
-
- if ((at != 0) && (at == len-1))
- at = name.substring(0, at-1).lastIndexOf("/");
-
- return (at == 0) ? "/" : name.substring(at+1);
+ // For the root path.
+ if (name.equals("/"))
+ return name;
+ // Remove the last '/' character.
+ if (name.endsWith("/"))
+ name = name.substring(0, name.length()-1);
+ return name.substring(name.lastIndexOf("/") + 1);
}